Skip to content

Commit adb22a4

Browse files
committed
Changed Vm create/update terminology for CPU allocation to aid in transparency. Changed terminology to core/socket rather than vcpu/socket
1 parent 933ac6d commit adb22a4

File tree

5 files changed

+39
-40
lines changed

5 files changed

+39
-40
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ A log of changes by version and date.
77
:header: "Version", "Date", "Notes"
88
:widths: 10, 10, 60
99

10+
"1.4.3", "6/1/2021", "Changed Vm create/update terminology for CPU allocation to aid in transparency. Changed terminology to core/socket rather than vcpu/socket."
1011
"1.4.2", "6/1/2021", "Updated vCPU/socket calculation for Vms.update to match that in Vms.create."
1112
"1.4.1", "6/1/2021", "Updated Images.search_uuid to also check for a match with the uuid of the image disk."
1213
"1.4.0", "5/20/2021", "Added functions to the VMs class for CRUD operations to related to the management of virtual machines. Added function to the VolumeGroups class for CRUD operations to related to the management of volumes and volume groups."

ntnx_api/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# 2) we can import it in setup.py for the same reason
44
# 3) we can import it into your module module
55

6-
__version_info__ = ('1', '4', '2')
6+
__version_info__ = ('1', '4', '3')
77
__version__ = '.'.join(__version_info__)

ntnx_api/prism.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,7 +3033,7 @@ def _vm_serial_port_spec(port_index:int=None, port_type:str='null', **kwargs):
30333033

30343034
return serial_port
30353035

