Skip to content

Commit

Permalink
vdom optional argument is not ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurHlt committed Oct 26, 2021
1 parent 0952e5b commit 48c859d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions napalm_fortios/fortios.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="napalm-fortios",
version="0.2.0",
version="0.2.1",
packages=find_packages(),
author="Arthur Halet",
author_email="[email protected]",
Expand Down

0 comments on commit 48c859d

Please sign in to comment.