Skip to content

Commit ba113a5

Browse files
committed
Fix ansible-core 2.19 compatibility
1 parent ce75a5a commit ba113a5

File tree

12 files changed

+95
-86
lines changed

12 files changed

+95
-86
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
bugfixes:
2+
- vm_device_helper - Fix an issue with ansible-core 2.19
3+
(https://github.com/ansible-collections/community.vmware/pull/2391).
4+
- vmware_guest_controller - Fix an issue with ansible-core 2.19
5+
(https://github.com/ansible-collections/community.vmware/pull/2391).
6+
- vmware_guest_disk - Fix an issue with ansible-core 2.19
7+
(https://github.com/ansible-collections/community.vmware/pull/2391).
8+
- vmware_target_canonical_info - Fix an issue with ansible-core 2.19
9+
(https://github.com/ansible-collections/community.vmware/pull/2391).

plugins/module_utils/vm_device_helper.py

+26-26
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ def gather_disk_info(self, vm_obj):
430430
for controller in vm_obj.config.hardware.device:
431431
for name, type in self.disk_ctl_device_type.items():
432432
if isinstance(controller, type):
433-
controller_info[controller_index] = dict(
433+
controller_info[str(controller_index)] = dict(
434434
key=controller.key,
435435
controller_type=name,
436436
bus_number=controller.busNumber,
@@ -448,7 +448,7 @@ def gather_disk_info(self, vm_obj):
448448
if disk.shares is None:
449449
disk.shares = vim.SharesInfo()
450450

451-
disks_info[disk_index] = dict(
451+
disks_info[str(disk_index)] = dict(
452452
key=disk.key,
453453
label=disk.deviceInfo.label,
454454
summary=disk.deviceInfo.summary,
@@ -470,48 +470,48 @@ def gather_disk_info(self, vm_obj):
470470
capacity_in_bytes=disk.capacityInBytes,
471471
)
472472
if isinstance(disk.backing, vim.vm.device.VirtualDisk.FlatVer1BackingInfo):
473-
disks_info[disk_index]['backing_type'] = 'FlatVer1'
473+
disks_info[str(disk_index)]['backing_type'] = 'FlatVer1'
474474

475475
elif isinstance(disk.backing, vim.vm.device.VirtualDisk.FlatVer2BackingInfo):
476-
disks_info[disk_index]['backing_type'] = 'FlatVer2'
477-
disks_info[disk_index]['backing_thinprovisioned'] = disk.backing.thinProvisioned
478-
disks_info[disk_index]['backing_eagerlyscrub'] = disk.backing.eagerlyScrub
476+
disks_info[str(disk_index)]['backing_type'] = 'FlatVer2'
477+
disks_info[str(disk_index)]['backing_thinprovisioned'] = disk.backing.thinProvisioned
478+
disks_info[str(disk_index)]['backing_eagerlyscrub'] = disk.backing.eagerlyScrub
479479

480480
elif isinstance(disk.backing, vim.vm.device.VirtualDisk.LocalPMemBackingInfo):
481-
disks_info[disk_index]['backing_type'] = 'LocalPMem'
482-
disks_info[disk_index]['backing_volumeuuid'] = disk.backing.volumeUUID
481+
disks_info[str(disk_index)]['backing_type'] = 'LocalPMem'
482+
disks_info[str(disk_index)]['backing_volumeuuid'] = disk.backing.volumeUUID
483483

484484
elif isinstance(disk.backing, vim.vm.device.VirtualDisk.PartitionedRawDiskVer2BackingInfo):
485-
disks_info[disk_index]['backing_type'] = 'PartitionedRawDiskVer2'
486-
disks_info[disk_index]['backing_descriptorfilename'] = disk.backing.descriptorFileName
485+
disks_info[str(disk_index)]['backing_type'] = 'PartitionedRawDiskVer2'
486+
disks_info[str(disk_index)]['backing_descriptorfilename'] = disk.backing.descriptorFileName
487487

488488
elif isinstance(disk.backing, vim.vm.device.VirtualDisk.RawDiskMappingVer1BackingInfo):
489-
disks_info[disk_index]['backing_type'] = 'RawDiskMappingVer1'
490-
disks_info[disk_index]['backing_devicename'] = disk.backing.deviceName
491-
disks_info[disk_index]['backing_lunuuid'] = disk.backing.lunUuid
492-
disks_info[disk_index]['backing_compatibility_mode'] = disk.backing.compatibilityMode
489+
disks_info[str(disk_index)]['backing_type'] = 'RawDiskMappingVer1'
490+
disks_info[str(disk_index)]['backing_devicename'] = disk.backing.deviceName
491+
disks_info[str(disk_index)]['backing_lunuuid'] = disk.backing.lunUuid
492+
disks_info[str(disk_index)]['backing_compatibility_mode'] = disk.backing.compatibilityMode
493493

494494
elif isinstance(disk.backing, vim.vm.device.VirtualDisk.RawDiskVer2BackingInfo):
495-
disks_info[disk_index]['backing_type'] = 'RawDiskVer2'
496-
disks_info[disk_index]['backing_descriptorfilename'] = disk.backing.descriptorFileName
495+
disks_info[str(disk_index)]['backing_type'] = 'RawDiskVer2'
496+
disks_info[str(disk_index)]['backing_descriptorfilename'] = disk.backing.descriptorFileName
497497

498498
elif isinstance(disk.backing, vim.vm.device.VirtualDisk.SeSparseBackingInfo):
499-
disks_info[disk_index]['backing_type'] = 'SeSparse'
499+
disks_info[str(disk_index)]['backing_type'] = 'SeSparse'
500500

501501
elif isinstance(disk.backing, vim.vm.device.VirtualDisk.SparseVer1BackingInfo):
502-
disks_info[disk_index]['backing_type'] = 'SparseVer1'
503-
disks_info[disk_index]['backing_spaceusedinkb'] = disk.backing.spaceUsedInKB
504-
disks_info[disk_index]['backing_split'] = disk.backing.split
502+
disks_info[str(disk_index)]['backing_type'] = 'SparseVer1'
503+
disks_info[str(disk_index)]['backing_spaceusedinkb'] = disk.backing.spaceUsedInKB
504+
disks_info[str(disk_index)]['backing_split'] = disk.backing.split
505505

506506
elif isinstance(disk.backing, vim.vm.device.VirtualDisk.SparseVer2BackingInfo):
507-
disks_info[disk_index]['backing_type'] = 'SparseVer2'
508-
disks_info[disk_index]['backing_spaceusedinkb'] = disk.backing.spaceUsedInKB
509-
disks_info[disk_index]['backing_split'] = disk.backing.split
507+
disks_info[str(disk_index)]['backing_type'] = 'SparseVer2'
508+
disks_info[str(disk_index)]['backing_spaceusedinkb'] = disk.backing.spaceUsedInKB
509+
disks_info[str(disk_index)]['backing_split'] = disk.backing.split
510510

511511
for controller_index in range(len(controller_info)):
512-
if controller_info[controller_index]['key'] == disks_info[disk_index]['controller_key']:
513-
disks_info[disk_index]['controller_bus_number'] = controller_info[controller_index]['bus_number']
514-
disks_info[disk_index]['controller_type'] = controller_info[controller_index]['controller_type']
512+
if controller_info[str(controller_index)]['key'] == disks_info[str(disk_index)]['controller_key']:
513+
disks_info[str(disk_index)]['controller_bus_number'] = controller_info[str(controller_index)]['bus_number']
514+
disks_info[str(disk_index)]['controller_type'] = controller_info[str(controller_index)]['controller_type']
515515

516516
disk_index += 1
517517
return disks_info

plugins/modules/vmware_guest_controller.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def gather_disk_controller_facts(self):
345345
for device in self.current_vm_obj.config.hardware.device:
346346
ctl_facts_dict = dict()
347347
if isinstance(device, tuple(self.controller_types.values())):
348-
ctl_facts_dict[device.busNumber] = dict(
348+
ctl_facts_dict[str(device.busNumber)] = dict(
349349
controller_summary=device.deviceInfo.summary,
350350
controller_label=device.deviceInfo.label,
351351
controller_busnumber=device.busNumber,
@@ -355,7 +355,7 @@ def gather_disk_controller_facts(self):
355355
controller_disks_devicekey=device.device,
356356
)
357357
if hasattr(device, 'sharedBus'):
358-
ctl_facts_dict[device.busNumber]['controller_bus_sharing'] = device.sharedBus
358+
ctl_facts_dict[str(device.busNumber)]['controller_bus_sharing'] = device.sharedBus
359359
if isinstance(device, tuple(self.device_helper.scsi_device_type.values())):
360360
disk_ctl_facts['scsi'].update(ctl_facts_dict)
361361
if isinstance(device, self.device_helper.nvme_device_type):

plugins/modules/vmware_guest_disk.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ def ensure_disks(self, vm_obj=None):
750750
if disk_change:
751751
self.config_spec.deviceChange.append(disk_spec)
752752
disk_change_list.append(disk_change)
753-
results['disk_changes'][disk['disk_index']] = "Disk reconfigured."
753+
results['disk_changes'][str(disk['disk_index'])] = "Disk reconfigured."
754754

755755
elif disk['state'] == 'absent':
756756
# Disk already exists, deleting
@@ -762,7 +762,7 @@ def ensure_disks(self, vm_obj=None):
762762
self.config_spec.deviceChange.append(disk_spec)
763763
disk_change = True
764764
disk_change_list.append(disk_change)
765-
results['disk_changes'][disk['disk_index']] = "Disk deleted."
765+
results['disk_changes'][str(disk['disk_index'])] = "Disk deleted."
766766
break
767767

768768
if disk_found:
@@ -804,7 +804,7 @@ def ensure_disks(self, vm_obj=None):
804804
self.config_spec.deviceChange.append(disk_spec)
805805
disk_change = True
806806
disk_change_list.append(disk_change)
807-
results['disk_changes'][disk['disk_index']] = "Disk created."
807+
results['disk_changes'][str(disk['disk_index'])] = "Disk created."
808808
break
809809
if disk_change:
810810
# Adding multiple disks in a single attempt raises weird errors

plugins/modules/vmware_target_canonical_info.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def gather_scsi_device_info(self):
133133
# Associate target number with LUN uuid
134134
for target in host.config.storageDevice.scsiTopology.adapter[0].target:
135135
for lun in target.lun:
136-
target_lun_uuid[target.target] = lun.scsiLun
136+
target_lun_uuid[str(target.target)] = lun.scsiLun
137137

138138
scsi_tgt_info[host.name] = dict(
139139
scsilun_canonical=scsilun_canonical,
@@ -143,7 +143,7 @@ def gather_scsi_device_info(self):
143143
canonical = ''
144144
temp_lun_data = scsi_tgt_info[self.esxi_hostname]['target_lun_uuid']
145145
if self.esxi_hostname in scsi_tgt_info and \
146-
target_id in temp_lun_data:
146+
str(target_id) in temp_lun_data:
147147
temp_scsi_data = scsi_tgt_info[self.esxi_hostname]['scsilun_canonical']
148148
temp_target = temp_lun_data[target_id]
149149
canonical = temp_scsi_data[temp_target]

tests/integration/targets/vmware_cluster_info/tasks/main.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
name: ensure info are gathered for all clusters
2020
assert:
2121
that:
22-
- all_cluster_result.clusters
22+
- all_cluster_result.clusters | length > 0
2323
- not all_cluster_result.changed
2424

2525
- name: ensure info are all defined
@@ -72,7 +72,7 @@
7272
name: Ensure info are gathered for the given cluster
7373
assert:
7474
that:
75-
- cluster_result.clusters
75+
- cluster_result.clusters | length > 0
7676
- not cluster_result.changed
7777

7878
- <<: *vc_cluster_data
@@ -99,7 +99,7 @@
9999
- name: Ensure info are gathered for all clusters with properteis
100100
assert:
101101
that:
102-
- all_cluster_result.clusters
102+
- all_cluster_result.clusters | length > 0
103103
- all_cluster_result.clusters[item].name == item
104104
- all_cluster_result.clusters[item].configuration.dasConfig.enabled is defined
105105
- all_cluster_result.clusters[item].summary.totalCpu is defined
@@ -123,7 +123,7 @@
123123
- name: Ensure info are gathered for the given cluster with properties
124124
assert:
125125
that:
126-
- cluster_result.clusters
126+
- cluster_result.clusters | length > 0
127127
- cluster_result.clusters[item].name == item
128128
- cluster_result.clusters[item].configuration.dasConfig.enabled is defined
129129
- cluster_result.clusters[item].summary.totalCpu is defined
@@ -191,4 +191,4 @@
191191
- name: "Ensure URL-encoded cluster name"
192192
assert:
193193
that:
194-
- all_cluster_result.clusters['Cluster/\%']
194+
- all_cluster_result.clusters['Cluster/\%'] is truthy

tests/integration/targets/vmware_datacenter_info/tasks/main.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
- name: Ensure datacenter is present
2020
assert:
2121
that:
22-
- dc_result.datacenter_info
22+
- dc_result.datacenter_info | length > 0
2323

2424
- name: Gather information about all datacenter in check mode
2525
vmware_datacenter_info:
@@ -36,7 +36,7 @@
3636
- name: Ensure datacenter is present
3737
assert:
3838
that:
39-
- dc_result.datacenter_info
39+
- dc_result.datacenter_info | length > 0
4040

4141
- name: Gather information about particular datacenter
4242
vmware_datacenter_info:
@@ -53,7 +53,7 @@
5353
- name: Ensure datacenter is present
5454
assert:
5555
that:
56-
- dc_result.datacenter_info
56+
- dc_result.datacenter_info | length > 0
5757

5858
- name: Gather information about particular datacenter in check mode
5959
vmware_datacenter_info:
@@ -71,4 +71,4 @@
7171
- name: Ensure datacenter is present
7272
assert:
7373
that:
74-
- dc_result.datacenter_info
74+
- dc_result.datacenter_info | length > 0

tests/integration/targets/vmware_dvs_portgroup_info/tasks/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
assert:
6565
that:
6666
- >-
67-
dvs_results.dvs_portgroup_info.{{ dvswitch1 }}
67+
dvs_results.dvs_portgroup_info['{{ dvswitch1 }}']
6868
| map(attribute='portgroup_name')
6969
| select('==', 'dvportgroup\/%')
7070
| list
@@ -107,4 +107,4 @@
107107
- assert:
108108
that:
109109
- "dvs_results_0002['dvs_portgroup_info']['DVS0'] is defined"
110-
- dvs_results_0002['dvs_portgroup_info']['DVS0'][0].key
110+
- dvs_results_0002['dvs_portgroup_info']['DVS0'][0].key is truthy

tests/integration/targets/vmware_host_config_info/tasks/main.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
- name: ensure info are gathered for all hosts
2222
assert:
2323
that:
24-
- all_hosts_result.hosts_info
24+
- all_hosts_result.hosts_info is truthy
2525

2626
- name: gather info about all hosts in given cluster in check mode
2727
vmware_host_config_info:
@@ -36,7 +36,7 @@
3636
- name: ensure info are gathered for all hosts
3737
assert:
3838
that:
39-
- all_hosts_result_check_mode.hosts_info
39+
- all_hosts_result_check_mode.hosts_info is truthy
4040

4141
- name: gather info about a given host in check mode
4242
vmware_host_config_info:
@@ -50,7 +50,7 @@
5050
- name: ensure info are gathered for all hosts
5151
assert:
5252
that:
53-
- single_hosts_result_check_mode.hosts_info
53+
- single_hosts_result_check_mode.hosts_info is truthy
5454

5555
- name: gather info about a given host
5656
vmware_host_config_info:
@@ -63,4 +63,4 @@
6363
- name: ensure info are gathered for all hosts
6464
assert:
6565
that:
66-
- single_hosts_result.hosts_info
66+
- single_hosts_result.hosts_info is truthy

tests/integration/targets/vmware_host_dns_info/tasks/main.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
- name: ensure DNS info are gathered for all hosts in given cluster
2020
assert:
2121
that:
22-
- all_hosts_dns_result.hosts_dns_info
22+
- all_hosts_dns_result.hosts_dns_info is truthy
2323
- not all_hosts_dns_result.changed
2424

2525
- name: gather DNS info about host system
@@ -34,7 +34,7 @@
3434
- name: ensure DNS info are gathered about host system
3535
assert:
3636
that:
37-
- all_hosts_dns_result.hosts_dns_info
37+
- all_hosts_dns_result.hosts_dns_info is truthy
3838
- not all_hosts_dns_result.changed
3939

4040
- name: gather DNS info about all hosts in given cluster in check mode
@@ -50,7 +50,7 @@
5050
- name: ensure DNS info are gathered for all hosts in given cluster
5151
assert:
5252
that:
53-
- all_hosts_dns_result_check_mode.hosts_dns_info
53+
- all_hosts_dns_result_check_mode.hosts_dns_info is truthy
5454
- not all_hosts_dns_result_check_mode.changed
5555

5656
- name: gather DNS info about host system in check mode
@@ -66,5 +66,5 @@
6666
- name: ensure DNS info are gathered about host system
6767
assert:
6868
that:
69-
- all_hosts_dns_result_check_mode.hosts_dns_info
69+
- all_hosts_dns_result_check_mode.hosts_dns_info is truthy
7070
- not all_hosts_dns_result_check_mode.changed

tests/integration/targets/vmware_host_scsidisk_info/tasks/main.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
- name: Ensure SCSI disks info are gathered for all hosts in given cluster
2121
assert:
2222
that:
23-
- all_hosts_disk_result.hosts_scsidisk_info
23+
- all_hosts_disk_result.hosts_scsidisk_info is truthy
2424
- not all_hosts_disk_result.changed
2525

2626
- name: Gather SCSI disks info about host system
@@ -35,7 +35,7 @@
3535
- name: Ensure SCSI disks info are gathered about host system
3636
assert:
3737
that:
38-
- all_hosts_disk_result.hosts_scsidisk_info
38+
- all_hosts_disk_result.hosts_scsidisk_info is truthy
3939
- not all_hosts_disk_result.changed
4040

4141
- name: Gather SCSI disks info about all hosts in given cluster in check mode
@@ -51,7 +51,7 @@
5151
- name: Ensure SCSI disks info are gathered for all hosts in given cluster
5252
assert:
5353
that:
54-
- all_hosts_disk_result_check_mode.hosts_scsidisk_info
54+
- all_hosts_disk_result_check_mode.hosts_scsidisk_info is truthy
5555
- not all_hosts_disk_result_check_mode.changed
5656

5757
- name: Ensure SCSI disks info about host system in check mode
@@ -67,5 +67,5 @@
6767
- name: Ensure SCSI disks info are gathered about host system
6868
assert:
6969
that:
70-
- all_hosts_disk_result_check_mode.hosts_scsidisk_info
70+
- all_hosts_disk_result_check_mode.hosts_scsidisk_info is truthy
7171
- not all_hosts_disk_result_check_mode.changed

0 commit comments

Comments
 (0)