napalm-automation-community / napalm-fortios

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error with VDOM

htam-net opened this issue · comments

###Description of Issue/Question
When connecting to a fortigate firewall with VDOM, I fails to fetch facts with the exception : pyFG.exceptions.CommandExecutionException: Something happened when executing some commands on device :
get system performance status

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

  • Yes
  • No
    I use napalm through NORNIR

Setup

napalm-fortios version

(Paste verbatim output from pip freeze | grep napalm-fortios between quotes below)

napalm-fortios==0.4.1

FortiOS version

(Paste verbatim output from get sys status between quotes below)

v6.0.8

Steps to Reproduce the Issue

get facts through nornir

Error Traceback

(Paste the complete traceback of the exception between quotes below)

Traceback (most recent call last):
  File "/home/xxxx/.local/lib/python3.6/site-packages/nornir/core/task.py", line 99, in start
    r = self.task(self, **self.params)
  File "/home/xxxx/.local/lib/python3.6/site-packages/nornir_napalm/plugins/tasks/napalm_get.py", line 44, in napalm_get
    result[g] = method(**options)
  File "/home/xxxx/.local/lib/python3.6/site-packages/napalm_fortios/fortios.py", line 196, in get_facts
    vdom='global')
  File "/home/xxxx/.local/lib/python3.6/site-packages/napalm_fortios/fortios.py", line 89, in _get_command_with_vdom
    output = self._execute_command_with_vdom(cmd, vdom)
  File "/home/xxxx/.local/lib/python3.6/site-packages/napalm_fortios/fortios.py", line 85, in _execute_command_with_vdom
    return self.device.execute_command(command)
  File "/home/xxxx/.local/lib/python3.6/site-packages/pyFG/fortios.py", line 159, in execute_command
    raise exceptions.CommandExecutionException(msg)
pyFG.exceptions.CommandExecutionException: Something happened when executing some commands on device <device IP/hostname>
get system performance status
Command fail. Return code -61

On line 64, I change the following line from :

if vdom == 'global' and self.vdom is not None:

to :

if vdom == 'global' and vdom is not None:

and now it works. It seems that the variable self.vdom is not correctly evaluated.

I have specified additional option in nornir inventory, like:

connection_options:
    napalm:
        extras:
           optional_args:
              fortios_vdom: global

and now it works without the modification