add inventory caching & use in virtualbox inventory plugin (#34510)

* Inventory caching

* Add inventory caching for virtualbox

* Don't populate cache for virtualbox with stdout, use a dict of inventory instead

* Fix error creating the cache dir if it doesn't exist

* Keep cache default False and set to True in VariableManager __init__

* Check all groups before determining if a host is ungrouped.
This commit is contained in:
Sloane Hertel 2018-01-22 19:33:14 -05:00 committed by Ryan Brown
commit 4a1cc661c4
5 changed files with 153 additions and 16 deletions

View file

@ -142,7 +142,7 @@ class InventoryManager(object):
self._sources = sources
# get to work!
self.parse_sources()
self.parse_sources(cache=True)
@property
def localhost(self):
@ -234,7 +234,7 @@ class InventoryManager(object):
# recursively deal with directory entries
fullpath = os.path.join(b_source, i)
parsed_this_one = self.parse_source(to_native(fullpath))
parsed_this_one = self.parse_source(to_native(fullpath), cache=cache)
display.debug(u'parsed %s as %s' % (fullpath, parsed_this_one))
if not parsed:
parsed = parsed_this_one