Securize the index based lookup of dict.keys() (#54452)

pull/54456/head
Ludovic Rivallain 6 years ago committed by ansibot
parent 4a5b9bd8eb
commit cf2f13e05d

@ -114,7 +114,7 @@ class VMwareConfigurationBackup(PyVmomi):
self.module.fail_json(msg="Failed to find ESXi %s" % self.esxi_hostname) self.module.fail_json(msg="Failed to find ESXi %s" % self.esxi_hostname)
host_system = get_all_objs(self.content, [vim.HostSystem]) host_system = get_all_objs(self.content, [vim.HostSystem])
return host_system.keys()[0] return list(host_system)[0]
def process_state(self): def process_state(self):
if self.state == 'saved': if self.state == 'saved':

@ -108,7 +108,7 @@ def main():
host = get_all_objs(content, [vim.HostSystem]) host = get_all_objs(content, [vim.HostSystem])
if not host: if not host:
module.fail_json(msg="Unable to locate Physical 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) changed = configure_dns(host_system, change_hostname_to, domainname, dns_servers)
module.exit_json(changed=changed) module.exit_json(changed=changed)
except vmodl.RuntimeFault as runtime_fault: except vmodl.RuntimeFault as runtime_fault:

@ -104,7 +104,7 @@ def main():
host = get_all_objs(content, [vim.HostSystem]) host = get_all_objs(content, [vim.HostSystem])
if not host: if not host:
module.fail_json(msg="Unable to locate Physical 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) changed = configure_vmkernel_ip_address(host_system, vmk_name, ip_address, subnet_mask)
module.exit_json(changed=changed) module.exit_json(changed=changed)
except vmodl.RuntimeFault as runtime_fault: except vmodl.RuntimeFault as runtime_fault:

@ -108,7 +108,7 @@ def main():
host = get_all_objs(content, [vim.HostSystem]) host = get_all_objs(content, [vim.HostSystem])
if not host: if not host:
module.fail_json(msg="Unable to locate Physical 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) changed, result, cluster_uuid = create_vsan_cluster(host_system, new_cluster_uuid)
module.exit_json(changed=changed, result=result, cluster_uuid=cluster_uuid) module.exit_json(changed=changed, result=result, cluster_uuid=cluster_uuid)

Loading…
Cancel
Save