[Inventory] Cache the result of enumerating groups and host names

for `VariableManager._get_magic_variables()`.

This saves a lot of time re-iterating the nearly always constant global
list of groups and their members.

Generate once and cache, and invalidate cache in case `add_host:` or
`group_by:` are used.
This commit is contained in:
Tobias Wolf 2016-08-30 14:27:06 +02:00 committed by James Cammarata
parent 28227546fa
commit c23b11d212
4 changed files with 38 additions and 11 deletions

View file

@ -237,6 +237,7 @@ class TestStrategyBase(unittest.TestCase):
mock_inventory.get_host.side_effect = _get_host
mock_inventory.get_group.side_effect = _get_group
mock_inventory.clear_pattern_cache.return_value = None
mock_inventory.clear_group_dict_cache.return_value = None
mock_inventory.get_host_vars.return_value = {}
mock_var_mgr = MagicMock()