3036-
def create(self, name:str, vcpus:int, memory_gb:int, sockets:int=1, vcpu_reservation_hz:int=0, memory_reservation_gb:int=0, description:str='',
3036+
def create(self, name:str, cores:int, memory_gb:int, sockets:int=1, vcpu_reservation_hz:int=0, memory_reservation_gb:int=0, description:str='',
30373037
power_state:str='on', disks:list=[], storage_container_uuid:str=None, nics:list=[], gpus:list=[], serial_ports:list=[], timezone:str='UTC',
30383038
sysprep:str=None, cloudinit:str=None, add_cdrom:bool=True, ha_priority:int=0, machine_type:str='pc', wait:bool=True, clusteruuid:str=None):
30393039
""" Create a new virtual machine.
@@ -3042,12 +3042,12 @@ def create(self, name:str, vcpus:int, memory_gb:int, sockets:int=1, vcpu_reserva
30423042
:type name: str
30433043
:param description: A description for the VM (default='')
30443044
:type description: str, optional
3045-
:param vcpus: The number of vCPUs to be assigned to this VM
3046-
:type vcpus: int
3047-
:param memory_gb: The amount of memory in GB to be assigne to this VM
3048-
:type memory_gb: int
3045+
:param cores: The number of virtual CPU cores per virtual CPU socket
3046+
:type cores: int
30493047
:param sockets: The number of virtual CPU sockets to distribute the defined vCPUs over (default=1)
30503048
:type sockets: int, optional
3049+
:param memory_gb: The amount of memory in GB to be assigne to this VM
3050+
:type memory_gb: int
30513051
:param vcpu_reservation_hz: A CPU reservation in hz for this VM. Only applicable on the ESXi hypervisor. (default=0)
30523052
:type vcpu_reservation_hz: int, optional
30533053
:param memory_reservation_gb: An amount of memory to lock to this VM. Only applicable on the ESXi hypervisor. (default=0)
@@ -3154,8 +3154,8 @@ def create(self, name:str, vcpus:int, memory_gb:int, sockets:int=1, vcpu_reserva
31543154
'name': name,
31553155
'description': description,
31563156
'memory_mb': int(bm_memory_mb),
3157+
'num_vcpus': cores,
31573158
'sockets': sockets,
3158-
'num_vcpus': (vcpus/sockets),
31593159
'power_state': 'OFF',
31603160
'timezone': timezone,
31613161
'ha_priority': ha_priority,
@@ -4054,7 +4054,7 @@ def power_state(self, uuid:str, desired_state:str='on', wait:bool=True, clusteru
40544054
else:
40554055
return False
40564056

4057-
def update_name(self, name:str, new_name:str=None, vcpus:int=None, memory_gb:int=None, sockets:int=None, vcpu_reservation_hz:int=None,
4057+
def update_name(self, name:str, new_name:str=None, cores:int=None, sockets:int=None, memory_gb:int=None, vcpu_reservation_hz:int=None,
40584058
memory_reservation_gb:int=None, description:str=None, disks:list=[], nics:list=[], gpus:list=[], serial_ports:list=[], timezone:str=None,
40594059
add_cdrom:bool=None, ha_priority:int=None, force:bool=False, wait:bool=True, clusteruuid:str=None):
40604060
"""Updates a specific virtual machine by the vm name provided.
@@ -4063,12 +4063,12 @@ def update_name(self, name:str, new_name:str=None, vcpus:int=None, memory_gb:int
40634063
:type name: str
40644064
:param new_name: A new name for the virtual machine.
40654065
:type new_name: str, optional
4066-
:param vcpus: The number of vCPUs to be assigned to this VM
4067-
:type vcpus: int
4068-
:param memory_gb: The amount of memory in GB to be assigne to this VM
4069-
:type memory_gb: int
4066+
:param cores: The number of virtual CPU cores per virtual CPU socket
4067+
:type cores: int
40704068
:param sockets: The number of virtual CPU sockets to distribute the defined vCPUs over (default=1)
40714069
:type sockets: int, optional
4070+
:param memory_gb: The amount of memory in GB to be assigne to this VM
4071+
:type memory_gb: int
40724072
:param vcpu_reservation_hz: A CPU reservation in hz for this VM. Only applicable on the ESXi hypervisor. (default=0)
40734073
:type vcpu_reservation_hz: int, optional
40744074
:param memory_reservation_gb: An amount of memory to lock to this VM. Only applicable on the ESXi hypervisor. (default=0)
@@ -4157,7 +4157,7 @@ def update_name(self, name:str, new_name:str=None, vcpus:int=None, memory_gb:int
41574157
vm_config = {
41584158
'uuid': vm.get('uuid'),
41594159
'new_name': new_name,
4160-
'vcpus': vcpus,
4160+
'cores': cores,
41614161
'memory_gb': memory_gb,
41624162
'sockets': sockets,
41634163
'vcpu_reservation_hz': vcpu_reservation_hz,
@@ -4178,7 +4178,7 @@ def update_name(self, name:str, new_name:str=None, vcpus:int=None, memory_gb:int
41784178
else:
41794179
raise ValueError()
41804180

4181-
def update_uuid(self, uuid:str, new_name:str=None, vcpus:int=None, memory_gb:int=None, sockets:int=None, vcpu_reservation_hz:int=None,
4181+
def update_uuid(self, uuid:str, new_name:str=None, cores:int=None, sockets:int=None, memory_gb:int=None, vcpu_reservation_hz:int=None,
41824182
memory_reservation_gb:int=None, description:str=None, disks:list=[], nics:list=[], gpus:list=[], serial_ports:list=[], timezone:str=None,
41834183
add_cdrom:bool=None, ha_priority:int=None, force:bool=False, wait:bool=True, clusteruuid:str=None):
41844184
"""Updates a specific virtual machine by the uuid provided
@@ -4187,10 +4187,10 @@ def update_uuid(self, uuid:str, new_name:str=None, vcpus:int=None, memory_gb:int
41874187
:type uuid: str
41884188
:param new_name: A new name for the virtual machine.
41894189
:type new_name: str, optional
4190-
:param vcpus: The number of vCPUs to be assigned to this VM
4191-
:type vcpus: int
41924190
:param memory_gb: The amount of memory in GB to be assigne to this VM
41934191
:type memory_gb: int
4192+
:param cores: The number of virtual CPU cores per virtual CPU socket
4193+
:type cores: int
41944194
:param sockets: The number of virtual CPU sockets to distribute the defined vCPUs over (default=1)
41954195
:type sockets: int, optional
41964196
:param vcpu_reservation_hz: A CPU reservation in hz for this VM. Only applicable on the ESXi hypervisor. (default=0)
@@ -4305,15 +4305,13 @@ def update_uuid(self, uuid:str, new_name:str=None, vcpus:int=None, memory_gb:int
43054305
bm_memory_mb = bm_memory_gb.to_MB()
43064306
payload['memory_mb'] = int(bm_memory_mb)
43074307

4308-
if sockets:
4308+
if cores:
43094309
required_power_state = 'off'
4310-
payload['sockets'] = sockets
4311-
else:
4312-
sockets = vm.get('sockets')
4310+
payload['num_vcpus'] = cores
43134311

4314-
if vcpus:
4312+
if sockets:
43154313
required_power_state = 'off'
4316-
payload['num_vcpus'] = (vcpus/sockets)
4314+
payload['sockets'] = sockets
43174315

43184316
if timezone:
43194317
payload['timezone'] = timezone

ntnx_api/test/prism/test_prism_vms_pc.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_vm_create_with_vdisks():
3737
result = False
3838
vm_config = {
3939
'name': 'api_test_v2_vdisk_{0}'.format(random_string),
40-
'vcpus': 1,
40+
'cores': 1,
4141
'memory_gb': 0.1,
4242
'add_cdrom': True,
4343
'power_state': 'off',
@@ -70,7 +70,7 @@ def test_vm_create_with_vdisk_nic():
7070
result = False
7171
vm_config = {
7272
'name': 'api_test_v2_vdisk_nic_{0}'.format(random_string),
73-
'vcpus': 1,
73+
'cores': 1,
7474
'memory_gb': 0.1,
7575
'add_cdrom': True,
7676
'power_state': 'off',
@@ -106,7 +106,7 @@ def test_vm_create_with_vdisk_nic_ipam():
106106
result = False
107107
vm_config = {
108108
'name': 'api_test_v2_vdisk_nic_ipam_{0}'.format(random_string),
109-
'vcpus': 1,
109+
'cores': 1,
110110
'memory_gb': 0.1,
111111
'add_cdrom': True,
112112
'power_state': 'off',
@@ -144,7 +144,7 @@ def test_return_v2_vm_create_with_vdisk_nic_ipam_ip():
144144
result = False
145145
vm_config = {
146146
'name': 'api_test_v2_vdisk_nic_ipam_ip_{0}'.format(random_string),
147-
'vcpus': 1,
147+
'cores': 1,
148148
'memory_gb': 0.1,
149149
'add_cdrom': True,
150150
'power_state': 'off',
@@ -182,7 +182,7 @@ def test_vm_create_from_image_nic_ipam():
182182
result = False
183183
vm_config = {
184184
'name': 'api_test_v2_image_nic_ipam_{0}'.format(random_string),
185-
'vcpus': 1,
185+
'cores': 1,
186186
'memory_gb': 0.1,
187187
'add_cdrom': True,
188188
'power_state': 'off',
@@ -217,7 +217,7 @@ def test_vm_create_from_image_vg_nic_ipam():
217217
result = False
218218
vm_config = {
219219
'name': 'api_test_v2_image_vg_nic_ipam_{0}'.format(random_string),
220-
'vcpus': 1,
220+
'cores': 1,
221221
'memory_gb': 0.1,
222222
'add_cdrom': True,
223223
'power_state': 'off',
@@ -255,7 +255,7 @@ def test_vm_create_failure():
255255
result = False
256256
vm_config = {
257257
'name': 'api_test_v2_failure_{0}'.format(random_string),
258-
'vcpus': 16,
258+
'cores': 16,
259259
'memory_gb': 128,
260260
'add_cdrom': True,
261261
'disks': [
@@ -288,7 +288,7 @@ def test_vm_clone():
288288
result = False
289289
vm_config = {
290290
'name': 'api_test_v2_clone_original_{0}'.format(random_string),
291-
'vcpus': 1,
291+
'cores': 1,
292292
'memory_gb': 0.1,
293293
'add_cdrom': True,
294294
'power_state': 'off',
@@ -316,7 +316,7 @@ def test_vm_clone():
316316
vm_clone_config_2 = {
317317
'source_name': 'api_test_v2_clone_original_{0}'.format(random_string),
318318
'name': 'api_test_v2_clone_2_{0}'.format(random_string),
319-
'vcpus': 2,
319+
'cores': 2,
320320
'memory_gb': 128,
321321
}
322322
results.append(vms_obj.clone_name(clusteruuid=each_uuid, **vm_clone_config_2))

ntnx_api/test/prism/test_prism_vms_pe.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_vm_create_with_vdisks():
3737
result = False
3838
vm_config = {
3939
'name': 'api_test_v2_vdisk_{0}'.format(random_string),
40-
'vcpus': 1,
40+
'cores': 1,
4141
'memory_gb': 0.1,
4242
'add_cdrom': True,
4343
'power_state': 'off',
@@ -70,7 +70,7 @@ def test_vm_create_with_vdisk_nic():
7070
result = False
7171
vm_config = {
7272
'name': 'api_test_v2_vdisk_nic_{0}'.format(random_string),
73-
'vcpus': 1,
73+
'cores': 1,
7474
'memory_gb': 0.1,
7575
'add_cdrom': True,
7676
'power_state': 'off',
@@ -106,7 +106,7 @@ def test_vm_create_with_vdisk_nic_ipam():
106106
result = False
107107
vm_config = {
108108
'name': 'api_test_v2_vdisk_nic_ipam_{0}'.format(random_string),
109-
'vcpus': 1,
109+
'cores': 1,
110110
'memory_gb': 0.1,
111111
'add_cdrom': True,
112112
'power_state': 'off',
@@ -144,7 +144,7 @@ def test_return_v2_vm_create_with_vdisk_nic_ipam_ip():
144144
result = False
145145
vm_config = {
146146
'name': 'api_test_v2_vdisk_nic_ipam_ip_{0}'.format(random_string),
147-
'vcpus': 1,
147+
'cores': 1,
148148
'memory_gb': 0.1,
149149
'add_cdrom': True,
150150
'power_state': 'off',
@@ -182,7 +182,7 @@ def test_vm_create_from_image_nic_ipam():
182182
result = False
183183
vm_config = {
184184
'name': 'api_test_v2_image_nic_ipam_{0}'.format(random_string),
185-
'vcpus': 1,
185+
'cores': 1,
186186
'memory_gb': 0.1,
187187
'add_cdrom': True,
188188
'power_state': 'off',
@@ -217,7 +217,7 @@ def test_vm_create_from_image_vg_nic_ipam():
217217
result = False
218218
vm_config = {
219219
'name': 'api_test_v2_image_vg_nic_ipam_{0}'.format(random_string),
220-
'vcpus': 1,
220+
'cores': 1,
221221
'memory_gb': 0.1,
222222
'add_cdrom': True,
223223
'power_state': 'off',
@@ -255,7 +255,7 @@ def test_vm_create_failure():
255255
result = False
256256
vm_config = {
257257
'name': 'api_test_v2_failure_{0}'.format(random_string),
258-
'vcpus': 16,
258+
'cores': 16,
259259
'memory_gb': 128,
260260
'add_cdrom': True,
261261
'disks': [
@@ -288,7 +288,7 @@ def test_vm_clone():
288288
result = False
289289
vm_config = {
290290
'name': 'api_test_v2_clone_original_{0}'.format(random_string),
291-
'vcpus': 1,
291+
'cores': 1,
292292
'memory_gb': 0.1,
293293
'add_cdrom': True,
294294
'power_state': 'off',
@@ -316,7 +316,7 @@ def test_vm_clone():
316316
vm_clone_config_2 = {
317317
'source_name': 'api_test_v2_clone_original_{0}'.format(random_string),
318318
'name': 'api_test_v2_clone_2_{0}'.format(random_string),
319-
'vcpus': 2,
319+
'cores': 2,
320320
'memory_gb': 128,
321321
}
322322
results.append(vms_obj.clone_name(clusteruuid=each_uuid, **vm_clone_config_2))

0 commit comments

Comments
 (0)