From c74e972691e81c0a373fc8bebc1c4f0f9f6b52af Mon Sep 17 00:00:00 2001 From: Dave Date: Mon, 30 Jan 2023 08:48:15 -0500 Subject: [PATCH 01/36] adding read_timeout_override netmiko option --- napalm_s350/s350.py | 1 + 1 file changed, 1 insertion(+) diff --git a/napalm_s350/s350.py b/napalm_s350/s350.py index 6763c25..3218b95 100644 --- a/napalm_s350/s350.py +++ b/napalm_s350/s350.py @@ -77,6 +77,7 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None) "alt_key_file": "", "ssh_config_file": None, "allow_agent": False, + "read_timeout_override": None, } # Allow for passing additional Netmiko arguments From a0b28c967805b1c22bfff72286cbee56ab56e814 Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 16 Feb 2023 16:19:07 -0500 Subject: [PATCH 02/36] adding netmiko option session_log --- napalm_s350/s350.py | 1 + 1 file changed, 1 insertion(+) diff --git a/napalm_s350/s350.py b/napalm_s350/s350.py index 3218b95..e2111fc 100644 --- a/napalm_s350/s350.py +++ b/napalm_s350/s350.py @@ -77,6 +77,7 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None) "alt_key_file": "", "ssh_config_file": None, "allow_agent": False, + "session_log": None, "read_timeout_override": None, } From 7206990ee1b491a17ad85eff1a082a5015a596ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 15:48:51 +0000 Subject: [PATCH 03/36] Bump black from 20.8b1 to 24.3.0 Bumps [black](https://github.com/psf/black) from 20.8b1 to 24.3.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/commits/24.3.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index becc136..2b308d0 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,4 @@ -black==20.8b1 +black==24.3.0 coveralls==2.1.2 ddt==1.4.1 flake8-import-order==0.18.1 From 593f998376ef8d7a4005e3fe883937052537f8fb Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 12:55:55 +0100 Subject: [PATCH 04/36] remove demjson - blocking tests --- requirements-dev.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 2b308d0..c8f8bbb 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -9,4 +9,3 @@ pytest-pythonpath==0.7.3 pylama==7.7.1 mock==4.0.2 tox==3.20.1 -demjson From 7023c590e453c085c9d62b18ab0d4582d6ba8d61 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 14:00:02 +0100 Subject: [PATCH 05/36] FIX minor formating fixes raised by pylama --- napalm_s350/s350.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/napalm_s350/s350.py b/napalm_s350/s350.py index e2111fc..7c851b6 100644 --- a/napalm_s350/s350.py +++ b/napalm_s350/s350.py @@ -366,7 +366,7 @@ def _get_facts_uptime(self, show_sys): return uptime_str def _get_facts_parse_inventory(self, show_inventory): - """ inventory can list more modules/devices """ + """inventory can list more modules/devices""" # make 1 module 1 line show_inventory = re.sub(r"\nPID", " PID", show_inventory, re.M) # delete empty lines @@ -525,7 +525,7 @@ def get_interfaces_ip(self): return interfaces def _get_ip_int_line_to_fields(self, line, fields_end): - """ dynamic fields lenghts """ + """dynamic fields lenghts""" line_elems = {} index = 0 f_start = 0 @@ -536,7 +536,7 @@ def _get_ip_int_line_to_fields(self, line, fields_end): return line_elems def _get_ip_int_fields_end(self, dashline): - """ fields length are diferent device to device, detect them on horizontal lin """ + """fields length are diferent device to device, detect them on horizontal line""" fields_end = [m.start() for m in re.finditer(" ", dashline.strip())] # fields_position.insert(0,0) @@ -590,7 +590,7 @@ def get_lldp_neighbors(self): return neighbors def _get_lldp_neighbors_line_to_fields(self, line, fields_end): - """ dynamic fields lenghts """ + """dynamic fields lenghts""" line_elems = {} index = 0 f_start = 0 @@ -601,7 +601,7 @@ def _get_lldp_neighbors_line_to_fields(self, line, fields_end): return line_elems def _get_lldp_neighbors_fields_end(self, dashline): - """ fields length are diferent device to device, detect them on horizontal lin """ + """fields length are diferent device to device, detect them on horizontal line""" fields_end = [m.start() for m in re.finditer(" ", dashline)] fields_end.append(len(dashline)) From 9787347098d10435ac260081eda27c1a79e11ca0 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 14:01:31 +0100 Subject: [PATCH 06/36] FIX limit napalm and netmiko o version 3.*, soften version requirements --- requirements-dev.txt | 25 ++++++++++++++----------- requirements.txt | 4 ++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index c8f8bbb..69b67af 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,11 +1,14 @@ -black==24.3.0 -coveralls==2.1.2 -ddt==1.4.1 -flake8-import-order==0.18.1 -pytest==5.4.3 -pytest-cov==2.10.1 -pytest-json==0.4.0 -pytest-pythonpath==0.7.3 -pylama==7.7.1 -mock==4.0.2 -tox==3.20.1 +napalm>=3.0.0, <4.0.0 +netmiko>=3.1.0, <4.0.0 +black +coveralls +ddt +flake8-import-order +pytest==6.2.5 +pytest-cov +pytest-json +pytest-pythonpath +pylama +pyflakes==2.4.0 #prevent problems +mock +tox diff --git a/requirements.txt b/requirements.txt index c17be3f..405545b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -napalm>=3.0.0 -netmiko>=3.1.0 +napalm>=3.0.0, <4.0.0 +netmiko>=3.1.0, <4.0.0 netaddr From 5049dcdfd68119fb95535d4cb62f39d8340ed92e Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 14:04:04 +0100 Subject: [PATCH 07/36] FIX minor formating fixes raised by pylama --- test/unit/conftest.py | 1 + test/unit/test_getters.py | 1 + 2 files changed, 2 insertions(+) diff --git a/test/unit/conftest.py b/test/unit/conftest.py index 6f9fb30..bd99cb3 100644 --- a/test/unit/conftest.py +++ b/test/unit/conftest.py @@ -1,4 +1,5 @@ """Test fixtures.""" + from builtins import super import pytest diff --git a/test/unit/test_getters.py b/test/unit/test_getters.py index 5f87d9e..e470888 100644 --- a/test/unit/test_getters.py +++ b/test/unit/test_getters.py @@ -1,4 +1,5 @@ """Tests for getters.""" + from napalm.base.test.getters import BaseTestGetters import pytest From 7a32595838ecdaeaf18ff451d535985bbd27f173 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 14:05:20 +0100 Subject: [PATCH 08/36] Allow testing on all supported Py versions --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 55340d6..d6c5f93 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] #envlist = py3{6,7,8},black,pylama,sphinx -envlist = py3{6,7,8},pylama,black +envlist = py3{8,9,10,11,12},pylama,black skip_missing_interpreters = true [testenv] From 751126a1f508be863f2106ee70d9399420ff3fd6 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 14:07:10 +0100 Subject: [PATCH 09/36] FIX add platform name to driver s350 --- napalm_s350/s350.py | 1 + 1 file changed, 1 insertion(+) diff --git a/napalm_s350/s350.py b/napalm_s350/s350.py index 7c851b6..2fd50e9 100644 --- a/napalm_s350/s350.py +++ b/napalm_s350/s350.py @@ -89,6 +89,7 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None) except KeyError: pass + self.platform = "s350" self.port = optional_args.get("port", 22) self.device = None self.force_no_enable = optional_args.get("force_no_enable", False) From 7929c6411c40decb956613310958a08482d63917 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 14:08:17 +0100 Subject: [PATCH 10/36] FIX force interface speed as a float --- napalm_s350/s350.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napalm_s350/s350.py b/napalm_s350/s350.py index 2fd50e9..f6c77d7 100644 --- a/napalm_s350/s350.py +++ b/napalm_s350/s350.py @@ -474,7 +474,7 @@ def get_interfaces(self): entry = { "is_up": is_up, "is_enabled": is_enabled, - "speed": speed, + "speed": float(speed), "mtu": mtu, "last_flapped": -1.0, "description": description, From de857ba48a0d7af1a07f7225af5fa5ff3b4d1558 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 14:22:01 +0100 Subject: [PATCH 11/36] Update information about required versions to Py3.8+ and napalm 3 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 635c88d..d5bc5ad 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ PyPi: [![Upload](https://github.com/napalm-automation-community/napalm-s350/work ## Requirements -Python 3.6+, napalm 3+ +Python 3.8+, napalm 3 ## Installation From 7e1d345af6b65f307b60b4de2bde8c16e249fb24 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 14:30:07 +0100 Subject: [PATCH 12/36] Add scheduled check on develop branch --- .github/workflows/TestBeforePush.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/TestBeforePush.yml b/.github/workflows/TestBeforePush.yml index 166eace..d466542 100644 --- a/.github/workflows/TestBeforePush.yml +++ b/.github/workflows/TestBeforePush.yml @@ -11,7 +11,9 @@ on: branches: - develop - master - + # check every 14 days + schedule: + - cron: '0 6 5,20 * *' jobs: build: From e939d9e73deb8a97622233fa5a75f60a7993c636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kl=C3=ADma?= Date: Tue, 26 Mar 2024 15:34:19 +0100 Subject: [PATCH 13/36] Update pkg version in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 01362eb..8125d10 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="napalm-s350", - version="0.3.1", + version="0.3.2", packages=find_packages(exclude=("test*",)), author="Jasper Lievisse Adriaanse, Petr Klíma, Daniel Bacher", author_email="j@jasper.la, qaxi@seznam.cz, mail@phill93.de", From 5a9bff81b9b4db58f37a173a8a5519abad4a7c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kl=C3=ADma?= Date: Tue, 26 Mar 2024 15:42:47 +0100 Subject: [PATCH 14/36] Update PublishToPIP.yml for manual run --- .github/workflows/PublishToPIP.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/PublishToPIP.yml b/.github/workflows/PublishToPIP.yml index bfa630c..5073ee2 100644 --- a/.github/workflows/PublishToPIP.yml +++ b/.github/workflows/PublishToPIP.yml @@ -6,6 +6,7 @@ name: Publish Python Package to PyPi.org on: release: types: [created] + workflow_dispatch: jobs: deploy: From f3d13a5e3111a1e209b242527b335bf5d17746ee Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 16:29:04 +0100 Subject: [PATCH 15/36] Napalm 4 compatibility, newer dependencies --- napalm_s350/s350.py | 17 +++++------------ requirements-dev.txt | 12 +++++++----- requirements.txt | 6 +++--- setup.py | 9 ++++++--- tox.ini | 9 +-------- 5 files changed, 22 insertions(+), 31 deletions(-) diff --git a/napalm_s350/s350.py b/napalm_s350/s350.py index f6c77d7..eb3a9b8 100644 --- a/napalm_s350/s350.py +++ b/napalm_s350/s350.py @@ -45,6 +45,8 @@ "te": "TengigabitEthernet", } +from typing import List + class S350Driver(NetworkDriver): """Napalm driver for S350.""" @@ -121,16 +123,6 @@ def close(self): """Close the connection to the device.""" self.device.disconnect() - def cli(self, commands): - output = {} - try: - for cmd in commands: - output[cmd] = self.device.send_command(cmd) - - return output - except (socket.error, EOFError) as e: - raise ConnectionClosedException(str(e)) - def _send_command(self, command): """Wrapper for self.device.send.command(). @@ -291,7 +283,8 @@ def get_facts(self): fqdn = "{0}.{1}".format(hostname, domainname) # interface_list - interfaces = [] + + interfaces: List[str] = [] show_int_st = show_int_st.strip() # remove the header information show_int_st = re.sub( @@ -312,7 +305,7 @@ def get_facts(self): "model": str(model), "os_version": str(os_version), "serial_number": str(serial_number), - "uptime": uptime, + "uptime": float(uptime), "vendor": "Cisco", } diff --git a/requirements-dev.txt b/requirements-dev.txt index 69b67af..a8b9916 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,14 +1,16 @@ -napalm>=3.0.0, <4.0.0 -netmiko>=3.1.0, <4.0.0 -black +napalm<=4.0.0 +netmiko<=4.0.0 +black<=24.3.0 # CVE-2024-21503 coveralls ddt flake8-import-order -pytest==6.2.5 +# pytest==6.2.5 +pytest pytest-cov pytest-json pytest-pythonpath pylama -pyflakes==2.4.0 #prevent problems +# pyflakes==2.4.0 #prevent problems +pyflakes mock tox diff --git a/requirements.txt b/requirements.txt index 405545b..be9a920 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -napalm>=3.0.0, <4.0.0 -netmiko>=3.1.0, <4.0.0 -netaddr +napalm<=4.0.0 +netmiko<=4.0.0 +netaddr<=1.2.1 diff --git a/setup.py b/setup.py index 01362eb..66ede45 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="napalm-s350", - version="0.3.1", + version="0.4.0", packages=find_packages(exclude=("test*",)), author="Jasper Lievisse Adriaanse, Petr Klíma, Daniel Bacher", author_email="j@jasper.la, qaxi@seznam.cz, mail@phill93.de", @@ -25,9 +25,12 @@ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Operating System :: POSIX :: Linux", "Operating System :: MacOS", ], diff --git a/tox.ini b/tox.ini index d6c5f93..c938707 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,5 @@ [tox] -#envlist = py3{6,7,8},black,pylama,sphinx -envlist = py3{8,9,10,11,12},pylama,black +envlist = py3{8,9,10,11,12,13},pylama,black skip_missing_interpreters = true [testenv] @@ -20,9 +19,3 @@ commands = commands = pylama . -[testenv:sphinx] -commands = - make doctest - -whitelist_externals = - make From cfd11697607e5115c9e5e5b325ac6a9cb17e5811 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 16:35:18 +0100 Subject: [PATCH 16/36] Full tox testing on "develop" and "master" branch. --- .github/workflows/TestBeforePush.yml | 30 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/TestBeforePush.yml b/.github/workflows/TestBeforePush.yml index d466542..d0d9c67 100644 --- a/.github/workflows/TestBeforePush.yml +++ b/.github/workflows/TestBeforePush.yml @@ -19,19 +19,23 @@ jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["pypy3.9", "pypy3.12", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.x - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi - - name: Test with tox - run: | - tox + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi + + - name: Test with tox + run: | + tox From 7009fc9121830781a70c905a21452df6ffd0ff53 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 16:50:48 +0100 Subject: [PATCH 17/36] Remove Py13 - too early --- .github/workflows/TestBeforePush.yml | 5 +++-- tox.ini | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/TestBeforePush.yml b/.github/workflows/TestBeforePush.yml index d0d9c67..e92e6f5 100644 --- a/.github/workflows/TestBeforePush.yml +++ b/.github/workflows/TestBeforePush.yml @@ -7,6 +7,7 @@ on: push: branches: - develop + - master pull_request: branches: - develop @@ -21,12 +22,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["pypy3.9", "pypy3.12", "3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["pypy3.9", "pypy3.10", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} diff --git a/tox.ini b/tox.ini index c938707..9d53f92 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3{8,9,10,11,12,13},pylama,black +envlist = py3{8,9,10,11,12},pylama,black skip_missing_interpreters = true [testenv] From 62f6ab4cc33f5ab59a922d2b09c51dc39a59766d Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 17:07:14 +0100 Subject: [PATCH 18/36] Do not test on PyPy, local test with local Py version only --- .github/workflows/TestBeforePush.yml | 2 +- tox.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/TestBeforePush.yml b/.github/workflows/TestBeforePush.yml index e92e6f5..376808e 100644 --- a/.github/workflows/TestBeforePush.yml +++ b/.github/workflows/TestBeforePush.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["pypy3.9", "pypy3.10", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 diff --git a/tox.ini b/tox.ini index 9d53f92..6b9fe5c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3{8,9,10,11,12},pylama,black +envlist = py,pylama,black skip_missing_interpreters = true [testenv] From a4f0473fd25141c21e48a4e19ed0a7e6760becd2 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 17:17:47 +0100 Subject: [PATCH 19/36] CI ThoroughTest for branches develop and master --- .github/workflows/ThoroughTest.yml | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/ThoroughTest.yml diff --git a/.github/workflows/ThoroughTest.yml b/.github/workflows/ThoroughTest.yml new file mode 100644 index 0000000..ba164fd --- /dev/null +++ b/.github/workflows/ThoroughTest.yml @@ -0,0 +1,42 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Thorough Test + +on: + push: + branches: + - develop + - master + pull_request: + branches: + - develop + - master + # check every 14 days + schedule: + - cron: '0 6 5,20 * *' +jobs: + + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi + + - name: Test with tox + run: | + tox From 7a8fbac693bc97771c929ddae7b463df3ad89259 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 17:18:31 +0100 Subject: [PATCH 20/36] CI FastTest for all other branches. --- .github/workflows/FastTest.yml | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/FastTest.yml diff --git a/.github/workflows/FastTest.yml b/.github/workflows/FastTest.yml new file mode 100644 index 0000000..f069f71 --- /dev/null +++ b/.github/workflows/FastTest.yml @@ -0,0 +1,40 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Fast Test + +on: + push: + branches-ignore: + - develop + - master + pull_request: + branches-ignore: + - develop + - master + +jobs: + + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ "3.11" ] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi + + - name: Test with tox + run: | + tox From d6dd81ea81ab3fe5875aeb9ad2be2e7ffa0df69f Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 17:19:12 +0100 Subject: [PATCH 21/36] CI rename legacy jobs --- .github/workflows/TestBeforePush.yml | 42 ---------------------------- 1 file changed, 42 deletions(-) delete mode 100644 .github/workflows/TestBeforePush.yml diff --git a/.github/workflows/TestBeforePush.yml b/.github/workflows/TestBeforePush.yml deleted file mode 100644 index 376808e..0000000 --- a/.github/workflows/TestBeforePush.yml +++ /dev/null @@ -1,42 +0,0 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -name: Test before push - -on: - push: - branches: - - develop - - master - pull_request: - branches: - - develop - - master - # check every 14 days - schedule: - - cron: '0 6 5,20 * *' -jobs: - - build: - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi - - - name: Test with tox - run: | - tox From 9025b0f43480bbc645f4d7651b4b95da9a051277 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 26 Mar 2024 17:20:36 +0100 Subject: [PATCH 22/36] CI renaname job --- .github/workflows/FastTest.yml | 2 +- .github/workflows/ThoroughTest.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/FastTest.yml b/.github/workflows/FastTest.yml index f069f71..024c538 100644 --- a/.github/workflows/FastTest.yml +++ b/.github/workflows/FastTest.yml @@ -15,7 +15,7 @@ on: jobs: - build: + tox_test: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/ThoroughTest.yml b/.github/workflows/ThoroughTest.yml index ba164fd..dc8ff30 100644 --- a/.github/workflows/ThoroughTest.yml +++ b/.github/workflows/ThoroughTest.yml @@ -17,7 +17,7 @@ on: - cron: '0 6 5,20 * *' jobs: - build: + tox_test: runs-on: ubuntu-latest strategy: From fc9e83c4bb6b3a20f4030c78fc3e5ac57df7932f Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Wed, 27 Mar 2024 09:07:39 +0100 Subject: [PATCH 23/36] Updata docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d5bc5ad..760050b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ PyPi: [![Upload](https://github.com/napalm-automation-community/napalm-s350/work ## Requirements -Python 3.8+, napalm 3 +Python 3.8+, napalm 4 ## Installation From 08d9a45e77860a7f2f3676dffd80d67126ee332b Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Wed, 27 Mar 2024 09:09:40 +0100 Subject: [PATCH 24/36] Shorten name of publish workflow --- .github/workflows/PublishToPIP.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/PublishToPIP.yml b/.github/workflows/PublishToPIP.yml index bfa630c..830d292 100644 --- a/.github/workflows/PublishToPIP.yml +++ b/.github/workflows/PublishToPIP.yml @@ -1,7 +1,7 @@ # This workflows will upload a Python Package using Twine when a release is created # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries -name: Publish Python Package to PyPi.org +name: Publish To PyPi.org on: release: From 3a63056fa8cc952f550ffce35a9b8a540ab6d57d Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Wed, 27 Mar 2024 09:14:14 +0100 Subject: [PATCH 25/36] Check syntax for Py3.12 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 6b9fe5c..76953d8 100644 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,7 @@ commands = [testenv:black] commands = - black --check --target-version py36 --line-length 100 --color --diff . + black --check --target-version py312 --line-length 100 --color --diff . [testenv:pylama] commands = From 86a7689d6da45dd994d8da154527a0753f269d09 Mon Sep 17 00:00:00 2001 From: Dave Date: Wed, 27 Mar 2024 23:54:55 -0400 Subject: [PATCH 26/36] use netmiko_args --- napalm_s350/s350.py | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/napalm_s350/s350.py b/napalm_s350/s350.py index eb3a9b8..df7539d 100644 --- a/napalm_s350/s350.py +++ b/napalm_s350/s350.py @@ -33,6 +33,7 @@ ConnectionClosedException, ) from napalm.base.helpers import canonical_interface_name +from napalm.base.netmiko_helpers import netmiko_args import napalm.base.constants as C import napalm.base.canonical_map @@ -65,31 +66,7 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None) self._dest_file_system = optional_args.get("dest_file_system", None) # Netmiko possible arguments - netmiko_argument_map = { - "port": None, - "secret": "", - "verbose": False, - "keepalive": 30, - "global_delay_factor": 1, - "use_keys": False, - "key_file": None, - "ssh_strict": False, - "system_host_keys": False, - "alt_host_keys": False, - "alt_key_file": "", - "ssh_config_file": None, - "allow_agent": False, - "session_log": None, - "read_timeout_override": None, - } - - # Allow for passing additional Netmiko arguments - self.netmiko_optional_args = {} - for k, v in netmiko_argument_map.items(): - try: - self.netmiko_optional_args[k] = optional_args[k] - except KeyError: - pass + self.netmiko_optional_args = netmiko_args(optional_args) self.platform = "s350" self.port = optional_args.get("port", 22) From c4a36239f6fa7719c2592e6e4b4fe3a01b2c0127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kl=C3=ADma?= Date: Fri, 29 Mar 2024 15:51:28 +0100 Subject: [PATCH 27/36] Add changes for 4.1.0 (#89) * Update requirements.txt * Typpo in requirements * _send_command has only two parameters * Adapt to stricter Unit tests --------- Co-authored-by: Anton Gridnev --- requirements-dev.txt | 8 +++----- requirements.txt | 6 +++--- .../test_get_arp_table/SG300-10/expected_result.json | 2 +- .../test_get_arp_table/SG350X-48P-K9/expected_result.json | 4 ++-- .../test_get_arp_table/SG500-28-K9/expected_result.json | 4 ++-- .../SG550X-24MP-K9/expected_result.json | 4 ++-- .../SG300-10/expected_result.json | 2 +- .../SG350X-48P-K9/expected_result.json | 4 ++-- .../SG500-28-K9/expected_result.json | 4 ++-- .../SG550X-24MP-K9/expected_result.json | 4 ++-- .../CBS350-24P-4G/expected_result.json | 4 ++-- .../test_get_interfaces_ip/SG300-10/expected_result.json | 2 +- .../SG350X-48P-K9/expected_result.json | 4 ++-- .../SG500-28-K9/expected_result.json | 2 +- .../SG550X-24MP-K9/expected_result.json | 2 +- 15 files changed, 27 insertions(+), 29 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index a8b9916..bf3ef10 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,16 +1,14 @@ -napalm<=4.0.0 -netmiko<=4.0.0 -black<=24.3.0 # CVE-2024-21503 +napalm>=4.0.0 +netmiko>=4.0.0 +black>=24.3.0 # CVE-2024-21503 coveralls ddt flake8-import-order -# pytest==6.2.5 pytest pytest-cov pytest-json pytest-pythonpath pylama -# pyflakes==2.4.0 #prevent problems pyflakes mock tox diff --git a/requirements.txt b/requirements.txt index be9a920..7510853 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -napalm<=4.0.0 -netmiko<=4.0.0 -netaddr<=1.2.1 +napalm>=4.0.0 +netmiko>=4.0.0 +netaddr>=1.2.1 diff --git a/test/unit/mocked_data/test_get_arp_table/SG300-10/expected_result.json b/test/unit/mocked_data/test_get_arp_table/SG300-10/expected_result.json index 3bd353c..75c5e8b 100644 --- a/test/unit/mocked_data/test_get_arp_table/SG300-10/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table/SG300-10/expected_result.json @@ -1,3 +1,3 @@ [ - {"interface": "vlan 1", "mac": "9C:EB:E8:AA:BB:CC", "ip": "192.168.1.1", "age": 0.0} + {"interface": "VLAN1", "mac": "9C:EB:E8:AA:BB:CC", "ip": "192.168.1.1", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table/SG350X-48P-K9/expected_result.json index 05c1b7e..98534dc 100644 --- a/test/unit/mocked_data/test_get_arp_table/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table/SG350X-48P-K9/expected_result.json @@ -7,6 +7,6 @@ {"interface": "TengigabitEthernet1/0/1", "mac": "5C:8A:38:2E:FD:E0", "ip": "19.51.0.8", "age": 0.0}, {"interface": "TengigabitEthernet1/0/1", "mac": "00:50:56:93:19:B7", "ip": "19.51.1.4", "age": 0.0}, {"interface": "TengigabitEthernet1/0/1", "mac": "00:50:56:92:2F:CB", "ip": "19.51.1.5", "age": 0.0}, - {"interface": "vlan 852", "mac": "00:50:56:9E:51:F3", "ip": "19.51.1.2", "age": 0.0}, - {"interface": "vlan 852", "mac": "A4:4C:C8:7D:37:03", "ip": "19.51.14.5", "age": 0.0} + {"interface": "VLAN852", "mac": "00:50:56:9E:51:F3", "ip": "19.51.1.2", "age": 0.0}, + {"interface": "VLAN852", "mac": "A4:4C:C8:7D:37:03", "ip": "19.51.14.5", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table/SG500-28-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table/SG500-28-K9/expected_result.json index 62f8007..5452c31 100644 --- a/test/unit/mocked_data/test_get_arp_table/SG500-28-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table/SG500-28-K9/expected_result.json @@ -1,4 +1,4 @@ [ - {"interface": "vlan 202", "mac": "00:15:17:27:9C:4D", "ip": "10.0.3.1", "age": 0.0}, - {"interface": "vlan 202", "mac": "00:50:56:90:23:E8", "ip": "10.0.3.4", "age": 0.0} + {"interface": "VLAN202", "mac": "00:15:17:27:9C:4D", "ip": "10.0.3.1", "age": 0.0}, + {"interface": "VLAN202", "mac": "00:50:56:90:23:E8", "ip": "10.0.3.4", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table/SG550X-24MP-K9/expected_result.json index b03f87b..87ad7d6 100644 --- a/test/unit/mocked_data/test_get_arp_table/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table/SG550X-24MP-K9/expected_result.json @@ -37,7 +37,7 @@ }, { "age" : 0.0, - "interface" : "vlan 1", + "interface" : "VLAN1", "ip" : "192.168.0.4", "mac" : "AB:50:EF:12:34:56" }, @@ -55,7 +55,7 @@ }, { "age" : 0.0, - "interface" : "vlan 1", + "interface" : "VLAN1", "ip" : "192.168.0.142", "mac" : "AB:50:EF:12:34:56" } diff --git a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG300-10/expected_result.json b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG300-10/expected_result.json index 3bd353c..75c5e8b 100644 --- a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG300-10/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG300-10/expected_result.json @@ -1,3 +1,3 @@ [ - {"interface": "vlan 1", "mac": "9C:EB:E8:AA:BB:CC", "ip": "192.168.1.1", "age": 0.0} + {"interface": "VLAN1", "mac": "9C:EB:E8:AA:BB:CC", "ip": "192.168.1.1", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG350X-48P-K9/expected_result.json index 05c1b7e..98534dc 100644 --- a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG350X-48P-K9/expected_result.json @@ -7,6 +7,6 @@ {"interface": "TengigabitEthernet1/0/1", "mac": "5C:8A:38:2E:FD:E0", "ip": "19.51.0.8", "age": 0.0}, {"interface": "TengigabitEthernet1/0/1", "mac": "00:50:56:93:19:B7", "ip": "19.51.1.4", "age": 0.0}, {"interface": "TengigabitEthernet1/0/1", "mac": "00:50:56:92:2F:CB", "ip": "19.51.1.5", "age": 0.0}, - {"interface": "vlan 852", "mac": "00:50:56:9E:51:F3", "ip": "19.51.1.2", "age": 0.0}, - {"interface": "vlan 852", "mac": "A4:4C:C8:7D:37:03", "ip": "19.51.14.5", "age": 0.0} + {"interface": "VLAN852", "mac": "00:50:56:9E:51:F3", "ip": "19.51.1.2", "age": 0.0}, + {"interface": "VLAN852", "mac": "A4:4C:C8:7D:37:03", "ip": "19.51.14.5", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG500-28-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG500-28-K9/expected_result.json index 62f8007..5452c31 100644 --- a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG500-28-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG500-28-K9/expected_result.json @@ -1,4 +1,4 @@ [ - {"interface": "vlan 202", "mac": "00:15:17:27:9C:4D", "ip": "10.0.3.1", "age": 0.0}, - {"interface": "vlan 202", "mac": "00:50:56:90:23:E8", "ip": "10.0.3.4", "age": 0.0} + {"interface": "VLAN202", "mac": "00:15:17:27:9C:4D", "ip": "10.0.3.1", "age": 0.0}, + {"interface": "VLAN202", "mac": "00:50:56:90:23:E8", "ip": "10.0.3.4", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG550X-24MP-K9/expected_result.json index b03f87b..87ad7d6 100644 --- a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG550X-24MP-K9/expected_result.json @@ -37,7 +37,7 @@ }, { "age" : 0.0, - "interface" : "vlan 1", + "interface" : "VLAN1", "ip" : "192.168.0.4", "mac" : "AB:50:EF:12:34:56" }, @@ -55,7 +55,7 @@ }, { "age" : 0.0, - "interface" : "vlan 1", + "interface" : "VLAN1", "ip" : "192.168.0.142", "mac" : "AB:50:EF:12:34:56" } diff --git a/test/unit/mocked_data/test_get_interfaces_ip/CBS350-24P-4G/expected_result.json b/test/unit/mocked_data/test_get_interfaces_ip/CBS350-24P-4G/expected_result.json index b23d0ea..313b531 100644 --- a/test/unit/mocked_data/test_get_interfaces_ip/CBS350-24P-4G/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces_ip/CBS350-24P-4G/expected_result.json @@ -1,4 +1,4 @@ { - "vlan 10" : { "ipv4" : { "10.1.2.2" : { "prefix_length" : 24 } } }, - "vlan 80" : { "ipv4" : { "10.0.0.150" : { "prefix_length" : 24 } } } + "VLAN10" : { "ipv4" : { "10.1.2.2" : { "prefix_length" : 24 } } }, + "VLAN80" : { "ipv4" : { "10.0.0.150" : { "prefix_length" : 24 } } } } diff --git a/test/unit/mocked_data/test_get_interfaces_ip/SG300-10/expected_result.json b/test/unit/mocked_data/test_get_interfaces_ip/SG300-10/expected_result.json index 143a01d..a6f4009 100644 --- a/test/unit/mocked_data/test_get_interfaces_ip/SG300-10/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces_ip/SG300-10/expected_result.json @@ -1 +1 @@ -{ "vlan 1" : { "ipv4" : { "192.168.1.254" : { "prefix_length" : 24 } } } } +{ "VLAN1" : { "ipv4" : { "192.168.1.254" : { "prefix_length" : 24 } } } } diff --git a/test/unit/mocked_data/test_get_interfaces_ip/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_interfaces_ip/SG350X-48P-K9/expected_result.json index 49ac0f8..acedffa 100644 --- a/test/unit/mocked_data/test_get_interfaces_ip/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces_ip/SG350X-48P-K9/expected_result.json @@ -1,4 +1,4 @@ { - "vlan 1" : { "ipv4" : { "198.51.100.2" : { "prefix_length" : 24 } } }, - "vlan 852" : { "ipv4" : { "198.51.100.1" : { "prefix_length" : 16 } } } + "VLAN1" : { "ipv4" : { "198.51.100.2" : { "prefix_length" : 24 } } }, + "VLAN852" : { "ipv4" : { "198.51.100.1" : { "prefix_length" : 16 } } } } diff --git a/test/unit/mocked_data/test_get_interfaces_ip/SG500-28-K9/expected_result.json b/test/unit/mocked_data/test_get_interfaces_ip/SG500-28-K9/expected_result.json index 0d90d50..2e58fc6 100644 --- a/test/unit/mocked_data/test_get_interfaces_ip/SG500-28-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces_ip/SG500-28-K9/expected_result.json @@ -1 +1 @@ -{"vlan 202": {"ipv4": {"10.0.3.5": {"prefix_length": 8}}}} +{"VLAN202": {"ipv4": {"10.0.3.5": {"prefix_length": 8}}}} diff --git a/test/unit/mocked_data/test_get_interfaces_ip/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_interfaces_ip/SG550X-24MP-K9/expected_result.json index 2365906..6087495 100644 --- a/test/unit/mocked_data/test_get_interfaces_ip/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces_ip/SG550X-24MP-K9/expected_result.json @@ -1 +1 @@ -{"vlan 1": {"ipv4": {"192.168.0.37": {"prefix_length": 17}}}} +{"VLAN1": {"ipv4": {"192.168.0.37": {"prefix_length": 17}}}} From 971310b7904d9d0806e55dd0112cf34c7a80e95f Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Fri, 29 Mar 2024 16:58:16 +0100 Subject: [PATCH 28/36] Remove s350_base_interfaces custom map - it is allready in napalm base --- napalm_s350/s350.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/napalm_s350/s350.py b/napalm_s350/s350.py index df7539d..9da78d9 100644 --- a/napalm_s350/s350.py +++ b/napalm_s350/s350.py @@ -38,14 +38,6 @@ import napalm.base.constants as C import napalm.base.canonical_map -# make may own base_interfaces for s350 -s350_base_interfaces = { - **napalm.base.canonical_map.base_interfaces, - "fa": "FastEthernet", - "gi": "GigabitEthernet", - "te": "TengigabitEthernet", -} - from typing import List @@ -152,7 +144,7 @@ def get_arp_table(self, vrf=""): else: raise ValueError("Unexpected output: {}".format(line.split())) - interface = canonical_interface_name(interface, s350_base_interfaces) + interface = canonical_interface_name(interface) entry = { "interface": interface, @@ -271,7 +263,7 @@ def get_facts(self): if not line: continue interface = line.split()[0] - interface = canonical_interface_name(interface, s350_base_interfaces) + interface = canonical_interface_name(interface) interfaces.append(str(interface)) @@ -451,7 +443,7 @@ def get_interfaces(self): "mac_address": napalm.base.helpers.mac(mac), } - interface = canonical_interface_name(interface, s350_base_interfaces) + interface = canonical_interface_name(interface) interfaces[interface] = entry @@ -489,7 +481,7 @@ def get_interfaces_ip(self): ip = netaddr.IPNetwork(cidr) family = "ipv{0}".format(ip.version) - interface = canonical_interface_name(interface, s350_base_interfaces) + interface = canonical_interface_name(interface) interfaces[interface] = {family: {str(ip.ip): {"prefix_length": ip.prefixlen}}} @@ -547,7 +539,7 @@ def get_lldp_neighbors(self): remote_port = line_elems[2] remote_name = line_elems[3] - local_port = canonical_interface_name(local_port, s350_base_interfaces) + local_port = canonical_interface_name(local_port) neighbor = { "hostname": remote_name, @@ -601,14 +593,14 @@ def get_lldp_neighbors_detail(self, interface=""): if interface: if interface == local_port: entry = self._get_lldp_neighbors_detail_parse(local_port) - local_port = canonical_interface_name(local_port, s350_base_interfaces) + local_port = canonical_interface_name(local_port) details[local_port] = [ entry, ] else: entry = self._get_lldp_neighbors_detail_parse(local_port) - local_port = canonical_interface_name(local_port, s350_base_interfaces) + local_port = canonical_interface_name(local_port) details[local_port] = [ entry, ] @@ -643,7 +635,7 @@ def _get_lldp_neighbors_detail_parse(self, local_port): elif line.startswith("Capabilities"): caps = self._get_lldp_neighbors_detail_capabilities_parse(line) - remote_port_id = canonical_interface_name(remote_port_id, s350_base_interfaces) + remote_port_id = canonical_interface_name(remote_port_id) entry = { "parent_interface": "N/A", From cf47f5ed1ee917dd74d64064ba5e518647b906d9 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Fri, 29 Mar 2024 16:59:16 +0100 Subject: [PATCH 29/36] Adapt Unit tests to canonical_interface_name() --- .../SG350X-48P-K9/expected_result.json | 16 ++++++++-------- .../SG550X-24MP-K9/expected_result.json | 16 ++++++++-------- .../SG350X-48P-K9/expected_result.json | 16 ++++++++-------- .../SG550X-24MP-K9/expected_result.json | 16 ++++++++-------- .../expected_result.json | 8 ++++---- .../expected_result.json | 8 ++++---- .../SG350X-48P-K9/expected_result.json | 8 ++++---- .../SG550X-24MP-K9/expected_result.json | 8 ++++---- .../SG350X-48P-K9/expected_result.json | 8 ++++---- .../SG550X-24MP-K9/expected_result.json | 8 ++++---- .../expected_result.json | 6 +++--- .../SG350X-48P-K9/expected_result.json | 6 +++--- .../SG550X-24MP-K9/expected_result.json | 4 ++-- .../SG550X-24MP-K9/expected_result.json | 2 +- ...w_lldp_neighbors_TenGigabitEthernet1_0_4.txt} | 0 15 files changed, 65 insertions(+), 65 deletions(-) rename test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/{show_lldp_neighbors_TengigabitEthernet1_0_4.txt => show_lldp_neighbors_TenGigabitEthernet1_0_4.txt} (100%) diff --git a/test/unit/mocked_data/test_get_arp_table/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table/SG350X-48P-K9/expected_result.json index 98534dc..a5fbe8d 100644 --- a/test/unit/mocked_data/test_get_arp_table/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table/SG350X-48P-K9/expected_result.json @@ -1,12 +1,12 @@ [ - {"interface": "TengigabitEthernet1/0/1", "mac": "00:00:0C:07:AC:01", "ip": "19.51.0.1", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "E4:C7:22:FE:E0:43", "ip": "19.51.0.2", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:15:AA", "ip": "19.51.0.5", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:14:6F", "ip": "19.51.0.3", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "5C:8A:38:2E:BD:C0", "ip": "19.51.0.1", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "5C:8A:38:2E:FD:E0", "ip": "19.51.0.8", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "00:50:56:93:19:B7", "ip": "19.51.1.4", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "00:50:56:92:2F:CB", "ip": "19.51.1.5", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "00:00:0C:07:AC:01", "ip": "19.51.0.1", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "E4:C7:22:FE:E0:43", "ip": "19.51.0.2", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:15:AA", "ip": "19.51.0.5", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:14:6F", "ip": "19.51.0.3", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "5C:8A:38:2E:BD:C0", "ip": "19.51.0.1", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "5C:8A:38:2E:FD:E0", "ip": "19.51.0.8", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "00:50:56:93:19:B7", "ip": "19.51.1.4", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "00:50:56:92:2F:CB", "ip": "19.51.1.5", "age": 0.0}, {"interface": "VLAN852", "mac": "00:50:56:9E:51:F3", "ip": "19.51.1.2", "age": 0.0}, {"interface": "VLAN852", "mac": "A4:4C:C8:7D:37:03", "ip": "19.51.14.5", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table/SG550X-24MP-K9/expected_result.json index 87ad7d6..76f97fc 100644 --- a/test/unit/mocked_data/test_get_arp_table/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table/SG550X-24MP-K9/expected_result.json @@ -1,37 +1,37 @@ [ { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.1", "mac" : "AB:00:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.2", "mac" : "AB:C7:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.65", "mac" : "AB:EA:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.73", "mac" : "AB:EA:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.40", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.44", "mac" : "AB:50:EF:12:34:56" }, @@ -43,13 +43,13 @@ }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.49", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.2", "mac" : "AB:50:EF:12:34:56" }, diff --git a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG350X-48P-K9/expected_result.json index 98534dc..a5fbe8d 100644 --- a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG350X-48P-K9/expected_result.json @@ -1,12 +1,12 @@ [ - {"interface": "TengigabitEthernet1/0/1", "mac": "00:00:0C:07:AC:01", "ip": "19.51.0.1", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "E4:C7:22:FE:E0:43", "ip": "19.51.0.2", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:15:AA", "ip": "19.51.0.5", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:14:6F", "ip": "19.51.0.3", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "5C:8A:38:2E:BD:C0", "ip": "19.51.0.1", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "5C:8A:38:2E:FD:E0", "ip": "19.51.0.8", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "00:50:56:93:19:B7", "ip": "19.51.1.4", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "00:50:56:92:2F:CB", "ip": "19.51.1.5", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "00:00:0C:07:AC:01", "ip": "19.51.0.1", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "E4:C7:22:FE:E0:43", "ip": "19.51.0.2", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:15:AA", "ip": "19.51.0.5", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:14:6F", "ip": "19.51.0.3", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "5C:8A:38:2E:BD:C0", "ip": "19.51.0.1", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "5C:8A:38:2E:FD:E0", "ip": "19.51.0.8", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "00:50:56:93:19:B7", "ip": "19.51.1.4", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "00:50:56:92:2F:CB", "ip": "19.51.1.5", "age": 0.0}, {"interface": "VLAN852", "mac": "00:50:56:9E:51:F3", "ip": "19.51.1.2", "age": 0.0}, {"interface": "VLAN852", "mac": "A4:4C:C8:7D:37:03", "ip": "19.51.14.5", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG550X-24MP-K9/expected_result.json index 87ad7d6..76f97fc 100644 --- a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG550X-24MP-K9/expected_result.json @@ -1,37 +1,37 @@ [ { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.1", "mac" : "AB:00:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.2", "mac" : "AB:C7:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.65", "mac" : "AB:EA:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.73", "mac" : "AB:EA:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.40", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.44", "mac" : "AB:50:EF:12:34:56" }, @@ -43,13 +43,13 @@ }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.49", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.2", "mac" : "AB:50:EF:12:34:56" }, diff --git a/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-domainname/expected_result.json b/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-domainname/expected_result.json index df56c88..f6a3660 100644 --- a/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-domainname/expected_result.json +++ b/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-domainname/expected_result.json @@ -50,10 +50,10 @@ "GigabitEthernet1/0/46", "GigabitEthernet1/0/47", "GigabitEthernet1/0/48", - "TengigabitEthernet1/0/1", - "TengigabitEthernet1/0/2", - "TengigabitEthernet1/0/3", - "TengigabitEthernet1/0/4", + "TenGigabitEthernet1/0/1", + "TenGigabitEthernet1/0/2", + "TenGigabitEthernet1/0/3", + "TenGigabitEthernet1/0/4", "Port-channel1", "Port-channel2", "Port-channel3", diff --git a/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-twisted_inventory/expected_result.json b/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-twisted_inventory/expected_result.json index 53726c6..51bafb5 100644 --- a/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-twisted_inventory/expected_result.json +++ b/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-twisted_inventory/expected_result.json @@ -50,10 +50,10 @@ "GigabitEthernet1/0/46", "GigabitEthernet1/0/47", "GigabitEthernet1/0/48", - "TengigabitEthernet1/0/1", - "TengigabitEthernet1/0/2", - "TengigabitEthernet1/0/3", - "TengigabitEthernet1/0/4", + "TenGigabitEthernet1/0/1", + "TenGigabitEthernet1/0/2", + "TenGigabitEthernet1/0/3", + "TenGigabitEthernet1/0/4", "Port-channel1", "Port-channel2", "Port-channel3", diff --git a/test/unit/mocked_data/test_get_facts/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_facts/SG350X-48P-K9/expected_result.json index 53726c6..51bafb5 100644 --- a/test/unit/mocked_data/test_get_facts/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_facts/SG350X-48P-K9/expected_result.json @@ -50,10 +50,10 @@ "GigabitEthernet1/0/46", "GigabitEthernet1/0/47", "GigabitEthernet1/0/48", - "TengigabitEthernet1/0/1", - "TengigabitEthernet1/0/2", - "TengigabitEthernet1/0/3", - "TengigabitEthernet1/0/4", + "TenGigabitEthernet1/0/1", + "TenGigabitEthernet1/0/2", + "TenGigabitEthernet1/0/3", + "TenGigabitEthernet1/0/4", "Port-channel1", "Port-channel2", "Port-channel3", diff --git a/test/unit/mocked_data/test_get_facts/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_facts/SG550X-24MP-K9/expected_result.json index 0708e8f..fb354cf 100644 --- a/test/unit/mocked_data/test_get_facts/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_facts/SG550X-24MP-K9/expected_result.json @@ -26,10 +26,10 @@ "GigabitEthernet1/0/22", "GigabitEthernet1/0/23", "GigabitEthernet1/0/24", - "TengigabitEthernet1/0/1", - "TengigabitEthernet1/0/2", - "TengigabitEthernet1/0/3", - "TengigabitEthernet1/0/4", + "TenGigabitEthernet1/0/1", + "TenGigabitEthernet1/0/2", + "TenGigabitEthernet1/0/3", + "TenGigabitEthernet1/0/4", "Port-channel1", "Port-channel2", "Port-channel3", diff --git a/test/unit/mocked_data/test_get_interfaces/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_interfaces/SG350X-48P-K9/expected_result.json index 6cf7fc2..6cea30b 100644 --- a/test/unit/mocked_data/test_get_interfaces/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces/SG350X-48P-K9/expected_result.json @@ -431,7 +431,7 @@ "mtu" : 9000, "speed" : 0 }, - "TengigabitEthernet1/0/1" : { + "TenGigabitEthernet1/0/1" : { "description" : "T1", "is_enabled" : true, "is_up" : true, @@ -440,7 +440,7 @@ "mtu" : 9000, "speed" : 1000 }, - "TengigabitEthernet1/0/2" : { + "TenGigabitEthernet1/0/2" : { "description" : "", "is_enabled" : false, "is_up" : false, @@ -449,7 +449,7 @@ "mtu" : 9000, "speed" : 0 }, - "TengigabitEthernet1/0/3" : { + "TenGigabitEthernet1/0/3" : { "description" : "T2", "is_enabled" : true, "is_up" : true, @@ -458,7 +458,7 @@ "mtu" : 9000, "speed" : 1000 }, - "TengigabitEthernet1/0/4" : { + "TenGigabitEthernet1/0/4" : { "description" : "T3", "is_enabled" : true, "is_up" : true, diff --git a/test/unit/mocked_data/test_get_interfaces/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_interfaces/SG550X-24MP-K9/expected_result.json index 7a45b1e..9b2183c 100644 --- a/test/unit/mocked_data/test_get_interfaces/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces/SG550X-24MP-K9/expected_result.json @@ -215,7 +215,7 @@ "mtu" : 9000, "speed" : 0 }, - "TengigabitEthernet1/0/1" : { + "TenGigabitEthernet1/0/1" : { "description" : "SW switch-c", "is_enabled" : true, "is_up" : true, @@ -224,7 +224,7 @@ "mtu" : 9000, "speed" : 1000 }, - "TengigabitEthernet1/0/2" : { + "TenGigabitEthernet1/0/2" : { "description" : "", "is_enabled" : false, "is_up" : false, @@ -233,7 +233,7 @@ "mtu" : 9000, "speed" : 0 }, - "TengigabitEthernet1/0/3" : { + "TenGigabitEthernet1/0/3" : { "description" : "", "is_enabled" : false, "is_up" : false, @@ -242,7 +242,7 @@ "mtu" : 9000, "speed" : 0 }, - "TengigabitEthernet1/0/4" : { + "TenGigabitEthernet1/0/4" : { "description" : "SW switch-c", "is_enabled" : true, "is_up" : true, diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9-long_systemname/expected_result.json b/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9-long_systemname/expected_result.json index 5c5e42f..dfd4570 100644 --- a/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9-long_systemname/expected_result.json +++ b/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9-long_systemname/expected_result.json @@ -7,15 +7,15 @@ "hostname" : "", "port" : "34:e6:aa:ff:53:a8" } ], - "TengigabitEthernet1/0/1" : [ { + "TenGigabitEthernet1/0/1" : [ { "hostname" : "swzdsadas-vedc", "port" : "Gi0/23" } ], - "TengigabitEthernet1/0/3" : [ { + "TenGigabitEthernet1/0/3" : [ { "hostname" : "sw1dsafdsfsdf.example.net", "port" : "gi28" } ], - "TengigabitEthernet1/0/4" : [ { + "TenGigabitEthernet1/0/4" : [ { "hostname" : "sw2dsdfssddfd", "port" : "te1/0/4" } ] diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9/expected_result.json index 9ada696..e2e7a51 100644 --- a/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9/expected_result.json @@ -7,15 +7,15 @@ "hostname" : "", "port" : "34:e6:aa:ff:53:a8" } ], - "TengigabitEthernet1/0/1" : [ { + "TenGigabitEthernet1/0/1" : [ { "hostname" : "swzdsadas-vedc", "port" : "Gi0/23" } ], - "TengigabitEthernet1/0/3" : [ { + "TenGigabitEthernet1/0/3" : [ { "hostname" : "sw1dsafdsfsdfsdd", "port" : "gi28" } ], - "TengigabitEthernet1/0/4" : [ { + "TenGigabitEthernet1/0/4" : [ { "hostname" : "sw2dsdfssddfd", "port" : "te1/0/4" } ] diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_lldp_neighbors/SG550X-24MP-K9/expected_result.json index 49eeff4..6ff024c 100644 --- a/test/unit/mocked_data/test_get_lldp_neighbors/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_lldp_neighbors/SG550X-24MP-K9/expected_result.json @@ -15,11 +15,11 @@ "hostname" : "ab:48:ef:12:34:56", "port" : "ab:48:ef:12:34:56" } ], - "TengigabitEthernet1/0/1" : [ { + "TenGigabitEthernet1/0/1" : [ { "hostname" : "switch-c", "port" : "gi1/0/1" } ], - "TengigabitEthernet1/0/4" : [ { + "TenGigabitEthernet1/0/4" : [ { "hostname" : "switch-c.cb.madeta.cz", "port" : "Gi1/0/26" } ] diff --git a/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/expected_result.json index b93c77f..d747de0 100644 --- a/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/expected_result.json @@ -1,4 +1,4 @@ -{ "TengigabitEthernet1/0/4" : [ { +{ "TenGigabitEthernet1/0/4" : [ { "parent_interface" : "N/A", "remote_chassis_id" : "ab:a5:ef:12:34:56", "remote_port" : "GigabitEthernet1/0/26", diff --git a/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/show_lldp_neighbors_TengigabitEthernet1_0_4.txt b/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/show_lldp_neighbors_TenGigabitEthernet1_0_4.txt similarity index 100% rename from test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/show_lldp_neighbors_TengigabitEthernet1_0_4.txt rename to test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/show_lldp_neighbors_TenGigabitEthernet1_0_4.txt From d37155998975552242602f7f6f54c75053e4020e Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Mon, 22 Apr 2024 15:52:03 +0200 Subject: [PATCH 30/36] Add format parameter to get_config() --- napalm_s350/s350.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/napalm_s350/s350.py b/napalm_s350/s350.py index 9da78d9..59d9f3b 100644 --- a/napalm_s350/s350.py +++ b/napalm_s350/s350.py @@ -157,7 +157,13 @@ def get_arp_table(self, vrf=""): return arp_table - def get_config(self, retrieve="all", full=False, sanitized=False): + def get_config( + self, + retrieve="all", + full=False, + sanitized=False, + format: str = "text", + ): """ get_config for S350. Since this firmware doesn't support a candidate configuration we leave it empty. From 3f6c8f8314b2f29fd3f50d52993733541253e0a9 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Mon, 22 Apr 2024 15:52:22 +0200 Subject: [PATCH 31/36] Add badges --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 760050b..446614b 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,12 @@ NAPALM driver for Cisco SMB switches (SF3xx, SF5xx, SG3xx, SG5xx, CBS35x). ## Status -Master: ![Build](https://github.com/napalm-automation-community/napalm-s350/workflows/Test%20before%20push/badge.svg?branch=master&event=push) -Develop: ![Build](https://github.com/napalm-automation-community/napalm-s350/workflows/Test%20before%20push/badge.svg?branch=develop&event=push) +Master: [![Thorough Test](https://github.com/napalm-automation-community/napalm-s350/actions/workflows/ThoroughTest.yml/badge.svg?branch=master)](https://github.com/napalm-automation-community/napalm-s350/actions/workflows/ThoroughTest.yml) -PyPi: [![Upload](https://github.com/napalm-automation-community/napalm-s350/workflows/Upload%20Python%20Package%20to%20PyPi.org/badge.svg)](https://github.com/napalm-automation-community/napalm-s350/actions?query=workflow%3A%22Upload+Python+Package+to+PyPi.org%22) +Develop: [![Thorough Test](https://github.com/napalm-automation-community/napalm-s350/actions/workflows/ThoroughTest.yml/badge.svg?branch=develop)](https://github.com/napalm-automation-community/napalm-s350/actions/workflows/ThoroughTest.yml) + +PyPi.org: [![Publish To PyPi.org](https://github.com/napalm-automation-community/napalm-s350/actions/workflows/PublishToPIP.yml/badge.svg?branch=master)](https://github.com/napalm-automation-community/napalm-s350/actions/workflows/PublishToPIP.yml) ## Requirements From f1e0aad450cb7af9e382e5b3cd271c41084a3a65 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Mon, 22 Apr 2024 16:08:43 +0200 Subject: [PATCH 32/36] Tests for push are enought --- .github/workflows/ThoroughTest.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ThoroughTest.yml b/.github/workflows/ThoroughTest.yml index dc8ff30..a0d023f 100644 --- a/.github/workflows/ThoroughTest.yml +++ b/.github/workflows/ThoroughTest.yml @@ -8,10 +8,6 @@ on: branches: - develop - master - pull_request: - branches: - - develop - - master # check every 14 days schedule: - cron: '0 6 5,20 * *' From a906c1b847087708d2b790b48489c07db18b8d41 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 23 Apr 2024 09:10:53 +0200 Subject: [PATCH 33/36] update CD actions --- .github/workflows/PublishToPIP.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/PublishToPIP.yml b/.github/workflows/PublishToPIP.yml index 492b919..4323411 100644 --- a/.github/workflows/PublishToPIP.yml +++ b/.github/workflows/PublishToPIP.yml @@ -14,9 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Install dependencies From 08071570d22d3f3cc34476cf1b06ddd468c384f1 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 23 Apr 2024 09:11:35 +0200 Subject: [PATCH 34/36] add tests for device SG500-52 --- test/unit/command_output/SG500-52-K9/show_dir.txt | 0 .../SG500-52-K9/show_interface_switchport_GigabitEthernet1_4.txt | 0 .../command_output/SG500-52-K9/show_interfaces_description.txt | 0 test/unit/command_output/SG500-52-K9/show_interfaces_status.txt | 0 test/unit/command_output/SG500-52-K9/show_inventory.txt | 0 test/unit/command_output/SG500-52-K9/show_running_config.txt | 0 .../command_output/SG500-52-K9/show_running_config_detailed.txt | 0 test/unit/command_output/SG500-52-K9/show_startup_config.txt | 0 test/unit/command_output/SG500-52-K9/show_system.txt | 0 test/unit/command_output/SG500-52-K9/show_version.txt | 0 10 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/unit/command_output/SG500-52-K9/show_dir.txt create mode 100644 test/unit/command_output/SG500-52-K9/show_interface_switchport_GigabitEthernet1_4.txt create mode 100644 test/unit/command_output/SG500-52-K9/show_interfaces_description.txt create mode 100644 test/unit/command_output/SG500-52-K9/show_interfaces_status.txt create mode 100644 test/unit/command_output/SG500-52-K9/show_inventory.txt create mode 100644 test/unit/command_output/SG500-52-K9/show_running_config.txt create mode 100644 test/unit/command_output/SG500-52-K9/show_running_config_detailed.txt create mode 100644 test/unit/command_output/SG500-52-K9/show_startup_config.txt create mode 100644 test/unit/command_output/SG500-52-K9/show_system.txt create mode 100644 test/unit/command_output/SG500-52-K9/show_version.txt diff --git a/test/unit/command_output/SG500-52-K9/show_dir.txt b/test/unit/command_output/SG500-52-K9/show_dir.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/command_output/SG500-52-K9/show_interface_switchport_GigabitEthernet1_4.txt b/test/unit/command_output/SG500-52-K9/show_interface_switchport_GigabitEthernet1_4.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/command_output/SG500-52-K9/show_interfaces_description.txt b/test/unit/command_output/SG500-52-K9/show_interfaces_description.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/command_output/SG500-52-K9/show_interfaces_status.txt b/test/unit/command_output/SG500-52-K9/show_interfaces_status.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/command_output/SG500-52-K9/show_inventory.txt b/test/unit/command_output/SG500-52-K9/show_inventory.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/command_output/SG500-52-K9/show_running_config.txt b/test/unit/command_output/SG500-52-K9/show_running_config.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/command_output/SG500-52-K9/show_running_config_detailed.txt b/test/unit/command_output/SG500-52-K9/show_running_config_detailed.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/command_output/SG500-52-K9/show_startup_config.txt b/test/unit/command_output/SG500-52-K9/show_startup_config.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/command_output/SG500-52-K9/show_system.txt b/test/unit/command_output/SG500-52-K9/show_system.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/command_output/SG500-52-K9/show_version.txt b/test/unit/command_output/SG500-52-K9/show_version.txt new file mode 100644 index 0000000..e69de29 From 112320f5bc35eadc489c0705565eefd9cb1fb419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kl=C3=ADma?= Date: Tue, 23 Apr 2024 12:40:55 +0200 Subject: [PATCH 35/36] Merge CI to develop (#95) * Simplify CI * CI update * CI update * Update CI from develop (#94) * Add format parameter to get_config() * Add badges * Tests for push are enought * update CD actions * add tests for device SG500-52 --- .github/workflows/FastTest.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/FastTest.yml b/.github/workflows/FastTest.yml index 024c538..24a52af 100644 --- a/.github/workflows/FastTest.yml +++ b/.github/workflows/FastTest.yml @@ -4,11 +4,7 @@ name: Fast Test on: - push: - branches-ignore: - - develop - - master - pull_request: + push: branches-ignore: - develop - master From ce7f542df9c7a2874369e0d95c904a0e001cb16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kl=C3=ADma?= Date: Tue, 23 Apr 2024 15:06:20 +0200 Subject: [PATCH 36/36] fetch_command_output helper (#97) * fetch_command_output.sh tool * Update fetch_command_update from develop (#93) * adding read_timeout_override netmiko option --------- Signed-off-by: dependabot[bot] Co-authored-by: Petr Klima Co-authored-by: Dave Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Anton Gridnev --- .github/workflows/FastTest.yml | 2 +- test/unit/fetch_command_output.cfg | 47 +++++++++ test/unit/fetch_command_output.sh | 157 +++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 test/unit/fetch_command_output.cfg create mode 100755 test/unit/fetch_command_output.sh diff --git a/.github/workflows/FastTest.yml b/.github/workflows/FastTest.yml index 24a52af..a6b58bf 100644 --- a/.github/workflows/FastTest.yml +++ b/.github/workflows/FastTest.yml @@ -4,7 +4,7 @@ name: Fast Test on: - push: + push: branches-ignore: - develop - master diff --git a/test/unit/fetch_command_output.cfg b/test/unit/fetch_command_output.cfg new file mode 100644 index 0000000..cd11f46 --- /dev/null +++ b/test/unit/fetch_command_output.cfg @@ -0,0 +1,47 @@ +# Config file for utility 'fetch_command_output.sh' +# +# This will help you to make bunch of command output files for napalm drivers unit tests +# +# There is not any IP, MAC or names obfuscation or anonymizations! +# Before using outputs as a unit test files it is recommendet to protect +# your privacy information yourself by editing output files. + +# Required variables +# $INTERFACE - for detailed interface information +# $LLDPINTERFACE - for detailed LLDP information + +# Define empty array of commands +COMMANDS=() + +# This is example set of commands for napalm driver 's350' (Cisco SMB) + +# system info +COMMANDS+=("show version") +COMMANDS+=("show system") +COMMANDS+=("show inventory") + +# config commands +COMMANDS+=("show startup-config") +COMMANDS+=("show running-config") +COMMANDS+=("show running-config detailed") + +# interface commands +COMMANDS+=("show interfaces status") +COMMANDS+=("show interfaces description") +COMMANDS+=("show interface switchport $INTERFACE") +COMMANDS+=("show ports jumbo-frame") + +# ip commands +COMMANDS+=("show hosts") +COMMANDS+=("show ip interface") +COMMANDS+=("show ipv6 interface brief") +COMMANDS+=("show arp") + +# lldp commands +COMMANDS+=("show lldp neighbors") +COMMANDS+=("show lldp local $LLDPINTERFACE") +COMMANDS+=("show lldp neighbors $LLDPINTERFACE") + +# ntp commands +COMMANDS+=("show sntp status") + diff --git a/test/unit/fetch_command_output.sh b/test/unit/fetch_command_output.sh new file mode 100755 index 0000000..ee0e032 --- /dev/null +++ b/test/unit/fetch_command_output.sh @@ -0,0 +1,157 @@ +#!/bin/bash + +# Defaults +DEF_FORCE="n" +#DEF_METHOD="cli" - nice with --method-kwargs "commands=['show ip interface']" +# but output is JSON +DEF_METHOD="_send_command" + +# mocked data dir +MDDIR="mocked_data" +# command output dir +CODIR="command_output" +# config +CMDIN="./$(basename $0 .sh ).cfg" + +GETOPTS=":hu:p:ft:m:i:l:v:d:" +function usage() { + MSG="usage: $(basename $0) [-h] -u USERNAME -p PASSWORD [-f]\n" + MSG+=" [-m METHOD] -i INTERFACE -l LLDP_INTERFACE\n" + MSG+=" -t TYPE -v VENDOR -d DEVICE [SINGLE_COMMAND]\n" + MSG+="\n" + MSG+=" This utility helps to get output of commands from device.\n" + MSG+=" Set of commands can be configured in '$CMDIN'\n" + MSG+=" Command output is saved to '$CODIR/DEVICE_TYPE/command_out.txt'\n" + MSG+=" and by default is not to be overwriten.\n" + MSG+="\n" + MSG+=" There is not any IP, MAC or names obfuscation or anonymizations!\n" + MSG+=" Before using as a unit test files it is recommendet to protect\n" + MSG+=" your privacy information yourself by editing output files\n" + MSG+=" in '$CODIR/DEVICE_TYPE/command_out.txt'!\n" + MSG+="\n" + MSG+=" -h - this help\n" + MSG+=" -u USERNAME - login username (or env DEVUSERNAME)\n" + MSG+=" -p PASSWORD - login password (or env DEVPASSWORD)\n" + MSG+=" -f - overwrite already downloaded output files\n" + MSG+=" -t TYPE - device type\n" + MSG+=" -m METHOD - what method sends command to device (def '$DEF_METHOD')\n" + MSG+=" -i INTERFACE - interface for deailed info (see '$CMDIN')\n" + MSG+=" -l INTERFACE - interface for deailed lldp info (see '$CMDIN')\n" + MSG+=" -v VENDOR - vendor napalm driver\n" + MSG+=" -d DEVICE - device to connect\n" + + [[ -n $@ ]] && echo -e "\n### $@ ###\n" >&2 + + echo -e "$MSG" >&2 + exit 127 +} + + +# Parse options +# No run without options +if ( ! getopts $GETOPTS opt); then # CLI bez options + usage "Options needed !!!" +fi +OPTIND=1 # reset index + +# Preset defaults +FORCE="$DEF_FORCE" +METHOD="$DEF_METHOD" + +while getopts $GETOPTS opt; do + #echo $opt; + + case "$opt" in + 'u') + DEVUSERNAME=$OPTARG ;; + + 'p') + DEVPASSWORD=$OPTARG ;; + + 't') + TYPE=$OPTARG ;; + + 'i') + INTERFACE=$OPTARG ;; + + 'l') + LLDPINTERFACE=$OPTARG ;; + + 'v') + VENDOR=$OPTARG ;; + + 'm') + METHOD=$OPTARG ;; + + 'd') + DEVICE=$OPTARG ;; + + 'f') + FORCE='y' ;; + + 'h') + usage ;; + + ':') + usage "Parameter '-$OPTARG' needs value." + ;; + + '?'|*) + usage "Unknown parameter '-$OPTARG' ." + ;; + esac +done + + +# read commands from file +[ -f "$CMDIN" ] || usage "File '$CMDIN' does not exists." +[ -r "$CMDIN" ] || usage "Can not read file '$CMDIN'." + +[ -z "$INTERFACE" ] && usage "Parameter -i needed" +[ -z "$LLDPINTERFACE" ] && usage "Parameter -l needed" + +. "${CMDIN}" + +# Get possible last arg and set it as only command +shift $(($OPTIND - 1)) +[ -z "$1" ] || COMMANDS=("$1") + +[ -z "$DEVUSERNAME" ] && usage "Parameter -u needed" +[ -z "$DEVPASSWORD" ] && usage "Parameter -p needed" +[ -z "$TYPE" ] && usage "Parameter -t needed" +[ -z "$VENDOR" ] && usage "Parameter -v needed" +[ -z "$DEVICE" ] && usage "Parameter -d needed" + +# ensure directory structure exists +[ -d "$CODIR" ] || usage "Output directory '$CODIR' does not exist." +[ -w "$CODIR" ] || usage "Output directory '$CODIR' is not writeable." + +mkdir -p "$CODIR/$TYPE" || usage "Can not make directory '$CODIR/$TYPE'" +[ -w "$CODIR/$TYPE" ] || usage "Output directory '$CODIR/$TYPE' is not writeable." + +echo "########## Generate output for type $TYPE ##########" +# lets get commands outputs +OLDIFS="$IFS" +IFS=$'\t\n' +for CMD in ${COMMANDS[@]} +do + IFS="$OLDIFS" + + CMDSTR=${CMD// /_} + CMDSTR=${CMDSTR//-/_} + CMDSTR=${CMDSTR/\\/_} + CMDSTR=${CMDSTR/./_} + CMDSTR=${CMDSTR////_} + CMDFILE="$CODIR/$TYPE/${CMDSTR}.txt" + + # skip already fetched command outputs + if [ -f "$CMDFILE" -a "$FORCE" = "n" ]; then + echo "###### Skiping '$CMD'. File '$CMDFILE' exists" + continue + fi + + echo "## Fetching '$CMD' to '$CMDSTR.txt'" + # --debug + echo -e "$(napalm --user "$DEVUSERNAME" --password "$DEVPASSWORD" --vendor "$VENDOR" "$DEVICE" call --method-kwargs "command='$CMD'" "$METHOD" | sed 's/^"//;s/"$//;s/\\"/"/g')" > "$CMDFILE" +done +