From 09b3b5305ad6e511042b59c0ef804e63fa48ace9 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Tue, 5 Dec 2017 22:33:50 +0530 Subject: [PATCH] VMware: Add vmware guest param - maxMkConnections (#33220) This fix adds functionality to configure vmware guest parameter called 'maxMkconnections'. Also, added integration test for this change. Signed-off-by: Abhijeet Kasurde --- .../modules/cloud/vmware/vmware_guest.py | 17 +++++++++++++++++ .../vmware_guest/tasks/create_d1_c1_f0.yml | 1 + 2 files changed, 18 insertions(+) diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index 01c8de476e..66167ef6e7 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -92,6 +92,7 @@ options: - ' - C(memory_reservation) (integer): Amount of memory in MB to set resource limits for memory. version_added: 2.5' - " - C(memory_reservation_lock) (boolean): If set true, memory resource reservation for VM will always be equal to the VM's memory size. version_added: 2.5" + - ' - C(max_connections) (integer): Maximum number of active remote display connections for the virtual machines. version_added: 2.5.' guest_id: description: - Set the guest ID (Debian, RHEL, Windows...). @@ -226,6 +227,7 @@ EXAMPLES = r''' scsi: paravirtual memory_reservation: 512 memory_reservation_lock: True + max_connections: 5 cdrom: type: iso iso_path: "[datastore1] livecd.iso" @@ -732,6 +734,19 @@ class PyVmomiHelper(PyVmomi): self.change_detected = True self.configspec.deviceChange.append(cdrom_spec) + def configure_hardware_params(self, vm_obj): + """ + Function to configure hardware related configuration of virtual machine + Args: + vm_obj: virtual machine object + """ + # maxMksConnections == max_connections + if 'hardware' in self.params: + if 'max_connections' in self.params['hardware']: + self.configspec.maxMksConnections = int(self.params['hardware']['max_connections']) + if vm_obj is None or self.configspec.maxMksConnections != vm_obj.config.hardware.maxMksConnections: + self.change_detected = True + def get_vm_cdrom_device(self, vm=None): if vm is None: return None @@ -1369,6 +1384,7 @@ class PyVmomiHelper(PyVmomi): 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) + self.configure_hardware_params(vm_obj=vm_obj) self.configure_disks(vm_obj=vm_obj) self.configure_network(vm_obj=vm_obj) self.configure_cdrom(vm_obj=vm_obj) @@ -1487,6 +1503,7 @@ class PyVmomiHelper(PyVmomi): self.configure_guestid(vm_obj=self.current_vm_obj) self.configure_cpu_and_memory(vm_obj=self.current_vm_obj) + self.configure_hardware_params(vm_obj=self.current_vm_obj) self.configure_disks(vm_obj=self.current_vm_obj) self.configure_network(vm_obj=self.current_vm_obj) self.configure_cdrom(vm_obj=self.current_vm_obj) 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 59b74d03ec..d9f751d012 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 @@ -50,6 +50,7 @@ # till the time. # memory_reservation: 512 # memory_reservation_lock: False + max_connections: 10 disk: - size: 0gb type: thin