From 48c859d6dee5ffdf8cea5267007e0e95359d84bc Mon Sep 17 00:00:00 2001 From: ArthurHlt Date: Tue, 26 Oct 2021 10:20:37 +0200 Subject: [PATCH] vdom optional argument is not ignored --- napalm_fortios/fortios.py | 16 ++++++++++++---- setup.py | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/napalm_fortios/fortios.py b/napalm_fortios/fortios.py index 1e62d62..ea0a9a9 100644 --- a/napalm_fortios/fortios.py +++ b/napalm_fortios/fortios.py @@ -113,16 +113,24 @@ def get_facts(self): } def get_firewall_policies(self): - policies_fg_stats = self.device.monitor('firewall', 'policy', vdom=self.vdom, - parameters={'global': 1, 'exclude-default-values': 1}) + params = {'exclude-default-values': 1} + if self.vdom is None: + params['global'] = 1 + policies_fg_stats = self.device.monitor('firewall', 'policy', vdom=self.vdom, parameters=params) policies_stats = {} + # make single vdom response compatible with global multiple vdom response + if self.vdom is not None: + policies_fg_stats = [policies_fg_stats] + for policies_fg_vdom_stats in policies_fg_stats: for stats in policies_fg_vdom_stats['results']: policies_stats[stats['policyid']] = stats - policies_fg = self.device.get('firewall', 'policy', vdom=self.vdom, - parameters={'global': 1, 'exclude-default-values': 1}) + policies_fg = self.device.get('firewall', 'policy', vdom=self.vdom, parameters=params) position = 1 + # make single vdom response compatible with global multiple vdom response + if self.vdom is not None: + policies_fg = [policies_fg] firewall_policies = {} for policies_vdom in policies_fg: for policy_fg in policies_vdom['results']: diff --git a/setup.py b/setup.py index e74987d..02a3280 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="napalm-fortios", - version="0.2.0", + version="0.2.1", packages=find_packages(), author="Arthur Halet", author_email="arthur.halet@orange.com",