diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index 6998277548..56d3137ea8 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -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 diff --git a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml index cd9e81f03d..be109db7a1 100644 --- a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml @@ -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 diff --git a/src/sunstone/etc/sunstone-views/groupadmin.yaml b/src/sunstone/etc/sunstone-views/groupadmin.yaml index 1b841f24a0..a9f0842525 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin.yaml @@ -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 diff --git a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml index 2179a918a5..3fa9259f50 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml @@ -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 diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 2b87cf26cb..9436ff7597 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -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 diff --git a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb index b76067e2a0..675319e00f 100644 --- a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb @@ -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 diff --git a/src/sunstone/public/app/opennebula/vm.js b/src/sunstone/public/app/opennebula/vm.js index aa0a71979a..6a25f35431 100644 --- a/src/sunstone/public/app/opennebula/vm.js +++ b/src/sunstone/public/app/opennebula/vm.js @@ -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); }, diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context.js index a6b0233d72..d47b5d6c1a 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context.js @@ -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, diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context/html.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context/html.hbs index cacdbe558a..7e54e8e0aa 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context/html.hbs +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context/html.hbs @@ -99,19 +99,17 @@ -
-
-
-
- - {{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")}}} - -
-
{{{userInputsHTML}}}
-
-
-
+
+
+
+ + {{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")}}} + +
+
{{{userInputsHTML}}}
+
+
diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js index 278bd4637b..3e7082878f 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js @@ -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"); } diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/hybrid.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/hybrid.js index 257e01019d..3ce9940d41 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/hybrid.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/hybrid.js @@ -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"); } diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io.js index 32c3b58df7..ba1a70c728 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io.js @@ -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"); } diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io/html.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io/html.hbs index 94135b78e3..c96b8bb902 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io/html.hbs +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io/html.hbs @@ -27,7 +27,7 @@ - +

diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network.js index 84d1ec9242..180915779e 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/network.js @@ -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" diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/os.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/os.js index 824bb74bd4..fd7d0c205c 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/os.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/os.js @@ -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']) { diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other.js index af4f4c1452..bb98ead3ae 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other.js @@ -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; }; diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other/html.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other/html.hbs index b654d8863f..f658477f7e 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other/html.hbs +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other/html.hbs @@ -21,8 +21,7 @@
-
@@ -35,7 +34,7 @@
-
+
{{tr "PCI Devices"}}
@@ -64,7 +63,7 @@
-
+
{{tr "Custom Tags"}} {{{customTagsTableHTML}}}
diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/scheduling.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/scheduling.js index 8806427195..1e5625fce1 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/scheduling.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/scheduling.js @@ -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"); diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage.js index 04e5af34f2..7bd07255e7 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage.js @@ -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" diff --git a/src/sunstone/public/app/tabs/vms-tab.js b/src/sunstone/public/app/tabs/vms-tab.js index 60e8f16fe6..f413cb4a25 100644 --- a/src/sunstone/public/app/tabs/vms-tab.js +++ b/src/sunstone/public/app/tabs/vms-tab.js @@ -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 = { diff --git a/src/sunstone/public/app/tabs/vms-tab/actions.js b/src/sunstone/public/app/tabs/vms-tab/actions.js index 5d39d102e9..b3d616e163 100644 --- a/src/sunstone/public/app/tabs/vms-tab/actions.js +++ b/src/sunstone/public/app/tabs/vms-tab/actions.js @@ -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; diff --git a/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf.js b/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf.js new file mode 100644 index 0000000000..d993d604b0 --- /dev/null +++ b/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf.js @@ -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); + }); + } +}); diff --git a/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf/advanced.hbs b/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf/advanced.hbs new file mode 100644 index 0000000000..a6612db419 --- /dev/null +++ b/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf/advanced.hbs @@ -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. }} +{{! -------------------------------------------------------------------------- }} + +
+
+
+

{{tr "Write the Virtual Machine template here"}}

+
+
+
+
+ +
+
+
diff --git a/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf/formPanelId.js b/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf/formPanelId.js new file mode 100644 index 0000000000..3125719f74 --- /dev/null +++ b/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf/formPanelId.js @@ -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'; +}) diff --git a/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf/wizard.hbs b/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf/wizard.hbs new file mode 100644 index 0000000000..927586a555 --- /dev/null +++ b/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf/wizard.hbs @@ -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. }} +{{! -------------------------------------------------------------------------- }} + +
+
+
+ {{#each wizardTabs}} +
+ +
{{title}}
+
+ {{/each}} +
+
+ {{#each wizardTabs}} +
+ {{{contentHTML}}} +
+ {{/each}} +
+
+
diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/conf.js b/src/sunstone/public/app/tabs/vms-tab/panels/conf.js new file mode 100644 index 0000000000..276e228801 --- /dev/null +++ b/src/sunstone/public/app/tabs/vms-tab/panels/conf.js @@ -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; + }); + } + + } +}); diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/conf/html.hbs b/src/sunstone/public/app/tabs/vms-tab/panels/conf/html.hbs new file mode 100644 index 0000000000..2281a7e250 --- /dev/null +++ b/src/sunstone/public/app/tabs/vms-tab/panels/conf/html.hbs @@ -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. }} +{{! -------------------------------------------------------------------------- }} + +
+
+ {{#isTabActionEnabled "vms-tab" "VM.updateconf"}} + + + + {{/isTabActionEnabled}} +
+
+
+ {{#each conf}} +
+ + + + + + + + {{#each this}} + + + + + {{/each}} + +
{{@key}}
{{@key}}{{this}}
+
+ {{/each}} +
\ No newline at end of file diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/conf/panelId.js b/src/sunstone/public/app/tabs/vms-tab/panels/conf/panelId.js new file mode 100644 index 0000000000..5ade4fcafc --- /dev/null +++ b/src/sunstone/public/app/tabs/vms-tab/panels/conf/panelId.js @@ -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'; +}); diff --git a/src/sunstone/public/app/tabs/vms-tab/utils/state-actions.js b/src/sunstone/public/app/tabs/vms-tab/utils/state-actions.js index a5feaea69b..a0ca783ac1 100644 --- a/src/sunstone/public/app/tabs/vms-tab/utils/state-actions.js +++ b/src/sunstone/public/app/tabs/vms-tab/utils/state-actions.js @@ -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 ] = []; diff --git a/src/sunstone/public/app/utils/template-utils.js b/src/sunstone/public/app/utils/template-utils.js index 948e5ae734..e66ecde4b1 100644 --- a/src/sunstone/public/app/utils/template-utils.js +++ b/src/sunstone/public/app/utils/template-utils.js @@ -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; diff --git a/src/sunstone/public/app/utils/unique-id.js b/src/sunstone/public/app/utils/unique-id.js new file mode 100644 index 0000000000..e2fd1c15ff --- /dev/null +++ b/src/sunstone/public/app/utils/unique-id.js @@ -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 + * @return {string} a unique ID + */ + function _id() { + number += 1; + return "one"+number; + } + + return { + 'id': _id + }; +}); +