Inventory and varmanager updates (#32054)
* better parsing erros * fix inventorydata serialization * dicts fixpull/4420/head
parent
e70c0afc5e
commit
c3564096cd
|
@ -62,11 +62,21 @@ class InventoryData(object):
|
||||||
self.add_child('all', 'ungrouped')
|
self.add_child('all', 'ungrouped')
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
data = dict()
|
self._groups_dict_cache = None
|
||||||
|
data = {
|
||||||
|
'groups': self.groups,
|
||||||
|
'hosts': self.hosts,
|
||||||
|
'local': self.locahost,
|
||||||
|
'source': self.current_source,
|
||||||
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def deserialize(self, data):
|
def deserialize(self, data):
|
||||||
pass
|
self._groups_dict_cache = {}
|
||||||
|
self.hosts = data.get('hosts')
|
||||||
|
self.groups = data.get('groups')
|
||||||
|
self.localhost = data.get('local')
|
||||||
|
self.current_source = data.get('source')
|
||||||
|
|
||||||
def _create_implicit_localhost(self, pattern):
|
def _create_implicit_localhost(self, pattern):
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,10 @@ class InventoryManager(object):
|
||||||
display.vvv('Parsed %s inventory source with %s plugin' % (to_native(source), plugin_name))
|
display.vvv('Parsed %s inventory source with %s plugin' % (to_native(source), plugin_name))
|
||||||
break
|
break
|
||||||
except AnsibleParserError as e:
|
except AnsibleParserError as e:
|
||||||
display.debug('%s did not meet %s requirements' % (to_native(source), plugin_name))
|
display.debug('%s was not parsable by %s' % (to_native(source), plugin_name))
|
||||||
|
failures.append({'src': source, 'plugin': plugin_name, 'exc': e})
|
||||||
|
except Exception as e:
|
||||||
|
display.debug('%s failed to parse %s' % (plugin_name, to_native(source)))
|
||||||
failures.append({'src': source, 'plugin': plugin_name, 'exc': e})
|
failures.append({'src': source, 'plugin': plugin_name, 'exc': e})
|
||||||
else:
|
else:
|
||||||
display.debug('%s did not meet %s requirements' % (to_native(source), plugin_name))
|
display.debug('%s did not meet %s requirements' % (to_native(source), plugin_name))
|
||||||
|
@ -281,7 +284,6 @@ class InventoryManager(object):
|
||||||
for fail in failures:
|
for fail in failures:
|
||||||
display.warning('\n* Failed to parse %s with %s plugin: %s' % (to_native(fail['src']), fail['plugin'], to_native(fail['exc'])))
|
display.warning('\n* Failed to parse %s with %s plugin: %s' % (to_native(fail['src']), fail['plugin'], to_native(fail['exc'])))
|
||||||
display.vvv(fail['exc'].tb)
|
display.vvv(fail['exc'].tb)
|
||||||
|
|
||||||
if not parsed:
|
if not parsed:
|
||||||
display.warning("Unable to parse %s as an inventory source" % to_native(source))
|
display.warning("Unable to parse %s as an inventory source" % to_native(source))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue