napalm-automation-community / napalm-aos

NAPALM driver for Alcatel Lucent Enterprise AOS
Apache License 2.0
11 stars 13 forks source link

Py3 breakage? #37

Open FlorianHeigl opened 3 years ago

FlorianHeigl commented 3 years ago

I'm just a beginner learning the modules i'll need in the next months, but this seems to be a real issue. I would strongly suggest there's some issue in python compatibilty. I'm running netbox-docker by the way, and added this driver via pip3 install napalm-aos.

bash-5.1$ python3
Python 3.8.7 (default, Dec 26 2020, 08:45:55) 
[GCC 10.2.1 20201203] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> from napalm import get_network_driver
dr>>> driver = get_network_driver("procurve")
>>> driver = get_network_driver("onyx")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/napalm/base/__init__.py", line 97, in get_network_driver
    raise ModuleImportError(
napalm.base.exceptions.ModuleImportError: Cannot import "onyx". Is the library installed?
>>> driver = get_network_driver("aos")
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/napalm_aos/utils/AlcatelOS.py", line 7, in <module>
    from napalm.base.utils import py23_compat
ImportError: cannot import name 'py23_compat' from 'napalm.base.utils' (/usr/lib/python3.8/site-packages/napalm/base/utils/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/napalm_aos/aos.py", line 27, in <module>
    from napalm_aos.utils.AlcatelOS import *
  File "/usr/lib/python3.8/site-packages/napalm_aos/utils/AlcatelOS.py", line 13, in <module>
    from napalm_base.utils import py23_compat
ModuleNotFoundError: No module named 'napalm_base'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/napalm/base/__init__.py", line 95, in get_network_driver
    raise e
  File "/usr/lib/python3.8/site-packages/napalm/base/__init__.py", line 86, in get_network_driver
    module = importlib.import_module(module_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/python3.8/site-packages/napalm_aos/__init__.py", line 17, in <module>
    from napalm_aos.aos import AOSDriver
  File "/usr/lib/python3.8/site-packages/napalm_aos/aos.py", line 39, in <module>
    import napalm_base.constants as C
ModuleNotFoundError: No module named 'napalm_base'

the procurve driver just loaded a moment before!

jefvantongerloo commented 3 years ago

AOSDriver is not compatible with build-in Napalm 3.0 yet, you have to use Napalm version 3.2.1 This PR could fix the problem: https://github.com/napalm-automation-community/napalm-aos/pull/30

FlorianHeigl commented 3 years ago

@jefvantongerloo so nice of you to take time for a reply. I am a bit confused - isn't 3.2.1 newer than 3.0?

jefvantongerloo commented 3 years ago

Sorry typo, the compatible version is 2.3.1. When I use and test Napalm 3.0 I get the same error message.

FlorianHeigl commented 3 years ago

Thanks! Hopefully that PR will move forward some day.

napalmaos commented 3 years ago

Please help to test again with latest code

FlorianHeigl commented 3 years ago

It seems to do a lot better now:

floh@blackbox:~/git/netbox-docker$ docker exec -ti netbox-docker_netbox_1 bash
bash-5.1$ python3
Python 3.8.7 (default, Feb 19 2021, 01:11:05) 
[GCC 10.2.1 20201203] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> from napalm import get_network_driver

I need to replicate things in an env with AOS switches for actual testing, but it seems you solved the main py3 pain points already!

jefvantongerloo commented 3 years ago

@FlorianHeigl Tested through netbox-docker and confirmed working with Python3 and Netbox: image