From cf2f13e05d1248debc278d4a687bc72898365968 Mon Sep 17 00:00:00 2001 From: Ludovic Rivallain Date: Wed, 27 Mar 2019 13:02:41 +0100 Subject: [PATCH] Securize the index based lookup of dict.keys() (#54452) --- lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py | 2 +- lib/ansible/modules/cloud/vmware/vmware_dns_config.py | 2 +- lib/ansible/modules/cloud/vmware/vmware_vmkernel_ip_config.py | 2 +- lib/ansible/modules/cloud/vmware/vmware_vsan_cluster.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py b/lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py index 224744c488b..2b7d3436174 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py +++ b/lib/ansible/modules/cloud/vmware/vmware_cfg_backup.py @@ -114,7 +114,7 @@ class VMwareConfigurationBackup(PyVmomi): self.module.fail_json(msg="Failed to find ESXi %s" % self.esxi_hostname) host_system = get_all_objs(self.content, [vim.HostSystem]) - return host_system.keys()[0] + return list(host_system)[0] def process_state(self): if self.state == 'saved': diff --git a/lib/ansible/modules/cloud/vmware/vmware_dns_config.py b/lib/ansible/modules/cloud/vmware/vmware_dns_config.py index 8f1032887e2..f1834ce1a23 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_dns_config.py +++ b/lib/ansible/modules/cloud/vmware/vmware_dns_config.py @@ -108,7 +108,7 @@ def main(): host = get_all_objs(content, [vim.HostSystem]) if not host: module.fail_json(msg="Unable to locate Physical Host.") - host_system = host.keys()[0] + host_system = list(host)[0] changed = configure_dns(host_system, change_hostname_to, domainname, dns_servers) module.exit_json(changed=changed) except vmodl.RuntimeFault as runtime_fault: diff --git a/lib/ansible/modules/cloud/vmware/vmware_vmkernel_ip_config.py b/lib/ansible/modules/cloud/vmware/vmware_vmkernel_ip_config.py index 669b9308e46..b91bc97683c 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vmkernel_ip_config.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vmkernel_ip_config.py @@ -104,7 +104,7 @@ def main(): host = get_all_objs(content, [vim.HostSystem]) if not host: module.fail_json(msg="Unable to locate Physical Host.") - host_system = host.keys()[0] + host_system = list(host)[0] changed = configure_vmkernel_ip_address(host_system, vmk_name, ip_address, subnet_mask) module.exit_json(changed=changed) except vmodl.RuntimeFault as runtime_fault: diff --git a/lib/ansible/modules/cloud/vmware/vmware_vsan_cluster.py b/lib/ansible/modules/cloud/vmware/vmware_vsan_cluster.py index 223f251acbf..15d50a8479f 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vsan_cluster.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vsan_cluster.py @@ -108,7 +108,7 @@ def main(): host = get_all_objs(content, [vim.HostSystem]) if not host: module.fail_json(msg="Unable to locate Physical Host.") - host_system = host.keys()[0] + host_system = list(host)[0] changed, result, cluster_uuid = create_vsan_cluster(host_system, new_cluster_uuid) module.exit_json(changed=changed, result=result, cluster_uuid=cluster_uuid)