1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-25 02:50:08 +03:00

Feature #4320: vm.updateconf dialog in sunstone admin view

This commit is contained in:
Carlos Martín 2016-04-25 18:04:56 +02:00
parent 0b4592bfd0
commit f615a4e7a9
31 changed files with 581 additions and 73 deletions

View File

@ -215,6 +215,7 @@ tabs:
vm_snapshot_tab: true
vm_placement_tab: true
vm_actions_tab: true
vm_conf_tab: true
vm_template_tab: true
vm_log_tab: true
table_columns:
@ -273,6 +274,7 @@ tabs:
VM.resched: true
VM.unresched: true
VM.saveas_template: true
VM.updateconf: true
oneflow-services-tab:
panel_tabs:
service_info_tab: true

View File

@ -215,6 +215,7 @@ tabs:
vm_snapshot_tab: true
vm_placement_tab: true
vm_actions_tab: true
vm_conf_tab: false
vm_template_tab: true
vm_log_tab: true
table_columns:
@ -273,6 +274,7 @@ tabs:
VM.resched: true
VM.unresched: true
VM.saveas_template: false
VM.updateconf: false
oneflow-services-tab:
panel_tabs:
service_info_tab: true

View File

@ -214,6 +214,7 @@ tabs:
vm_snapshot_tab: false
vm_placement_tab: false
vm_actions_tab: false
vm_conf_tab: false
vm_template_tab: false
vm_log_tab: false
table_columns:
@ -272,6 +273,7 @@ tabs:
VM.resched: false
VM.unresched: false
VM.saveas_template: true
VM.updateconf: false
oneflow-services-tab:
panel_tabs:
service_info_tab: true

View File

@ -216,6 +216,7 @@ tabs:
vm_snapshot_tab: false
vm_placement_tab: false
vm_actions_tab: false
vm_conf_tab: false
vm_template_tab: false
vm_log_tab: false
table_columns:
@ -274,6 +275,7 @@ tabs:
VM.resched: false
VM.unresched: false
VM.saveas_template: false
VM.updateconf: false
oneflow-services-tab:
panel_tabs:
service_info_tab: true

View File

@ -218,6 +218,7 @@ tabs:
vm_snapshot_tab: true
vm_placement_tab: false
vm_actions_tab: true
vm_conf_tab: true
vm_template_tab: false
vm_log_tab: false
table_columns:
@ -276,6 +277,7 @@ tabs:
VM.resched: false
VM.unresched: false
VM.saveas_template: true
VM.updateconf: true
oneflow-services-tab:
panel_tabs:
service_info_tab: true

View File

@ -72,6 +72,7 @@ module OpenNebulaJSON
when "attachnic" then self.nic_attach(action_hash['params'])
when "detachnic" then self.nic_detach(action_hash['params'])
when "update" then self.update(action_hash['params'])
when "updateconf" then self.updateconf(action_hash['params'])
when "rename" then self.rename(action_hash['params'])
when "undeploy" then self.undeploy(action_hash['params'])
when "resched" then self.resched
@ -180,6 +181,10 @@ module OpenNebulaJSON
end
end
def updateconf(params=Hash.new)
super(params['template_raw'])
end
def rename(params=Hash.new)
super(params['name'])
end

View File

