|
|
@ -716,8 +716,9 @@ class PyVmomiHelper(PyVmomi):
|
|
|
|
:param vm_obj: VM object in case of reconfigure, None in case of deploy
|
|
|
|
:param vm_obj: VM object in case of reconfigure, None in case of deploy
|
|
|
|
:return: None
|
|
|
|
:return: None
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self.configspec.memoryAllocation = vim.ResourceAllocationInfo()
|
|
|
|
rai_change_detected = False
|
|
|
|
self.configspec.cpuAllocation = vim.ResourceAllocationInfo()
|
|
|
|
memory_allocation = vim.ResourceAllocationInfo()
|
|
|
|
|
|
|
|
cpu_allocation = vim.ResourceAllocationInfo()
|
|
|
|
|
|
|
|
|
|
|
|
if 'hardware' in self.params:
|
|
|
|
if 'hardware' in self.params:
|
|
|
|
if 'mem_limit' in self.params['hardware']:
|
|
|
|
if 'mem_limit' in self.params['hardware']:
|
|
|
@ -726,9 +727,9 @@ class PyVmomiHelper(PyVmomi):
|
|
|
|
mem_limit = int(self.params['hardware'].get('mem_limit'))
|
|
|
|
mem_limit = int(self.params['hardware'].get('mem_limit'))
|
|
|
|
except ValueError as e:
|
|
|
|
except ValueError as e:
|
|
|
|
self.module.fail_json(msg="hardware.mem_limit attribute should be an integer value.")
|
|
|
|
self.module.fail_json(msg="hardware.mem_limit attribute should be an integer value.")
|
|
|
|
self.configspec.memoryAllocation.limit = mem_limit
|
|
|
|
memory_allocation.limit = mem_limit
|
|
|
|
if vm_obj is None or self.configspec.memoryAllocation.limit != vm_obj.config.memoryAllocation.limit:
|
|
|
|
if vm_obj is None or memory_allocation.limit != vm_obj.config.memoryAllocation.limit:
|
|
|
|
self.change_detected = True
|
|
|
|
rai_change_detected = True
|
|
|
|
|
|
|
|
|
|
|
|
if 'mem_reservation' in self.params['hardware']:
|
|
|
|
if 'mem_reservation' in self.params['hardware']:
|
|
|
|
mem_reservation = None
|
|
|
|
mem_reservation = None
|
|
|
@ -737,10 +738,10 @@ class PyVmomiHelper(PyVmomi):
|
|
|
|
except ValueError as e:
|
|
|
|
except ValueError as e:
|
|
|
|
self.module.fail_json(msg="hardware.mem_reservation should be an integer value.")
|
|
|
|
self.module.fail_json(msg="hardware.mem_reservation should be an integer value.")
|
|
|
|
|
|
|
|
|
|
|
|
self.configspec.memoryAllocation.reservation = mem_reservation
|
|
|
|
memory_allocation.reservation = mem_reservation
|
|
|
|
if vm_obj is None or \
|
|
|
|
if vm_obj is None or \
|
|
|
|
self.configspec.memoryAllocation.reservation != vm_obj.config.memoryAllocation.reservation:
|
|
|
|
memory_allocation.reservation != vm_obj.config.memoryAllocation.reservation:
|
|
|
|
self.change_detected = True
|
|
|
|
rai_change_detected = True
|
|
|
|
|
|
|
|
|
|
|
|
if 'cpu_limit' in self.params['hardware']:
|
|
|
|
if 'cpu_limit' in self.params['hardware']:
|
|
|
|
cpu_limit = None
|
|
|
|
cpu_limit = None
|
|
|
@ -748,9 +749,9 @@ class PyVmomiHelper(PyVmomi):
|
|
|
|
cpu_limit = int(self.params['hardware'].get('cpu_limit'))
|
|
|
|
cpu_limit = int(self.params['hardware'].get('cpu_limit'))
|
|
|
|
except ValueError as e:
|
|
|
|
except ValueError as e:
|
|
|
|
self.module.fail_json(msg="hardware.cpu_limit attribute should be an integer value.")
|
|
|
|
self.module.fail_json(msg="hardware.cpu_limit attribute should be an integer value.")
|
|
|
|
self.configspec.cpuAllocation.limit = cpu_limit
|
|
|
|
cpu_allocation.limit = cpu_limit
|
|
|
|
if vm_obj is None or self.configspec.cpuAllocation.limit != vm_obj.config.cpuAllocation.limit:
|
|
|
|
if vm_obj is None or cpu_allocation.limit != vm_obj.config.cpuAllocation.limit:
|
|
|
|
self.change_detected = True
|
|
|
|
rai_change_detected = True
|
|
|
|
|
|
|
|
|
|
|
|
if 'cpu_reservation' in self.params['hardware']:
|
|
|
|
if 'cpu_reservation' in self.params['hardware']:
|
|
|
|
cpu_reservation = None
|
|
|
|
cpu_reservation = None
|
|
|
@ -758,9 +759,14 @@ class PyVmomiHelper(PyVmomi):
|
|
|
|
cpu_reservation = int(self.params['hardware'].get('cpu_reservation'))
|
|
|
|
cpu_reservation = int(self.params['hardware'].get('cpu_reservation'))
|
|
|
|
except ValueError as e:
|
|
|
|
except ValueError as e:
|
|
|
|
self.module.fail_json(msg="hardware.cpu_reservation should be an integer value.")
|
|
|
|
self.module.fail_json(msg="hardware.cpu_reservation should be an integer value.")
|
|
|
|
self.configspec.cpuAllocation.reservation = cpu_reservation
|
|
|
|
cpu_allocation.reservation = cpu_reservation
|
|
|
|
if vm_obj is None or \
|
|
|
|
if vm_obj is None or \
|
|
|
|
self.configspec.cpuAllocation.reservation != vm_obj.config.cpuAllocation.reservation:
|
|
|
|
cpu_allocation.reservation != vm_obj.config.cpuAllocation.reservation:
|
|
|
|
|
|
|
|
rai_change_detected = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if rai_change_detected:
|
|
|
|
|
|
|
|
self.configspec.memoryAllocation = memory_allocation
|
|
|
|
|
|
|
|
self.configspec.cpuAllocation = cpu_allocation
|
|
|
|
self.change_detected = True
|
|
|
|
self.change_detected = True
|
|
|
|
|
|
|
|
|
|
|
|
def configure_cpu_and_memory(self, vm_obj, vm_creation=False):
|
|
|
|
def configure_cpu_and_memory(self, vm_obj, vm_creation=False):
|
|
|
|