* Fix broken indentation in vmware inventory (#16177)

* Allow script to be a symlink without breaking ini path.
This commit is contained in:
jctanner 2016-06-07 18:10:57 -04:00
parent f9803bfcc9
commit aa5c8ed86c

View file

@ -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':
@ -484,7 +484,7 @@ class VMWareInventory(object):
if self.lowerkeys: if self.lowerkeys:
k = k.lower() k = k.lower()
rdata[k] = self._process_object_types(v, level=level) rdata[k] = self._process_object_types(v, level=level)
else: else:
@ -511,7 +511,7 @@ class VMWareInventory(object):
if self.lowerkeys: if self.lowerkeys:
method = method.lower() method = method.lower()
rdata[method] = self._process_object_types(methodToCall, level=level) rdata[method] = self._process_object_types(methodToCall, level=level)
return rdata return rdata
@ -554,8 +554,7 @@ class VMWareInventory(object):
if not rdata: if not rdata:
rdata = None rdata = None
return rdata return rdata
def get_host_info(self, host): def get_host_info(self, host):