@ -476,6 +476,10 @@ define(function(require) {
var action_obj = {"template_raw" : params.data.extra_param};
OpenNebulaAction.simple_action(params, RESOURCE, "update", action_obj);
},
"updateconf": function(params) {
var action_obj = {"template_raw" : params.data.extra_param};
OpenNebulaAction.simple_action(params, RESOURCE, "updateconf", action_obj);
},
"monitor" : function(params) {
OpenNebulaAction.monitor(params, RESOURCE, false);
},

View File

@ -28,6 +28,7 @@ define(function(require) {
var FilesTable = require('tabs/files-tab/datatable')
var OpenNebulaHost = require('opennebula/host');
var UserInputs = require('utils/user-inputs');
var UniqueId = require('utils/unique-id');
/*
TEMPLATES
@ -50,12 +51,12 @@ define(function(require) {
throw "Wizard Tab not enabled";
}
this.wizardTabId = WIZARD_TAB_ID;
this.wizardTabId = WIZARD_TAB_ID + UniqueId.id();
this.icon = 'fa-folder';
this.title = Locale.tr("Context");
this.classes = "hypervisor only_kvm only_vcenter";
this.contextFilesTable = new FilesTable(this.wizardTabId + 'ContextTable', {
this.contextFilesTable = new FilesTable('ContextTable' + UniqueId.id(), {
'select': true,
'selectOptions': {
'multiple_choice': true,

View File

@ -99,19 +99,17 @@
<label for="ENCODE_START_SCRIPT">{{tr " Encode Script in Base64"}}</label>
</div>
</div>
<hr>
<div class="">
<div class="large-12 columns">
<fieldset class="row">
<legend>
<i class="fa fa-lg fa-fw fa-cogs off-color"/>{{tr "User Inputs"}}
{{{tip (tr "These attributes must be provided by the user when a new VM is intantatiated using each template. They will be included in the VM context")}}}
</legend>
<div class="row">
<div class="large-12 columns">{{{userInputsHTML}}}</div>
</div>
</fieldset>
</div>
<br/>
<div class="large-12 columns vm_updateconf_hide">
<fieldset class="row">
<legend>
<i class="fa fa-lg fa-fw fa-cogs off-color"/>{{tr "User Inputs"}}
{{{tip (tr "These attributes must be provided by the user when a new VM is intantatiated using each template. They will be included in the VM context")}}}
</legend>
<div class="row">
<div class="large-12 columns">{{{userInputsHTML}}}</div>
</div>
</fieldset>
</div>
</div>
<div class="wizard_internal_tab tabs-panel" id="filesTab">

View File

@ -25,6 +25,7 @@ define(function(require) {
var WizardFields = require('utils/wizard-fields');
var Config = require('sunstone-config');
var UserInputs = require('utils/user-inputs');
var UniqueId = require('utils/unique-id');
/*
TEMPLATES
@ -43,7 +44,7 @@ define(function(require) {
*/
function WizardTab() {
this.wizardTabId = WIZARD_TAB_ID;
this.wizardTabId = WIZARD_TAB_ID + UniqueId.id();
this.icon = 'fa-laptop';
this.title = Locale.tr("General");
}

View File

@ -24,6 +24,7 @@ define(function(require) {
var Locale = require('utils/locale');
var Tips = require('utils/tips');
var WizardFields = require('utils/wizard-fields');
var UniqueId = require('utils/unique-id');
/*
TEMPLATES
@ -229,7 +230,7 @@ define(function(require) {
throw "Wizard Tab not enabled";
}
this.wizardTabId = WIZARD_TAB_ID;
this.wizardTabId = WIZARD_TAB_ID + UniqueId.id();
this.icon = 'fa-cloud';
this.title = Locale.tr("Hybrid");
}

View File

@ -24,6 +24,7 @@ define(function(require) {
var Tips = require('utils/tips');
var WizardFields = require('utils/wizard-fields');
var TemplateUtils = require('utils/template-utils');
var UniqueId = require('utils/unique-id');
/*
TEMPLATES
@ -46,7 +47,7 @@ define(function(require) {
throw "Wizard Tab not enabled";
}
this.wizardTabId = WIZARD_TAB_ID;
this.wizardTabId = WIZARD_TAB_ID + UniqueId.id();
this.icon = 'fa-exchange';
this.title = Locale.tr("Input/Output");
}

View File

@ -27,7 +27,7 @@
<input type="radio" name="graphics_type" ID="radioSdlType" value="SDL" class="hypervisor only_kvm" >
<label class="hypervisor only_kvm" for="radioSdlType">SDL</label>
<input type="radio" name="graphics_type" ID="radioSpiceType" value="SPICE" class="hypervisor only_kvm" >
<label class="hypervisor only_kvm" for="radionSpiceType">SPICE</label>
<label class="hypervisor only_kvm" for="radioSpiceType">SPICE</label>
</div>
</div>
<br>

View File

@ -25,6 +25,7 @@ define(function(require) {
var Tips = require('utils/tips');
var WizardFields = require('utils/wizard-fields');
var NicTab = require('./network/nic-tab');
var UniqueId = require('utils/unique-id');
/*
TEMPLATES
@ -49,7 +50,7 @@ define(function(require) {
throw "Wizard Tab not enabled";
}
this.wizardTabId = WIZARD_TAB_ID;
this.wizardTabId = WIZARD_TAB_ID + UniqueId.id();
this.icon = 'fa-globe';
this.title = Locale.tr("Network");
this.classes = "hypervisor only_kvm only_vcenter"

View File

@ -25,6 +25,7 @@ define(function(require) {
var Tips = require('utils/tips');
var WizardFields = require('utils/wizard-fields');
var FilesTable = require('tabs/files-tab/datatable');
var UniqueId = require('utils/unique-id');
/*
TEMPLATES
@ -141,21 +142,23 @@ define(function(require) {
throw "Wizard Tab not enabled";
}
this.wizardTabId = WIZARD_TAB_ID;
this.wizardTabId = WIZARD_TAB_ID + UniqueId.id();
this.icon = 'fa-power-off';
this.title = Locale.tr("OS Booting");
this.classes = "hypervisor only_kvm"
this.kernelFilesTable = new FilesTable(this.wizardTabId + 'KernelTable', {
'select': true,
'selectOptions': {
"filter_fn": function(file) { return file.TYPE == 3; } // KERNEL
this.kernelFilesTable = new FilesTable(
this.wizardTabId + UniqueId.id(),
{ 'select': true,
'selectOptions': {
"filter_fn": function(file) { return file.TYPE == 3; } // KERNEL
}
});
this.initrdFilesTable = new FilesTable(this.wizardTabId + 'InitrdTable', {
'select': true,
'selectOptions': {
"filter_fn": function(file) { return file.TYPE == 4; } // RAMDISK
this.initrdFilesTable = new FilesTable(
this.wizardTabId + UniqueId.id(),
{ 'select': true,
'selectOptions': {
"filter_fn": function(file) { return file.TYPE == 4; } // RAMDISK
}
});
}
@ -272,6 +275,15 @@ define(function(require) {
function _fill(context, templateJSON) {
var osJSON = templateJSON['OS'];
if (osJSON) {
if (osJSON['KERNEL_DS'] == undefined && osJSON['KERNEL'] != undefined){
$('input#radioKernelPath', context).click();
}
if (osJSON['INITRD_DS'] == undefined && osJSON['INITRD'] != undefined){
$('input#radioInitrdPath', context).click();
}
WizardFields.fill(context, osJSON);
if (osJSON && osJSON['BOOT']) {

View File

@ -26,6 +26,7 @@ define(function(require) {
var TemplateUtils = require('utils/template-utils');
var CustomTagsTable = require('utils/custom-tags-table');
var OpenNebulaHost = require('opennebula/host');
var UniqueId = require('utils/unique-id');
/*
TEMPLATES
@ -49,7 +50,7 @@ define(function(require) {
throw "Wizard Tab not enabled";
}
this.wizardTabId = WIZARD_TAB_ID;
this.wizardTabId = WIZARD_TAB_ID + UniqueId.id();
this.icon = 'fa-ellipsis-h';
this.title = Locale.tr("Other");
}
@ -146,12 +147,15 @@ define(function(require) {
var templateJSON = CustomTagsTable.retrieve(context);
var rawJSON = {}
t = $('#raw_type', context).val();
if (t) { rawJSON['TYPE'] = t; }
t = TemplateUtils.escapeDoubleQuotes($('#raw_data', context).val());
if (t) { rawJSON['DATA'] = t; }
t = TemplateUtils.escapeDoubleQuotes($('#raw_data_vmx', context).val());
if (t) { rawJSON['DATA_VMX'] = t; }
var rawData = TemplateUtils.escapeDoubleQuotes($('#raw_data', context).val());
if (rawData != "") {
rawJSON['DATA'] = rawData;
var rawType = $('#raw_type', context).val();
if (rawType != undefined) {
rawJSON['TYPE'] = rawType;
}
}
if (!$.isEmptyObject(rawJSON)) { templateJSON['RAW'] = rawJSON; };

View File

@ -21,8 +21,7 @@
<div >
<div class="medium-4 columns">
<label for="raw_type">{{tr "TYPE"}}</label>
<select id="raw_type" name="raw_type">
<option value=""></option>
<select id="raw_type" name="raw_type" disabled>
<option value="kvm">{{tr "kvm"}}</option>
</select>
</div>
@ -35,7 +34,7 @@
</div>
</div>
</fieldset>
<fieldset class="hypervisor only_kvm">
<fieldset class="hypervisor only_kvm vm_updateconf_hide">
<legend>{{tr "PCI Devices"}}</legend>
<div >
<div class="large-12 columns">
@ -64,7 +63,7 @@
</div>
</div>
</fieldset>
<fieldset>
<fieldset class="vm_updateconf_hide">
<legend>{{tr "Custom Tags"}}</legend>
{{{customTagsTableHTML}}}
</fieldset>

View File

@ -27,6 +27,7 @@ define(function(require) {
var TemplateUtils = require('utils/template-utils');
var HostsTable = require('tabs/hosts-tab/datatable');
var ClustersTable = require('tabs/clusters-tab/datatable');
var UniqueId = require('utils/unique-id');
/*
TEMPLATES
@ -49,7 +50,7 @@ define(function(require) {
throw "Wizard Tab not enabled";
}
this.wizardTabId = WIZARD_TAB_ID;
this.wizardTabId = WIZARD_TAB_ID + UniqueId.id();
this.icon = 'fa-sitemap';
this.title = Locale.tr("Scheduling");

View File

@ -25,6 +25,7 @@ define(function(require) {
var Tips = require('utils/tips');
var WizardFields = require('utils/wizard-fields');
var DiskTab = require('./storage/disk-tab');
var UniqueId = require('utils/unique-id');
/*
TEMPLATES
@ -49,7 +50,7 @@ define(function(require) {
throw "Wizard Tab not enabled";
}
this.wizardTabId = WIZARD_TAB_ID;
this.wizardTabId = WIZARD_TAB_ID + UniqueId.id();
this.icon = 'fa-tasks';
this.title = Locale.tr("Storage");
this.classes = "hypervisor only_kvm only_vcenter"

View File

@ -50,12 +50,14 @@ define(function(require) {
require('./vms-tab/panels/snapshots'),
require('./vms-tab/panels/placement'),
require('./vms-tab/panels/actions'),
require('./vms-tab/panels/conf'),
require('./vms-tab/panels/template'),
require('./vms-tab/panels/log')
];
var _formPanels = [
require('./vms-tab/form-panels/create')
require('./vms-tab/form-panels/create'),
require('./vms-tab/form-panels/updateconf')
]
var Tab = {

View File

@ -31,6 +31,7 @@ define(function(require) {
var VNC_DIALOG_ID = require('./dialogs/vnc/dialogId');
var SPICE_DIALOG_ID = require('./dialogs/spice/dialogId');
var SAVE_AS_TEMPLATE_DIALOG_ID = require('./dialogs/saveas-template/dialogId');
var UPDATECONF_FORM_ID = require('./form-panels/updateconf/formPanelId');
var XML_ROOT = "VM";
var RESOURCE = "VM";
@ -208,6 +209,24 @@ define(function(require) {
},
notify: false
},
"VM.updateconf": {
type: "single",
call: OpenNebulaVM.updateconf,
callback: function (req) {
Sunstone.resetFormPanel(TAB_ID, UPDATECONF_FORM_ID);
Sunstone.hideFormPanel(TAB_ID);
Sunstone.runAction("VM.refresh");
},
elements: function() {
return Sunstone.getDataTable(TAB_ID).elements();
},
error: function(request, response) {
Sunstone.hideFormPanelLoading(TAB_ID);
Notifier.onError(request, response);
},
notify: false
}
};
return _actions;

View File

@ -0,0 +1,157 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require) {
/*
DEPENDENCIES
*/
var BaseFormPanel = require('utils/form-panels/form-panel');
var Sunstone = require('sunstone');
var Locale = require('utils/locale');
var Tips = require('utils/tips');
var TemplateUtils = require('utils/template-utils');
/*
TEMPLATES
*/
var TemplateWizardHTML = require('hbs!./updateconf/wizard');
var TemplateAdvancedHTML = require('hbs!./updateconf/advanced');
/*
CONSTANTS
*/
var FORM_PANEL_ID = require('./updateconf/formPanelId');
var TAB_ID = require('../tabId');
var WIZARD_TABS = [
require('tabs/templates-tab/form-panels/create/wizard-tabs/os'),
require('tabs/templates-tab/form-panels/create/wizard-tabs/io'),
require('tabs/templates-tab/form-panels/create/wizard-tabs/context'),
require('tabs/templates-tab/form-panels/create/wizard-tabs/other')
]
/*
CONSTRUCTOR
*/
function FormPanel() {
this.formPanelId = FORM_PANEL_ID;
this.tabId = TAB_ID;
this.actions = {
'updateconf': {
'title': Locale.tr("Update VM Configuration"),
'buttonText': Locale.tr("Update"),
'resetButton': false
}
};
var that = this;
that.wizardTabs = [];
var wizardTabInstance;
$.each(WIZARD_TABS, function(index, wizardTab) {
try {
wizardTabInstance = new wizardTab();
wizardTabInstance.contentHTML = wizardTabInstance.html();
that.wizardTabs.push(wizardTabInstance);
} catch (err) {
console.log(err);
}
})
BaseFormPanel.call(this);
}
FormPanel.FORM_PANEL_ID = FORM_PANEL_ID;
FormPanel.prototype = Object.create(BaseFormPanel.prototype);
FormPanel.prototype.constructor = FormPanel;
FormPanel.prototype.htmlWizard = _htmlWizard;
FormPanel.prototype.htmlAdvanced = _htmlAdvanced;
FormPanel.prototype.setup = _setup;
FormPanel.prototype.onShow = _onShow;
FormPanel.prototype.submitWizard = _submitWizard;
FormPanel.prototype.submitAdvanced = _submitAdvanced;
FormPanel.prototype.fill = _fill;
return FormPanel;
/*
FUNCTION DEFINITIONS
*/
function _htmlWizard() {
return TemplateWizardHTML({
'formPanelId': this.formPanelId,
'wizardTabs': this.wizardTabs
});
}
function _htmlAdvanced() {
return TemplateAdvancedHTML({formPanelId: this.formPanelId});
}
function _setup(context) {
$.each(this.wizardTabs, function(index, wizardTab) {
wizardTab.setup($('#' + wizardTab.wizardTabId, context));
});
$(".vm_updateconf_hide", context).remove();
Foundation.reflow(context, 'tabs');
Foundation.reflow(context, 'tooltip');
}
function _onShow(context) {
var that = this;
$('a[href="#'+ that.wizardTabs[0].wizardTabId +'"]', context).trigger("click");
$.each(that.wizardTabs, function(index, wizardTab) {
wizardTab.onShow($('#' + wizardTab.wizardTabId, context), that);
});
}
function _submitWizard(context) {
var templateJSON = {}
$.each(this.wizardTabs, function(index, wizardTab) {
$.extend(true, templateJSON, wizardTab.retrieve($('#' + wizardTab.wizardTabId, context)));
});
Sunstone.runAction("VM.updateconf", this.resourceId, TemplateUtils.templateToString(templateJSON));
return false;
}
function _submitAdvanced(context) {
var template = $('textarea#template', context).val();
Sunstone.runAction("VM.updateconf", this.resourceId, template);
return false;
}
function _fill(context, elementId, templateJSON) {
this.resourceId = elementId;
// Populates the Avanced mode Tab
$('#template', context).val(
TemplateUtils.templateToString(templateJSON).replace(/^[\r\n]+$/g, ""));
$.each(this.wizardTabs, function(index, wizardTab) {
wizardTab.fill($('#' + wizardTab.wizardTabId, context), templateJSON);
});
}
});

View File

@ -0,0 +1,28 @@
{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2015, OpenNebula Project, OpenNebula Systems }}
{{! }}
{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }}
{{! not use this file except in compliance with the License. You may obtain }}
{{! a copy of the License at }}
{{! }}
{{! http://www.apache.org/licenses/LICENSE-2.0 }}
{{! }}
{{! Unless required by applicable law or agreed to in writing, software }}
{{! distributed under the License is distributed on an "AS IS" BASIS, }}
{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }}
{{! See the License for the specific language governing permissions and }}
{{! limitations under the License. }}
{{! -------------------------------------------------------------------------- }}
<form data-abide="ajax" id="{{formPanelId}}Advanced" class="custom creation">
<div class="row">
<div class="large-12 columns">
<p>{{tr "Write the Virtual Machine template here"}}</p>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<textarea id="template" rows="15" required></textarea>
</div>
</div>
</form>

View File

@ -0,0 +1,19 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require){
return 'updateConfForm';
})

