From 0141c0c33653219ffd5f41e9c756c83d1c50236a Mon Sep 17 00:00:00 2001 From: Damien Date: Wed, 22 Feb 2017 13:45:49 -0800 Subject: [PATCH] inventory/Aos - Add session information to group all variables (#21719) * Add aos.session information to group all variables * Revert IP address change * Remove space in empty line for PEP8 --- contrib/inventory/apstra_aos.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/contrib/inventory/apstra_aos.py b/contrib/inventory/apstra_aos.py index 685414f4279..d6694742c43 100755 --- a/contrib/inventory/apstra_aos.py +++ b/contrib/inventory/apstra_aos.py @@ -310,6 +310,9 @@ class AosInventory(object): aos.login() + # Save session information in variables of group all + self.add_var_to_group('all', 'aos_session', aos.session) + # ---------------------------------------------------- # Build the inventory # 2 modes are supported: device based or blueprint based @@ -482,7 +485,6 @@ class AosInventory(object): except: pass - def parse_cli_args(self): """ Command line argument processing """ @@ -517,6 +519,16 @@ class AosInventory(object): self.inventory['_meta']['hostvars'][host][var] = value + def add_var_to_group(self, group, var, value): + + # Check if the group exist, if not initialize it + if group not in self.inventory.keys(): + self.inventory[group] = {} + self.inventory[group]['hosts'] = [] + self.inventory[group]['vars'] = {} + + self.inventory[group]['vars'][var] = value + def add_device_facts_to_var(self, device_name, device): # Populate variables for this host