From 8a21fa2c0795b063d997f2dd9dff1b167d507792 Mon Sep 17 00:00:00 2001 From: Dario Zanzico Date: Fri, 10 Nov 2017 14:09:30 +0100 Subject: [PATCH] remove cpuHotAddEnabled, memoryHotAddEnabled defaults from configSpec (#25202) * add hardware.hotadd_cpu, hardware.hotadd_memory parameters * use hotadd_{cpu,memory} paramters on create integration tests --- lib/ansible/modules/cloud/vmware/vmware_guest.py | 14 +++++++++++++- .../targets/vmware_guest/tasks/create_d1_c1_f0.yml | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index 1df2f85393d..e308a132841 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -82,6 +82,8 @@ options: description: - Manage some VM hardware attributes. - 'Valid attributes are:' + - ' - C(hotadd_cpu) (boolean): Allow cpus to be added while the VM is running.' + - ' - C(hotadd_memory) (boolean): Allow memory to be added while the VM is running.' - ' - C(memory_mb) (integer): Amount of memory in MB.' - ' - C(num_cpus) (integer): Number of CPUs.' - ' - C(scsi) (string): Valid values are C(buslogic), C(lsilogic), C(lsilogicsas) and C(paravirtual) (default).' @@ -605,6 +607,16 @@ class PyVmomiHelper(PyVmomi): elif vm_creation and not self.params['template']: self.module.fail_json(msg="hardware.memory_mb attribute is mandatory for VM creation") + if 'hotadd_memory' in self.params['hardware']: + self.configspec.memoryHotAddEnabled = bool(self.params['hardware']['hotadd_memory']) + if vm_obj is None or self.configspec.memoryHotAddEnabled != vm_obj.config.memoryHotAddEnabled: + self.change_detected = True + + if 'hotadd_cpu' in self.params['hardware']: + self.configspec.cpuHotAddEnabled = bool(self.params['hardware']['hotadd_cpu']) + if vm_obj is None or self.configspec.cpuHotAddEnabled != vm_obj.config.cpuHotAddEnabled: + self.change_detected = True + def configure_cdrom(self, vm_obj): # Configure the VM CD-ROM if "cdrom" in self.params and self.params["cdrom"]: @@ -1274,7 +1286,7 @@ class PyVmomiHelper(PyVmomi): # set the destination datastore for VM & disks (datastore, datastore_name) = self.select_datastore(vm_obj) - self.configspec = vim.vm.ConfigSpec(cpuHotAddEnabled=True, memoryHotAddEnabled=True) + self.configspec = vim.vm.ConfigSpec() self.configspec.deviceChange = [] self.configure_guestid(vm_obj=vm_obj, vm_creation=True) self.configure_cpu_and_memory(vm_obj=vm_obj, vm_creation=True) diff --git a/test/integration/targets/vmware_guest/tasks/create_d1_c1_f0.yml b/test/integration/targets/vmware_guest/tasks/create_d1_c1_f0.yml index 02146c49f6c..26d36ac786d 100644 --- a/test/integration/targets/vmware_guest/tasks/create_d1_c1_f0.yml +++ b/test/integration/targets/vmware_guest/tasks/create_d1_c1_f0.yml @@ -72,6 +72,8 @@ hardware: num_cpus: 1 memory_mb: 512 + hotadd_memory: true + hotadd_cpu: false disk: - size: 0gb type: thin