View File

@ -0,0 +1,35 @@
{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2015, OpenNebula Project, OpenNebula Systems }}
{{! }}
{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }}
{{! not use this file except in compliance with the License. You may obtain }}
{{! a copy of the License at }}
{{! }}
{{! http://www.apache.org/licenses/LICENSE-2.0 }}
{{! }}
{{! Unless required by applicable law or agreed to in writing, software }}
{{! distributed under the License is distributed on an "AS IS" BASIS, }}
{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }}
{{! See the License for the specific language governing permissions and }}
{{! limitations under the License. }}
{{! -------------------------------------------------------------------------- }}
<form data-abide="ajax" id="{{formPanelId}}Wizard" class="custom creation">
<div class="bordered-tabs">
<dl id="{{formPanelId}}Tabs" class="tabs right-info-tabs" data-tabs>
{{#each wizardTabs}}
<dd class='tabs-title {{classes}}'>
<a href='#{{wizardTabId}}'> <i class='fa {{icon}}'></i>
<br>{{title}}</a>
</dd>
{{/each}}
</dl>
<div class="tabs-content" data-tabs-content="{{formPanelId}}Tabs">
{{#each wizardTabs}}
<div id="{{wizardTabId}}" class="wizard_tab tabs-panel">
{{{contentHTML}}}
</div>
{{/each}}
</div>
</div>
</form>

View File

@ -0,0 +1,108 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require) {
/*
DEPENDENCIES
*/
var Locale = require('utils/locale');
var Sunstone = require('sunstone');
var Config = require('sunstone-config');
var TemplateUtils = require('utils/template-utils');
var StateActions = require('../utils/state-actions');
/*
TEMPLATES
*/
var Template = require('hbs!./conf/html');
/*
CONSTANTS
*/
var TAB_ID = require('../tabId');
var PANEL_ID = require('./conf/panelId');
var RESOURCE = "VM";
var XML_ROOT = "VM";
var UPDATECONF_FORM_ID = require('../form-panels/updateconf/formPanelId');
/*
CONSTRUCTOR
*/
function Panel(info) {
this.panelId = PANEL_ID;
this.title = Locale.tr("Conf");
this.icon = "fa-cog";
this.element = info[XML_ROOT];
var conf = {};
var template = this.element.TEMPLATE;
$.each(["OS", "FEATURES", "INPUT", "GRAPHICS", "RAW", "CONTEXT"], function(){
if(template[this] != undefined){
conf[this] = template[this];
}
});
this.conf = conf;
return this;
};
Panel.PANEL_ID = PANEL_ID;
Panel.prototype.html = _html;
Panel.prototype.setup = _setup;
return Panel;
/*
FUNCTION DEFINITIONS
*/
function _html() {
return Template({
conf: this.conf
});
}
function _setup(context) {
var that = this;
if (Config.isTabActionEnabled("vms-tab", "VM.updateconf")) {
if (!StateActions.enabledStateAction("VM.updateconf", that.element.STATE, that.element.LCM_STATE)){
$('#vm_updateconf', context).attr("disabled", "disabled");
}
context.off('click', '#vm_updateconf');
context.on('click', '#vm_updateconf', function() {
Sunstone.resetFormPanel(TAB_ID, UPDATECONF_FORM_ID);
Sunstone.showFormPanel(TAB_ID, UPDATECONF_FORM_ID, "updateconf",
function(formPanelInstance, context) {
formPanelInstance.fill(context, that.element.ID, that.conf);
});
return false;
});
}
}
});

View File

@ -0,0 +1,48 @@
{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2015, OpenNebula Project, OpenNebula Systems }}
{{! }}
{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }}
{{! not use this file except in compliance with the License. You may obtain }}
{{! a copy of the License at }}
{{! }}
{{! http://www.apache.org/licenses/LICENSE-2.0 }}
{{! }}
{{! Unless required by applicable law or agreed to in writing, software }}
{{! distributed under the License is distributed on an "AS IS" BASIS, }}
{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }}
{{! See the License for the specific language governing permissions and }}
{{! limitations under the License. }}
{{! -------------------------------------------------------------------------- }}
<div class="row">
<div class="small-12 columns">
{{#isTabActionEnabled "vms-tab" "VM.updateconf"}}
<span class="right">
<button id="vm_updateconf" class="button success right radius">
{{tr "Update Configuration"}}
</button>
</span>
{{/isTabActionEnabled}}
</div>
</div>
<div class="row">
{{#each conf}}
<div class="medium-6 columns">
<table class="dataTable">
<thead>
<tr>
<th colspan="2">{{@key}}</th>
</tr>
</thead>
<tbody>
{{#each this}}
<tr>
<td class="key_td">{{@key}}</td>
<td class="value_td">{{this}}</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
{{/each}}
</div>

View File

@ -0,0 +1,19 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require){
return 'vm_conf_tab';
});

View File

@ -23,10 +23,10 @@ define(function(require) {
["VM.delete", "VM.delete_recreate", "VM.resize"];
STATE_ACTIONS[OpenNebulaVM.STATES.PENDING] =
["VM.delete", "VM.delete_recreate", "VM.hold", "VM.deploy"];
["VM.delete", "VM.delete_recreate", "VM.hold", "VM.deploy", "VM.updateconf"];
STATE_ACTIONS[OpenNebulaVM.STATES.HOLD] =
["VM.delete", "VM.delete_recreate", "VM.release", "VM.deploy"];
["VM.delete", "VM.delete_recreate", "VM.release", "VM.deploy", "VM.updateconf"];
STATE_ACTIONS[OpenNebulaVM.STATES.ACTIVE] =
["VM.delete", "VM.delete_recreate", "VM.recover"];
@ -44,20 +44,20 @@ define(function(require) {
["VM.delete", "VM.delete_recreate", "VM.resize"];
STATE_ACTIONS[OpenNebulaVM.STATES.POWEROFF] =
["VM.delete", "VM.resume", "VM.resize", "VM.attachdisk", "VM.detachdisk", "VM.attachnic", "VM.detachnic", "VM.disk_saveas", "VM.disk_snapshot_create", "VM.disk_snapshot_revert", "VM.disk_snapshot_delete", "VM.migrate", "VM.undeploy", "VM.undeploy_hard", "VM.shutdown_hard", "VM.saveas_template"];
["VM.delete", "VM.resume", "VM.resize", "VM.attachdisk", "VM.detachdisk", "VM.attachnic", "VM.detachnic", "VM.disk_saveas", "VM.disk_snapshot_create", "VM.disk_snapshot_revert", "VM.disk_snapshot_delete", "VM.migrate", "VM.undeploy", "VM.undeploy_hard", "VM.shutdown_hard", "VM.saveas_template", "VM.updateconf"];
STATE_ACTIONS[OpenNebulaVM.STATES.UNDEPLOYED] =
["VM.delete", "VM.delete_recreate", "VM.resume", "VM.resize", "VM.deploy"];
["VM.delete", "VM.delete_recreate", "VM.resume", "VM.resize", "VM.deploy", "VM.updateconf"];
STATE_ACTIONS[OpenNebulaVM.STATES.CLONING] =
["VM.delete", "VM.delete_recreate"];
["VM.delete", "VM.delete_recreate", "VM.updateconf"];
STATE_ACTIONS[OpenNebulaVM.STATES.CLONING_FAILURE] =
["VM.delete", "VM.delete_recreate", "VM.recover"];
["VM.delete", "VM.delete_recreate", "VM.recover", "VM.updateconf"];
var LCM_STATE_ACTIONS = {};
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.LCM_INIT ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.RUNNING ] =
["VM.shutdown", "VM.shutdown_hard", "VM.stop", "VM.suspend", "VM.reboot", "VM.reboot_hard", "VM.resched", "VM.unresched", "VM.poweroff", "VM.poweroff_hard", "VM.undeploy", "VM.undeploy_hard", "VM.migrate", "VM.migrate_live", "VM.attachdisk", "VM.detachdisk", "VM.attachnic", "VM.detachnic", "VM.disk_saveas", "VM.disk_snapshot_create", "VM.disk_snapshot_delete"];
@ -68,50 +68,50 @@ define(function(require) {
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_MIGRATE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_RESUME ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.EPILOG_STOP ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.EPILOG ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.SHUTDOWN ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.EPILOG ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.SHUTDOWN ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.CANCEL ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.CLEANUP_RESUBMIT ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.CLEANUP_RESUBMIT ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.UNKNOWN ] =
["VM.shutdown", "VM.shutdown_hard", "VM.resched", "VM.unresched", "VM.poweroff", "VM.poweroff_hard", "VM.undeploy", "VM.undeploy_hard", "VM.migrate", "VM.migrate_live", "VM.resume"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.SHUTDOWN_POWEROFF ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.SHUTDOWN_POWEROFF ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT_UNKNOWN ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT_POWEROFF ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT_SUSPENDED ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT_STOPPED ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.CLEANUP_DELETE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.CLEANUP_DELETE ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_SNAPSHOT ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_NIC ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_SAVEAS ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_SAVEAS_POWEROFF ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_SAVEAS_POWEROFF ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_SAVEAS_SUSPENDED ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.SHUTDOWN_UNDEPLOY ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.EPILOG_UNDEPLOY ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_UNDEPLOY ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.SHUTDOWN_UNDEPLOY ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.EPILOG_UNDEPLOY ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_UNDEPLOY ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT_UNDEPLOY ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_PROLOG_POWEROFF ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_EPILOG_POWEROFF ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_PROLOG_POWEROFF ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG_EPILOG_POWEROFF ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT_MIGRATE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT_FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT_FAILURE ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT_MIGRATE_FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_MIGRATE_FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.EPILOG_FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_FAILURE ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.EPILOG_FAILURE ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.EPILOG_STOP_FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.EPILOG_UNDEPLOY_FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_MIGRATE_POWEROFF ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_MIGRATE_POWEROFF_FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.EPILOG_UNDEPLOY_FAILURE ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_MIGRATE_POWEROFF ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_MIGRATE_POWEROFF_FAILURE ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_MIGRATE_SUSPEND ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_MIGRATE_SUSPEND_FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT_UNDEPLOY_FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT_UNDEPLOY_FAILURE ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT_STOPPED_FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_RESUME_FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_UNDEPLOY_FAILURE ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.DISK_SNAPSHOT_POWEROFF ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.DISK_SNAPSHOT_REVERT_POWEROFF ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.DISK_SNAPSHOT_DELETE_POWEROFF ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG_UNDEPLOY_FAILURE ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.DISK_SNAPSHOT_POWEROFF ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.DISK_SNAPSHOT_REVERT_POWEROFF ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.DISK_SNAPSHOT_DELETE_POWEROFF ] = ["VM.updateconf"];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.DISK_SNAPSHOT_SUSPENDED ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.DISK_SNAPSHOT_REVERT_SUSPENDED ] = [];
LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.DISK_SNAPSHOT_DELETE_SUSPENDED ] = [];

View File

@ -21,7 +21,7 @@ define(function(require) {
//Escape doublequote in a string and return it
function _escapeDoubleQuotes(string) {
if (string != undefined) {
if (string != undefined && typeof(string) == "string") {
return string.replace(/\\/g, '\\').replace(/"/g, '\\"');
} else {
return string;

View File

@ -0,0 +1,34 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require) {
var number = 0;
/**
* Returns a unique ID, sunstone<number>
* @return {string} a unique ID
*/
function _id() {
number += 1;
return "one"+number;
}
return {
'id': _id
};
});