vmware: vmware_vm_inventory use port value when with_tags:True (#65568)

If user specifies a port number in vmware_vm_inventory plugin configuration,
then use that port to connect to vCenter rather than connecting to 443 which
is default port.

Fixes: #64096
pull/65620/head
Abhijeet Kasurde 5 years ago committed by Gonéri Le Bouder
parent b782227642
commit c97360d21f

@ -0,0 +1,2 @@
bugfixes:
- vmware_vm_inventory inventory plugin, use the port value while connecting to vCenter (https://github.com/ansible/ansible/issues/64096).

@ -163,12 +163,15 @@ class BaseVMwareInventory:
# Disable warning shown at stdout # Disable warning shown at stdout
requests.packages.urllib3.disable_warnings() requests.packages.urllib3.disable_warnings()
client = create_vsphere_client(server=self.hostname, server = self.hostname
if self.port:
server += ":" + str(self.port)
client = create_vsphere_client(server=server,
username=self.username, username=self.username,
password=self.password, password=self.password,
session=session) session=session)
if client is None: if client is None:
raise AnsibleError("Failed to login to %s using %s" % (self.hostname, self.username)) raise AnsibleError("Failed to login to %s using %s" % (server, self.username))
return client return client
def _login(self): def _login(self):

Loading…
Cancel
Save