diff --git a/share/doc/xsd/oned.conf b/share/doc/xsd/oned.conf index 9cca915fa5..0468f6abe5 100644 --- a/share/doc/xsd/oned.conf +++ b/share/doc/xsd/oned.conf @@ -770,7 +770,7 @@ VM_RESTRICTED_ATTR = "MEMORY_COST" VM_RESTRICTED_ATTR = "DISK_COST" VM_RESTRICTED_ATTR = "PCI" VM_RESTRICTED_ATTR = "USER_INPUTS" -VM_RESTRICTED_ATTR = "DEPLOY_FOLDER" +VM_RESTRICTED_ATTR = "VCENTER_VM_FOLDER" #VM_RESTRICTED_ATTR = "RANK" #VM_RESTRICTED_ATTR = "SCHED_RANK" diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 3acb7ce904..47f75fd2d1 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -248,10 +248,10 @@ VXLAN_IDS = [ # DEFAULT_CDROM_DEVICE_PREFIX: Same as above but for CDROM devices. # # DEFAULT_IMAGE_PERSISTENT: Control the default value for the PERSISTENT -# attribute on image creation (oneimage clone, onevm disk-saveas). If blank +# attribute on image creation (oneimage clone, onevm disk-saveas). If blank # images will inherit the persistent attribute from the base image. # -# DEFAULT_IMAGE_PERSISTENT_NEW: Control the default value for the PERSISTENT +# DEFAULT_IMAGE_PERSISTENT_NEW: Control the default value for the PERSISTENT # attribute on image creation (oneimage create). By default images are no # persistent if not set. #******************************************************************************* @@ -814,8 +814,8 @@ DEFAULT_UMASK = 177 VM_ADMIN_OPERATIONS = "migrate, delete, recover, retry, deploy, resched" -VM_MANAGE_OPERATIONS = "undeploy, hold, release, stop, suspend, resume, reboot, - poweroff, disk-attach, nic-attach, disk-snapshot, terminate, disk-resize, +VM_MANAGE_OPERATIONS = "undeploy, hold, release, stop, suspend, resume, reboot, + poweroff, disk-attach, nic-attach, disk-snapshot, terminate, disk-resize, snapshot, updateconf, rename, resize, update, disk-saveas" VM_USE_OPERATIONS = "" @@ -856,7 +856,7 @@ VM_RESTRICTED_ATTR = "EMULATOR" VM_RESTRICTED_ATTR = "USER_INPUTS/CPU" VM_RESTRICTED_ATTR = "USER_INPUTS/MEMORY" VM_RESTRICTED_ATTR = "USER_INPUTS/VCPU" -VM_RESTRICTED_ATTR = "DEPLOY_FOLDER" +VM_RESTRICTED_ATTR = "VCENTER_VM_FOLDER" #VM_RESTRICTED_ATTR = "RANK" #VM_RESTRICTED_ATTR = "SCHED_RANK" diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index 86d60f897f..c0e118f7c0 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -354,11 +354,11 @@ EOT :description => 'Sends READY=YES to OneGate, useful for OneFlow' }, { - :name => 'deploy_folder', - :large => '--deploy_folder path', + :name => 'vcenter_vm_folder', + :large => '--vcenter_vm_folder path', :format => String, :description => "In a vCenter environment sets the the VMs and Template folder where the VM will be placed in." \ - " The path uses slashes to separate folders. For example: --deploy_folder \"/Management/VMs\"" + " The path uses slashes to separate folders. For example: --vcenter_vm_folder \"/Management/VMs\"" } ] @@ -1133,7 +1133,7 @@ EOT template<<' ]' << "\n" end - template<<"DEPLOY_FOLDER=#{options[:deploy_folder]}\n" if options[:deploy_folder] + template<<"VCENTER_VM_FOLDER=#{options[:vcenter_vm_folder]}\n" if options[:vcenter_vm_folder] context=create_context(options) template< -
+
-
diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js index b118a3c556..8001dd35ec 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js @@ -32,7 +32,7 @@ define(function(require) { var DisksResize = require('utils/disks-resize'); var NicsSection = require('utils/nics-section'); var VMGroupSection = require('utils/vmgroup-section'); - var DeployFolder = require('utils/deploy-folder'); + var VcenterVMFolder = require('utils/vcenter-vm-folder'); var CapacityInputs = require('tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs'); var Config = require('sunstone-config'); @@ -214,10 +214,10 @@ define(function(require) { tmp_json.PCI = pcis; } - if (Config.isFeatureEnabled("vcenter_deploy_folder")){ + if (Config.isFeatureEnabled("vcenter_vm_folder")){ if(!$.isEmptyObject(original_tmpl.TEMPLATE.HYPERVISOR) && original_tmpl.TEMPLATE.HYPERVISOR === 'vcenter'){ - $.extend(tmp_json, DeployFolder.retrieveChanges($(".deployFolderContext" + template_id))); + $.extend(tmp_json, VcenterVMFolder.retrieveChanges($(".vcenterVMFolderContext" + template_id))); } } @@ -279,9 +279,9 @@ define(function(require) { VMGroupSection.insert(template_json, $(".vmgroupContext"+ template_json.VMTEMPLATE.ID, context)); - deployFolderContext = $(".deployFolderContext" + template_json.VMTEMPLATE.ID, context); - DeployFolder.setup(deployFolderContext); - DeployFolder.fill(deployFolderContext, template_json.VMTEMPLATE); + vcenterVMFolderContext = $(".vcenterVMFolderContext" + template_json.VMTEMPLATE.ID, context); + VcenterVMFolder.setup(vcenterVMFolderContext); + VcenterVMFolder.fill(vcenterVMFolderContext, template_json.VMTEMPLATE); var inputs_div = $(".template_user_inputs" + template_json.VMTEMPLATE.ID, context); diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/templateRow.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/templateRow.hbs index cd2aaf2159..4e642263d5 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/templateRow.hbs +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/templateRow.hbs @@ -68,8 +68,8 @@
-
-
+
+
diff --git a/src/sunstone/public/app/utils/deploy-folder.js b/src/sunstone/public/app/utils/deploy-folder.js deleted file mode 100644 index 2497985ae2..0000000000 --- a/src/sunstone/public/app/utils/deploy-folder.js +++ /dev/null @@ -1,74 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* Copyright 2002-2016, 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 Locale = require('utils/locale'); - var Config = require('sunstone-config'); - var OpenNebula = require('opennebula'); - var OpenNebulaImage = require('opennebula/image'); - var UserInputs = require('utils/user-inputs'); - var WizardFields = require('utils/wizard-fields'); - var DeployFolderTemplate = require('hbs!./deploy-folder/html'); - - return { - 'setup': _setup, - 'fill': _fill, - 'retrieveChanges': _retrieveChanges - }; - - function _setup(context) { - if (!Config.isFeatureEnabled("vcenter_deploy_folder")){ - $(context).remove(); - } - } - - function _fill(context, element) { - - if (Config.isFeatureEnabled("vcenter_deploy_folder")){ - var deployFolderContext = context; - var template_public_cloud_type = element.TEMPLATE.HYPERVISOR - - if ($.isEmptyObject(template_public_cloud_type)) { - deployFolderContext.html(""); - } else { - if (template_public_cloud_type === 'vcenter') { - var deploy_folder = element.TEMPLATE.DEPLOY_FOLDER - deployFolderContext.html(DeployFolderTemplate()); - $("#deploy_folder_input", deployFolderContext).val(deploy_folder); - $("#deploy_folder_input", deployFolderContext).data("original_value",deploy_folder); - } else { - deployFolderContext.html(""); - } - } - } - } - - - function _retrieveChanges(context) { - - var templateJSON = WizardFields.retrieve(context); - var fields = $('[wizard_field]', context); - - fields.each(function() { - var field_name = $(this).attr('wizard_field'); - if (templateJSON[field_name] == $(this).data("original_value")){ - delete templateJSON[field_name]; - } - }); - - return templateJSON; - } -}); \ No newline at end of file diff --git a/src/sunstone/public/app/utils/deploy-folder/html.hbs b/src/sunstone/public/app/utils/deploy-folder/html.hbs deleted file mode 100644 index 9bb686bb7e..0000000000 --- a/src/sunstone/public/app/utils/deploy-folder/html.hbs +++ /dev/null @@ -1,29 +0,0 @@ -{{! -------------------------------------------------------------------------- }} -{{! Copyright 2002-2016, 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 "vCenter Deployment"}} - -
- - -
-
- diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb b/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb index 193eb7f63c..694b495cc7 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb @@ -330,11 +330,24 @@ class VirtualMachine clone_spec = RbVmomi::VIM.VirtualMachineCloneSpec(spec_hash) + # Specify vm folder in vSpere's VM and Templates view F#4823 + vcenter_vm_folder = nil + vcenter_vm_folder = one_item["USER_TEMPLATE/VCENTER_VM_FOLDER"] + vcenter_vm_folder_object = nil + + dc = cluster.get_dc + if !!vcenter_vm_folder && !vcenter_vm_folder.empty? + # Look for folder object + vcenter_vm_folder_object = dc.item.find_folder(vcenter_vm_folder) + end + + vm_folder = vc_template.parent if vcenter_vm_folder_object.nil? + if ds.instance_of? RbVmomi::VIM::StoragePod # VM is cloned using Storage Resource Manager for StoragePods begin vm = storagepod_clonevm_task(vc_template, vcenter_name, - clone_spec, ds) + clone_spec, ds, vcenter_vm_folder_object) rescue Exception => e raise "Cannot clone VM Template to StoragePod: #{e.message}" end @@ -342,7 +355,7 @@ class VirtualMachine vm = nil begin vm = vc_template.CloneVM_Task( - :folder => vc_template.parent, + :folder => vcenter_vm_folder_object, :name => vcenter_name, :spec => clone_spec).wait_for_completion rescue Exception => e @@ -350,7 +363,7 @@ class VirtualMachine raise "Cannot clone VM Template: #{e.message}\n#{e.backtrace}" end - vm_folder = cluster.get_dc.vm_folder + vm_folder = dc.vm_folder vm_folder.fetch! vm = vm_folder.items .select{|k,v| v.item.name == vcenter_name} @@ -359,7 +372,7 @@ class VirtualMachine if vm vm.Destroy_Task.wait_for_completion vm = vc_template.CloneVM_Task( - :folder => vc_template.parent, + :folder => vcenter_vm_folder_object, :name => vcenter_name, :spec => clone_spec).wait_for_completion else @@ -374,7 +387,7 @@ class VirtualMachine end - def storagepod_clonevm_task(vc_template, vcenter_name, clone_spec, storpod) + def storagepod_clonevm_task(vc_template, vcenter_name, clone_spec, storpod, vcenter_vm_folder_object) storage_manager = vc_template ._connection.serviceContent.storageResourceManager @@ -382,7 +395,7 @@ class VirtualMachine storage_spec = RbVmomi::VIM.StoragePlacementSpec( type: 'clone', cloneName: vcenter_name, - folder: vc_template.parent, + folder: vcenter_vm_folder_object, podSelectionSpec: RbVmomi::VIM.StorageDrsPodSelectionSpec(storagePod: storpod), vm: vc_template, cloneSpec: clone_spec