|
|
@ -230,7 +230,7 @@ class VMWareInventory(object):
|
|
|
|
config.read(vmware_ini_path)
|
|
|
|
config.read(vmware_ini_path)
|
|
|
|
|
|
|
|
|
|
|
|
# apply defaults
|
|
|
|
# apply defaults
|
|
|
|
for k,v in defaults['vmware'].iteritems():
|
|
|
|
for k,v in defaults['vmware'].items():
|
|
|
|
if not config.has_option('vmware', k):
|
|
|
|
if not config.has_option('vmware', k):
|
|
|
|
config.set('vmware', k, str(v))
|
|
|
|
config.set('vmware', k, str(v))
|
|
|
|
|
|
|
|
|
|
|
@ -401,7 +401,7 @@ class VMWareInventory(object):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Reset the inventory keys
|
|
|
|
# Reset the inventory keys
|
|
|
|
for k,v in name_mapping.iteritems():
|
|
|
|
for k,v in name_mapping.items():
|
|
|
|
|
|
|
|
|
|
|
|
if not host_mapping or not k in host_mapping:
|
|
|
|
if not host_mapping or not k in host_mapping:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
@ -434,7 +434,7 @@ class VMWareInventory(object):
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
self.debugl('filter: %s' % hf)
|
|
|
|
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.items():
|
|
|
|
if not v:
|
|
|
|
if not v:
|
|
|
|
# delete this host
|
|
|
|
# delete this host
|
|
|
|
inventory['all']['hosts'].remove(k)
|
|
|
|
inventory['all']['hosts'].remove(k)
|
|
|
@ -447,7 +447,7 @@ class VMWareInventory(object):
|
|
|
|
# Create groups
|
|
|
|
# Create groups
|
|
|
|
for gbp in self.groupby_patterns:
|
|
|
|
for gbp in self.groupby_patterns:
|
|
|
|
groupby_map = self.create_template_mapping(inventory, gbp)
|
|
|
|
groupby_map = self.create_template_mapping(inventory, gbp)
|
|
|
|
for k,v in groupby_map.iteritems():
|
|
|
|
for k,v in groupby_map.items():
|
|
|
|
if v not in inventory:
|
|
|
|
if v not in inventory:
|
|
|
|
inventory[v] = {}
|
|
|
|
inventory[v] = {}
|
|
|
|
inventory[v]['hosts'] = []
|
|
|
|
inventory[v]['hosts'] = []
|
|
|
@ -462,7 +462,7 @@ class VMWareInventory(object):
|
|
|
|
''' Return a hash of uuid to templated string from pattern '''
|
|
|
|
''' Return a hash of uuid to templated string from pattern '''
|
|
|
|
|
|
|
|
|
|
|
|
mapping = {}
|
|
|
|
mapping = {}
|
|
|
|
for k,v in inventory['_meta']['hostvars'].iteritems():
|
|
|
|
for k,v in inventory['_meta']['hostvars'].items():
|
|
|
|
t = jinja2.Template(pattern)
|
|
|
|
t = jinja2.Template(pattern)
|
|
|
|
newkey = None
|
|
|
|
newkey = None
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -671,7 +671,7 @@ class VMWareInventory(object):
|
|
|
|
# check if the machine has the name requested
|
|
|
|
# check if the machine has the name requested
|
|
|
|
keys = self.inventory['_meta']['hostvars'].keys()
|
|
|
|
keys = self.inventory['_meta']['hostvars'].keys()
|
|
|
|
match = None
|
|
|
|
match = None
|
|
|
|
for k,v in self.inventory['_meta']['hostvars'].iteritems():
|
|
|
|
for k,v in self.inventory['_meta']['hostvars'].items():
|
|
|
|
if self.inventory['_meta']['hostvars'][k]['name'] == self.args.host:
|
|
|
|
if self.inventory['_meta']['hostvars'][k]['name'] == self.args.host:
|
|
|
|
match = k
|
|
|
|
match = k
|
|
|
|
break
|
|
|
|
break
|
|
|
|