* Fix broken indentation in vmware inventory (#16177)

* Allow script to be a symlink without breaking ini path.
pull/16181/head
jctanner 9 years ago
parent f9803bfcc9
commit aa5c8ed86c

@ -172,7 +172,7 @@ class VMWareInventory(object):
''' Reads the settings from the vmware_inventory.ini file ''' ''' Reads the settings from the vmware_inventory.ini file '''
scriptbasename = os.path.realpath(__file__) scriptbasename = __file__
scriptbasename = os.path.basename(scriptbasename) scriptbasename = os.path.basename(scriptbasename)
scriptbasename = scriptbasename.replace('.py', '') scriptbasename = scriptbasename.replace('.py', '')
@ -181,7 +181,7 @@ class VMWareInventory(object):
'port': 443, 'port': 443,
'username': '', 'username': '',
'password': '', 'password': '',
'ini_path': os.path.join(os.path.dirname(os.path.realpath(__file__)), '%s.ini' % scriptbasename), 'ini_path': os.path.join(os.path.dirname(__file__), '%s.ini' % scriptbasename),
'cache_name': 'ansible-vmware', 'cache_name': 'ansible-vmware',
'cache_path': '~/.ansible/tmp', 'cache_path': '~/.ansible/tmp',
'cache_max_age': 3600, 'cache_max_age': 3600,
@ -279,17 +279,14 @@ class VMWareInventory(object):
context.verify_mode = ssl.CERT_NONE context.verify_mode = ssl.CERT_NONE
kwargs['sslContext'] = context kwargs['sslContext'] = context
self.debugl("### RUNNING WITHOUT VCR")
instances = self._get_instances(kwargs) instances = self._get_instances(kwargs)
self.debugl("### INSTANCES RETRIEVED") self.debugl("### INSTANCES RETRIEVED")
return instances return instances
def _get_instances(self, inkwargs): def _get_instances(self, inkwargs):
''' Make API calls without VCR fixtures ''' ''' Make API calls '''
instances = [] instances = []
si = SmartConnect(**inkwargs) si = SmartConnect(**inkwargs)
@ -399,6 +396,7 @@ class VMWareInventory(object):
for hf in self.host_filters: for hf in self.host_filters:
if not hf: if not hf:
continue continue
self.debugl('FILTER: %s' % hf)
filter_map = self.create_template_mapping(inventory, hf, dtype='boolean') filter_map = self.create_template_mapping(inventory, hf, dtype='boolean')
for k,v in filter_map.iteritems(): for k,v in filter_map.iteritems():
if not v: if not v:
@ -437,7 +435,9 @@ class VMWareInventory(object):
except Exception as e: except Exception as e:
self.debugl(str(e)) self.debugl(str(e))
#import epdb; epdb.st() #import epdb; epdb.st()
if dtype == 'integer': if not newkey:
continue
elif dtype == 'integer':
newkey = int(newkey) newkey = int(newkey)
elif dtype == 'boolean': elif dtype == 'boolean':
if newkey.lower() == 'false': if newkey.lower() == 'false':
@ -556,7 +556,6 @@ class VMWareInventory(object):
rdata = None rdata = None
return rdata return rdata
def get_host_info(self, host): def get_host_info(self, host):
''' Return hostvars for a single host ''' ''' Return hostvars for a single host '''

Loading…
Cancel
Save