diff --git a/lib/ansible/modules/cloud/vmware/vsphere_guest.py b/lib/ansible/modules/cloud/vmware/vsphere_guest.py index ffa6baa1fd071a..caa3a394ad788b 100644 --- a/lib/ansible/modules/cloud/vmware/vsphere_guest.py +++ b/lib/ansible/modules/cloud/vmware/vsphere_guest.py @@ -19,6 +19,7 @@ # TODO: # Ability to set CPU/Memory reservations + try: import json except ImportError: @@ -983,7 +984,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name disk_num = 0 dev_changes = [] disks_changed = {} - for disk in sorted(vm_disk.iterkeys()): + for disk in sorted(vm_disk): try: disksize = int(vm_disk[disk]['size_gb']) # Convert the disk size to kilobytes @@ -1339,7 +1340,7 @@ def create_vm(vsphere_client, module, esxi, resource_pool, cluster_name, guest, if vm_disk: disk_num = 0 disk_key = 0 - for disk in sorted(vm_disk.iterkeys()): + for disk in sorted(vm_disk): try: datastore = vm_disk[disk]['datastore'] except KeyError: @@ -1395,7 +1396,7 @@ def create_vm(vsphere_client, module, esxi, resource_pool, cluster_name, guest, add_floppy(module, vsphere_client, config_target, config, devices, default_devs, floppy_type, floppy_image_path) if vm_nic: - for nic in sorted(vm_nic.iterkeys()): + for nic in sorted(vm_nic): try: nictype = vm_nic[nic]['type'] except KeyError: