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
This commit is contained in:
Abhijeet Kasurde 2019-12-07 01:53:12 +05:30 committed by Gonéri Le Bouder
parent b782227642
commit c97360d21f
2 changed files with 7 additions and 2 deletions

View file

@ -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).

View file

@ -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):