1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

VMware: Fix regression in get_all_host_objs (#36770)

If user does not specify esxi_hostname then module
fails to detect ESXi hostsystem from given configuration.
This fixes the regression in get_all_host_objs API by
getting first host managed object from list.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2018-03-28 00:27:17 +05:30 committed by ansibot
parent 4edcbeb62d
commit 8ce2ee0ebb

View file

@ -188,7 +188,13 @@ class PyVmomiHelper(PyVmomi):
self.vlan_id = self.params['vlan_id']
self.esxi_host_name = self.params['esxi_hostname']
self.esxi_host_obj = self.get_all_host_objs(esxi_host_name=self.esxi_host_name)[0]
hosts = self.get_all_host_objs(esxi_host_name=self.esxi_host_name)
if hosts:
self.esxi_host_obj = hosts[0]
else:
self.module.fail_json("Failed to get details of ESXi server."
" Please specify esxi_hostname.")
self.port_group_obj = self.get_port_group_by_name(host_system=self.esxi_host_obj, portgroup_name=self.port_group_name)
if not self.port_group_obj: