1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

VMware: Add support for numCoresPerSocket (#33149)

This fix adds support for hardware parameter 'numCoresPerSocket'
in vmware_guest module. Also, adds integration tests for this change.

Fixes: #20406

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2017-11-30 19:14:31 +05:30 committed by ansibot
parent 390a17f0eb
commit 1ca7929f96
2 changed files with 29 additions and 6 deletions

View file

@ -87,6 +87,7 @@ options:
- ' - 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(num_cpu_cores_per_socket) (integer): Number of Cores Per Socket. Value should be multiple of C(num_cpus).'
- ' - C(scsi) (string): Valid values are C(buslogic), C(lsilogic), C(lsilogicsas) and C(paravirtual) (default).'
guest_id:
description:
@ -217,7 +218,8 @@ EXAMPLES = r'''
datastore: g73_datastore
hardware:
memory_mb: 512
num_cpus: 1
num_cpus: 6
num_cpu_cores_per_socket: 3
scsi: paravirtual
cdrom:
type: iso
@ -612,7 +614,26 @@ class PyVmomiHelper(PyVmomi):
# set cpu/memory/etc
if 'hardware' in self.params:
if 'num_cpus' in self.params['hardware']:
self.configspec.numCPUs = int(self.params['hardware']['num_cpus'])
try:
num_cpus = int(self.params['hardware']['num_cpus'])
except ValueError as e:
self.module.fail_json(msg="hardware.num_cpus attribute should be an integer value.")
if 'num_cpu_cores_per_socket' in self.params['hardware']:
try:
num_cpu_cores_per_socket = int(self.params['hardware']['num_cpu_cores_per_socket'])
except ValueError as e:
self.module.fail_json(msg="hardware.num_cpu_cores_per_socket attribute "
"should be an integer value.")
if num_cpus % num_cpu_cores_per_socket != 0:
self.module.fail_json(msg="hardware.num_cpus attribute should be a multiple "
"of hardware.num_cpu_cores_per_socket")
self.configspec.numCoresPerSocket = num_cpu_cores_per_socket
if vm_obj is None or self.configspec.numCoresPerSocket != vm_obj.config.hardware.numCoresPerSocket:
self.change_detected = True
self.configspec.numCPUs = num_cpus
if vm_obj is None or self.configspec.numCPUs != vm_obj.config.hardware.numCPU:
self.change_detected = True
# num_cpu is mandatory for VM creation

View file

@ -41,8 +41,11 @@
guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}"
hardware:
num_cpus: 1
num_cpus: 4
num_cpu_cores_per_socket: 2
memory_mb: 512
hotadd_memory: true
hotadd_cpu: false
disk:
- size: 0gb
type: thin
@ -70,10 +73,9 @@
guest_id: centos64Guest
datacenter: "{{ (item|basename).split('_')[0] }}"
hardware:
num_cpus: 1
num_cpus: 4
num_cpu_cores_per_socket: 2
memory_mb: 512
hotadd_memory: true
hotadd_cpu: false
disk:
- size: 0gb
type: thin