diff --git a/src/sunstone/etc/sunstone-views/cloud.yaml b/src/sunstone/etc/sunstone-views/cloud.yaml index 68c83cbe2e..6eff081693 100644 --- a/src/sunstone/etc/sunstone-views/cloud.yaml +++ b/src/sunstone/etc/sunstone-views/cloud.yaml @@ -78,6 +78,8 @@ tabs: capacity_select: true # True to allow NIC customization network_select: true + # True to allow vmgroup customization + vmgroup_select: true # True to allow DISK size customization disk_resize: true settings-tab: @@ -135,4 +137,13 @@ tabs: - 2 # Owner #- 3 # Group - 4 # Name - #- 5 # Labels \ No newline at end of file + #- 5 # Labels + vmgroup-tab: + table_columns: + - 0 # Checkbox + - 1 # ID + - 2 # Owner + - 3 # Group + - 4 # Name + #- 5 # Labels + #- 6 # Search data \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/provision-tab.js b/src/sunstone/public/app/tabs/provision-tab.js index 4b5d979edc..df3f06adfb 100644 --- a/src/sunstone/public/app/tabs/provision-tab.js +++ b/src/sunstone/public/app/tabs/provision-tab.js @@ -34,6 +34,7 @@ define(function(require) { var RangeSlider = require('utils/range-slider'); var DisksResize = require('utils/disks-resize'); var NicsSection = require('utils/nics-section'); + var VMGroupSection = require('utils/vmgroup-section'); var TemplateUtils = require('utils/template-utils'); var WizardFields = require('utils/wizard-fields'); var UserInputs = require('utils/user-inputs'); @@ -927,6 +928,7 @@ define(function(require) { $(".provision_accordion_template a").first().trigger("click"); + $("#provision_create_vm .provision_vmgroup").show(); OpenNebula.Template.show({ data : { id: template_id, @@ -959,6 +961,12 @@ define(function(require) { $(".provision_network_selector", create_vm_context).html(""); } + if (Config.provision.create_vm.isEnabled("vmgroup_select")) { + VMGroupSection.insert(template_json, $(".vmgroupContext", create_vm_context)); + } else { + $(".provision_vmgroup_selector", create_vm_context).html(""); + } + if (template_json.VMTEMPLATE.TEMPLATE.USER_INPUTS) { UserInputs.vmTemplateInsert( $(".provision_custom_attributes_selector", create_vm_context), @@ -1009,6 +1017,12 @@ define(function(require) { } } + var vmgroup = VMGroupSection.retrieve($(".vmgroupContext"+ template_id)); + + if(vmgroup){ + $.extend(extra_info.template, vmgroup); + } + if (nics.length > 0) { extra_info.template.nic = nics; } diff --git a/src/sunstone/public/app/tabs/provision-tab/vms/create.hbs b/src/sunstone/public/app/tabs/provision-tab/vms/create.hbs index 015948b341..8010346002 100644 --- a/src/sunstone/public/app/tabs/provision-tab/vms/create.hbs +++ b/src/sunstone/public/app/tabs/provision-tab/vms/create.hbs @@ -123,4 +123,20 @@
+ \ No newline at end of file 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 790e845c63..4945e55170 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 @@ -178,7 +178,12 @@ define(function(require) { function _retrieve(context) { var templateJSON = WizardFields.retrieve(context); - templateJSON["DISK_COST"] = templateJSON["DISK_COST"] * 1024; + if(templateJSON["DISK_COST"]){ + templateJSON["DISK_COST"] = templateJSON["DISK_COST"] * 1024; + } + else{ + templateJSON["DISK_COST"] = "0"; + } if(templateJSON["MEMORY_UNIT_COST"] == "GB") templateJSON["MEMORY_COST"] = templateJSON["MEMORY_COST"] * 1024; if (templateJSON["HYPERVISOR"] == 'vcenter') { diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage/disk-tab.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage/disk-tab.js index 2dd40b45c8..45a0f0f164 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage/disk-tab.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/storage/disk-tab.js @@ -146,7 +146,12 @@ define(function(require) { } var tmpl = WizardFields.retrieve(selectedContext); - tmpl["SIZE"] = tmpl["SIZE"] * 1024; + if(tmpl["SIZE"]){ + tmpl["SIZE"] = tmpl["SIZE"] * 1024; + } + else{ + return {}; + } var dev_prefix = WizardFields.retrieveInput($('#disk_dev_prefix', selectedContext)); if (dev_prefix != undefined && dev_prefix.length) { if (dev_prefix == "custom") { diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/vmgroup.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/vmgroup.js index c5c54ff52d..52eff5e351 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/vmgroup.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/vmgroup.js @@ -80,7 +80,7 @@ define(function(require) { } function _retrieve(context) { - return vmgroupSection.retrieve(context); + return vmgroupSection.retrieve(context, this.vmGroupTable); } function _fill(context, templateJSON) { diff --git a/src/sunstone/public/app/utils/vmgroup-section.js b/src/sunstone/public/app/utils/vmgroup-section.js index 31336e0fd2..81e3cdcd8c 100644 --- a/src/sunstone/public/app/utils/vmgroup-section.js +++ b/src/sunstone/public/app/utils/vmgroup-section.js @@ -66,6 +66,7 @@ define(function(require) { function _insert(template_json, context) { var templateVmgroup = null; + var that = this; this.vmGroupTable = new VMGroupsTable('vmgroups_table'+UniqueId.id(), { 'select': true }); var that = this; var templateVmgroup = $(TemplateSection({ @@ -92,19 +93,25 @@ define(function(require) { }); $("#role_section",context).hide(); $(".role_table_section", context).prop('required', false); + if(template_json.VMTEMPLATE.TEMPLATE.VMGROUP){ + this.vmGroupTable.selectResourceTableSelect({ids:template_json.VMTEMPLATE.TEMPLATE.VMGROUP.VMGROUP_ID}); + _generate_provision_role_table(context, template_json.VMTEMPLATE.TEMPLATE.VMGROUP.VMGROUP_ID, template_json.VMTEMPLATE.TEMPLATE.VMGROUP.ROLE); + } } function _fill(context, templateJSON, vmGroupTable=undefined){ - var element = templateJSON.VMGROUP; - vmGroupTable.selectResourceTableSelect({ids:element.VMGROUP_ID}); - _generate_provision_role_table(context,element.VMGROUP_ID, element.ROLE); + if(templateJSON.VMGROUP){ + var element = templateJSON.VMGROUP; + vmGroupTable.selectResourceTableSelect({ids:element.VMGROUP_ID}); + _generate_provision_role_table(context,element.VMGROUP_ID, element.ROLE); + } } function _retrieve(context, vmGroupTable=undefined) { - var role_selected = $('.role_table_section').val(); + var role_selected = $('.role_table_section', context).val(); var vmgroup_selected = undefined; if(this.vmGroupTable) - this.vmGroupTable.retrieveResourceTableSelect(); + vmgroup_selected = this.vmGroupTable.retrieveResourceTableSelect(); if(vmGroupTable) vmgroup_selected = vmGroupTable.retrieveResourceTableSelect(); if(vmgroup_selected){