napalm-automation-community / napalm-panos

NAPALM driver for PAN-OS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ModuleImportError "napalm.base.base.NetworkDriver" found in "napalm.panos"

netwninja opened this issue · comments

Description of Issue/Question

Trying to run python script against Palo Alto FW node.

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

  • [X ] Yes
  • No

Setup

napalm ---------PA-FW

napalm-panos version

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

root@napalm:~# pip freeze | grep napalm

napalm==2.5.0
napalm-base==1.0.0
napalm-eos==0.6.1
napalm-ios==0.8.1
napalm-panos==0.5.2


PanOS version

(Paste verbatim output from show system info between quotes below)

ansible@PA1> show system info | match sw
sw-version: 7.0.1
ansible@PA1> 

Steps to Reproduce the Issue

pip install napalm-panos
Then use the below python script
I did trying to close the DEV and master from github and then "pip install ./", no luck.

import json
from napalm import get_network_driver
driver = get_network_driver('panos')
dev = driver(hostname='eos-a', username='ansible', password='ansible123')
dev.open()
dev_info = dev.get_facts()
dev.close()
print(json.dumps(dev_info, sort_keys=True, indent=4))

Error Traceback

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

Traceback (most recent call last):
  File "pan.py", line 3, in <module>
    driver = get_network_driver('panos')
  File "/usr/local/lib/python2.7/dist-packages/napalm/base/__init__.py", line 92, in get_network_driver
    module = importlib.import_module(module_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/dist-packages/napalm_panos/__init__.py", line 21, in <module>
    from napalm_panos.panos import PANOSDriver
  File "/usr/local/lib/python2.7/dist-packages/napalm_panos/panos.py", line 19, in <module>
    import pan.xapi
  File "/root/pan.py", line 3, in <module>
    driver = get_network_driver('panos')
  File "/usr/local/lib/python2.7/dist-packages/napalm/base/__init__.py", line 116, in get_network_driver
    install_name=module_install_name
napalm.base.exceptions.ModuleImportError: No class inheriting "napalm.base.base.NetworkDriver" found in "napalm.panos".

I was referring this old issue

https://github.com/napalm-automation-community/napalm-panos/issues/50

seems like you are failing on importing pan xapi, can you indicate which version you have there? It is possible they have changed their structure, so maybe play around with different pan xapi versions as well.

Actually, did you name your python file pan.py?

Yea, a lot has changed in the last 90 seconds. Fairly certain that is the issue, you named your script pan.py, which is now in you python path, and attempting to import there and it dies. If somehow that is incorrect, feel free to reopen a ticket.

I have corrected the namespace issue.

NEW TRACEBACK

Traceback (most recent call last):
  File "pan1.py", line 6, in <module>
    dev_info = dev.get_facts()
  File "/usr/local/lib/python2.7/dist-packages/napalm_panos/panos.py", line 392, in get_facts
    facts['interface_list'] = self._extract_interface_list()
  File "/usr/local/lib/python2.7/dist-packages/napalm_panos/panos.py", line 363, in _extract_interface_list
    for entry_contents in entry.values():
AttributeError: 'NoneType' object has no attribute 'values'

SCRIPT

import json
from napalm import get_network_driver
driver = get_network_driver('panos')
dev = driver(hostname='10.0.0.189', username='ansible', password='ansible123')
dev.open()
dev_info = dev.get_facts()
dev.close()
print(json.dumps(dev_info, sort_keys=True, indent=4))