New Version for NAPALM 3 and Python 3.8
Dapsy2000 opened this issue · comments
Hello together,
Is it possible that you release a new version of the NAPALM community driver for the Cisco ASA platform, for example 0.1.2?
So that it can be installed with pip and and requirements.txt file.
After some changes I was able to use the NAPALM-ASA driver with NAPALM 3 and Python 3.8.
What I did:
Install NAPALM ASA via Pip
pip install git+https://github.com/napalm-automation-community/napalm-asa.git@develop
Changed asa.py to use with Python 3
nano .../lib/python3.8/site-packages/napalm_asa/asa.py
Changes I found here: https://github.com/napalm-automation-community/napalm-asa/pull/31/commits/8942fd6f7ecdb5b8f71425bdb70d86fa6c895d55
Changed asa.py again to use it with Python 3.8
Python 3.8 raised the following errors:
.../lib/python3.8/site-packages/napalm_asa/asa.py:58: SyntaxWarning: "is" with a literal. Did you mean "=="?
if token_request.status_code is 204 and 'X-Auth-Token' in token_request.headers.keys():
.../lib/python3.8/site-packages/napalm_asa/asa.py:74: SyntaxWarning: "is" with a literal. Did you mean "=="?
if token_delete_request.status_code is 204:
So I replaced "is" with "==".
After changing I was able to query the ASA Rest API:
# ipython
Python 3.8.6 (default, Sep 25 2020, 09:36:53)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.20.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from napalm import get_network_driver
...:
...: driver = get_network_driver("asa")
In [2]: device = driver(hostname='172.16.105.209', username='testuser', password='secret')
In [3]: device.open()
Out[3]: True
In [4]: facts = device.get_facts()
...: device.close()
Out[4]: True
In [5]: facts
Out[5]:
{'uptime': 183600,
'vendor': 'Cisco Systems',
'os_version': '9.12(4)10',
'serial_number': 'ABCDEFGH',
'model': 'ASA5512',
'hostname': 'ciscoasa',
'fqdn': 'ciscoasa',
'interface_list': ['Management0/0',
'GigabitEthernet0/0',
'GigabitEthernet0/1',
'GigabitEthernet0/2',
'GigabitEthernet0/3',
'GigabitEthernet0/4',
'GigabitEthernet0/5']}
In [6]:
Just pushed a new version to PyPI - https://pypi.org/project/napalm-asa/0.1.3/