From 8326b7672ae092c80eaaf5f75a7e7a6132f28a61 Mon Sep 17 00:00:00 2001 From: Krzysztof Warzecha Date: Thu, 29 May 2014 23:57:41 +0200 Subject: [PATCH 1/2] vsphere_guest: Add support for setting hardware version (should fix #7206) --- library/cloud/vsphere_guest | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/library/cloud/vsphere_guest b/library/cloud/vsphere_guest index 2a02b933b20..13b55e0ad60 100644 --- a/library/cloud/vsphere_guest +++ b/library/cloud/vsphere_guest @@ -88,6 +88,11 @@ options: - A key, value pair of any extra values you want set or changed in the vmx file of the VM. Useful to set advanced options on the VM. required: false default: null + vm_hw_version: + description: + - Desired hardware version identifier (for example, "vmx-08" for vms that needs to be managed with vSphere Client). Note that changing hardware version of existing vm is not supported. + required: false + default: null vmware_guest_facts: description: - Gather facts from vCenter on a particular VM @@ -593,7 +598,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name module.exit_json(changed=False) -def create_vm(vsphere_client, module, esxi, resource_pool, cluster_name, guest, vm_extra_config, vm_hardware, vm_disk, vm_nic, state): +def create_vm(vsphere_client, module, esxi, resource_pool, cluster_name, guest, vm_extra_config, vm_hardware, vm_disk, vm_nic, vm_hw_version, state): datacenter = esxi['datacenter'] esxi_hostname = esxi['hostname'] @@ -696,6 +701,8 @@ def create_vm(vsphere_client, module, esxi, resource_pool, cluster_name, guest, # add parameters to the create vm task create_vm_request = VI.CreateVM_TaskRequestMsg() config = create_vm_request.new_config() + if vm_hw_version: + config.set_element_version(vm_hw_version) vmfiles = config.new_files() datastore_name, ds = find_datastore( module, vsphere_client, vm_disk['disk1']['datastore'], config_target) @@ -1063,6 +1070,7 @@ def main(): vm_nic=dict(required=False, type='dict', default={}), vm_hardware=dict(required=False, type='dict', default={}), vm_extra_config=dict(required=False, type='dict', default={}), + vm_hw_version=dict(required=False, default=None, type='str'), resource_pool=dict(required=False, default=None, type='str'), cluster=dict(required=False, default=None, type='str'), force=dict(required=False, choices=BOOLEANS, default=False), @@ -1099,6 +1107,7 @@ def main(): vm_nic = module.params['vm_nic'] vm_hardware = module.params['vm_hardware'] vm_extra_config = module.params['vm_extra_config'] + vm_hw_version = module.params['vm_hw_version'] esxi = module.params['esxi'] resource_pool = module.params['resource_pool'] cluster = module.params['cluster'] @@ -1200,6 +1209,7 @@ def main(): vm_hardware=vm_hardware, vm_disk=vm_disk, vm_nic=vm_nic, + vm_hw_version=vm_hw_version, state=state ) From 3e7d91723f0a5e6e760c321fc9c142f5dac974ea Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 10 Jul 2014 08:53:56 -0500 Subject: [PATCH 2/2] Adding version_added for new vm_hw_version field in vpshere_guest --- library/cloud/vsphere_guest | 1 + 1 file changed, 1 insertion(+) diff --git a/library/cloud/vsphere_guest b/library/cloud/vsphere_guest index 333e277531e..a16f3441cf6 100644 --- a/library/cloud/vsphere_guest +++ b/library/cloud/vsphere_guest @@ -93,6 +93,7 @@ options: - Desired hardware version identifier (for example, "vmx-08" for vms that needs to be managed with vSphere Client). Note that changing hardware version of existing vm is not supported. required: false default: null + version_added: "1.7" vmware_guest_facts: description: - Gather facts from vCenter on a particular VM