From dff36c8a276b24e06d35044daedd74eb1a96faca Mon Sep 17 00:00:00 2001 From: Ken Celenza Date: Mon, 27 Feb 2017 15:56:03 -0500 Subject: [PATCH 01/15] Test for interfaces with no lldp neighbor --- napalm_panos/panos.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/napalm_panos/panos.py b/napalm_panos/panos.py index 5ec4925..a1446e5 100644 --- a/napalm_panos/panos.py +++ b/napalm_panos/panos.py @@ -398,8 +398,10 @@ def get_lldp_neighbors(self): if local_int not in neighbors.keys(): neighbors[local_int] = [] - - lldp_neighs = lldp_item['neighbors']['entry'] + try: + lldp_neighs = lldp_item.get('neighbors').get('entry') + except AttributeError: + lldp_neighs = '' if isinstance(lldp_neighs, dict): lldp_neighs = [lldp_neighs] From e5845debc5e98690769797a62eb078475211f664 Mon Sep 17 00:00:00 2001 From: Ken Celenza Date: Mon, 27 Feb 2017 15:58:28 -0500 Subject: [PATCH 02/15] Add expected input --- ...neighbors_all__neighbors___lldp___show_.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/unit/mocked_data/test_get_lldp_neighbors/no_neighbor/_show__lldp__neighbors_all__neighbors___lldp___show_.xml diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/no_neighbor/_show__lldp__neighbors_all__neighbors___lldp___show_.xml b/test/unit/mocked_data/test_get_lldp_neighbors/no_neighbor/_show__lldp__neighbors_all__neighbors___lldp___show_.xml new file mode 100644 index 0000000..68a933e --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/no_neighbor/_show__lldp__neighbors_all__neighbors___lldp___show_.xml @@ -0,0 +1,18 @@ + + + + +16 +1 + + + + + +17 +2 + + + + + From 1425fc3793e04b92c8ae1de996295976da8c5593 Mon Sep 17 00:00:00 2001 From: Ken Celenza Date: Mon, 27 Feb 2017 15:59:51 -0500 Subject: [PATCH 03/15] Add expected output --- .../test_get_lldp_neighbors/no_neighbor/expected_result.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/unit/mocked_data/test_get_lldp_neighbors/no_neighbor/expected_result.json diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/no_neighbor/expected_result.json b/test/unit/mocked_data/test_get_lldp_neighbors/no_neighbor/expected_result.json new file mode 100644 index 0000000..09a3bbe --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/no_neighbor/expected_result.json @@ -0,0 +1 @@ +{"ethernet1/1": [], "ethernet1/2": []} From a70b33a088e11a91f5d51db11b82af7b7da03d8b Mon Sep 17 00:00:00 2001 From: GGabriele Date: Wed, 1 Mar 2017 13:11:06 +0100 Subject: [PATCH 04/15] Bumping version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 232c1fb..4c7de97 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="napalm-panos", - version="0.4.0", + version="0.4.1", packages=find_packages(), author="Gabriele Gerbino", author_email="gabriele@networktocode.com", From 3081187e5241c19c4670996db7384a558d9ccca7 Mon Sep 17 00:00:00 2001 From: gjim83 Date: Wed, 16 Aug 2017 17:21:49 +0000 Subject: [PATCH 05/15] Adding code to fix #45 --- napalm_panos/panos.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/napalm_panos/panos.py b/napalm_panos/panos.py index a1446e5..05b6d5e 100644 --- a/napalm_panos/panos.py +++ b/napalm_panos/panos.py @@ -372,9 +372,13 @@ def get_facts(self): for element in interfaces: for entry in interfaces[element]: - for intf in interfaces[element][entry]: - if intf['name'] not in facts['interface_list']: - facts['interface_list'].append(intf['name']) + if isinstance(interfaces[element][entry], list): + for intf in interfaces[element][entry]: + if intf['name'] not in facts['interface_list']: + facts['interface_list'].append(intf['name']) + else: + if interfaces[element][entry]['name'] not in facts['interface_list']: + facts['interface_list'].append(interfaces[element][entry]['name']) facts['interface_list'].sort() return facts From 200f28ed3880c2ab4d638435025e531b35700008 Mon Sep 17 00:00:00 2001 From: gjim83 Date: Wed, 16 Aug 2017 17:24:18 +0000 Subject: [PATCH 06/15] Also adding tests for #45 solution --- ...show__interface_all__interface___show_.xml | 41 +++++++++++++++++ ...__system__info___info___system___show_.xml | 46 +++++++++++++++++++ .../one_interface/expected_result.json | 1 + 3 files changed, 88 insertions(+) create mode 100644 test/unit/mocked_data/test_get_facts/one_interface/_show__interface_all__interface___show_.xml create mode 100644 test/unit/mocked_data/test_get_facts/one_interface/_show__system__info___info___system___show_.xml create mode 100644 test/unit/mocked_data/test_get_facts/one_interface/expected_result.json diff --git a/test/unit/mocked_data/test_get_facts/one_interface/_show__interface_all__interface___show_.xml b/test/unit/mocked_data/test_get_facts/one_interface/_show__interface_all__interface___show_.xml new file mode 100644 index 0000000..37b956a --- /dev/null +++ b/test/unit/mocked_data/test_get_facts/one_interface/_show__interface_all__interface___show_.xml @@ -0,0 +1,41 @@ + + + + ethernet1/1 + + N/A + 1 + + + 0 + N/A + 16 + + + + ethernet1/1.135 + Untrust + vr:default + 1 + + + 135 + 10.20.30.40/29 + 256 + + + + + + ethernet1/1 + full + 0 + up + 10000/full/up + 00:ca:fe:be:ef:00 + (autoneg) + 10000 + 16 + + + diff --git a/test/unit/mocked_data/test_get_facts/one_interface/_show__system__info___info___system___show_.xml b/test/unit/mocked_data/test_get_facts/one_interface/_show__system__info___info___system___show_.xml new file mode 100644 index 0000000..b72db86 --- /dev/null +++ b/test/unit/mocked_data/test_get_facts/one_interface/_show__system__info___info___system___show_.xml @@ -0,0 +1,46 @@ + + + + pa1 + 10.0.0.90 + 255.255.255.0 + 10.0.0.2 + unknown + fe80::20c:29ff:fe6d:c67e/64 + + 00:0c:29:6d:c6:7e + + 11 days, 22:09:01 + pa1 + vm + PA-VM + unknown + BA:DB:EE:FB:AD:00 + 255 + 564D8B6D-7BDB-75AF-400F-B062016DC67E + FB060000FDFB8B07 + none + VMWare ESXi + 7.0.1 + 0.0.0 + 497-2688 + unknown + 0 + unknown + 0 + unknown + 0 + unknown + paloaltonetworks + 0 + unknown + 0000.00.00.000 + 0 + unknown7.0.9 + vm + off + off + normal + + + diff --git a/test/unit/mocked_data/test_get_facts/one_interface/expected_result.json b/test/unit/mocked_data/test_get_facts/one_interface/expected_result.json new file mode 100644 index 0000000..0914018 --- /dev/null +++ b/test/unit/mocked_data/test_get_facts/one_interface/expected_result.json @@ -0,0 +1 @@ +{"uptime": 79741, "vendor": "Palo Alto Networks", "hostname": "pa1", "fqdn": "N/A", "os_version": "7.0.1", "serial_number": "unknown", "model": "PA-VM", "interface_list": ["ethernet1/1", "ethernet1/1.135"]} From f8c36cd5149b0e45c076d3374749fc7ae59b9f64 Mon Sep 17 00:00:00 2001 From: gjim83 Date: Thu, 17 Aug 2017 07:27:28 +0000 Subject: [PATCH 07/15] Fixing tests for #48 --- .../unit/mocked_data/test_get_facts/normal/expected_result.json | 2 +- .../test_get_facts/one_interface/expected_result.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/mocked_data/test_get_facts/normal/expected_result.json b/test/unit/mocked_data/test_get_facts/normal/expected_result.json index 634a11e..fac7079 100644 --- a/test/unit/mocked_data/test_get_facts/normal/expected_result.json +++ b/test/unit/mocked_data/test_get_facts/normal/expected_result.json @@ -1 +1 @@ -{"uptime": 79741, "vendor": "Palo Alto Networks", "hostname": "pa1", "fqdn": "N/A", "os_version": "7.0.1", "serial_number": "unknown", "model": "PA-VM", "interface_list": ["ethernet1/1", "ethernet1/2", "ethernet1/3", "ethernet1/4", "loopback"]} +{"uptime": 1030141, "vendor": "Palo Alto Networks", "hostname": "pa1", "fqdn": "N/A", "os_version": "7.0.1", "serial_number": "unknown", "model": "PA-VM", "interface_list": ["ethernet1/1", "ethernet1/2", "ethernet1/3", "ethernet1/4", "loopback"]} diff --git a/test/unit/mocked_data/test_get_facts/one_interface/expected_result.json b/test/unit/mocked_data/test_get_facts/one_interface/expected_result.json index 0914018..9990601 100644 --- a/test/unit/mocked_data/test_get_facts/one_interface/expected_result.json +++ b/test/unit/mocked_data/test_get_facts/one_interface/expected_result.json @@ -1 +1 @@ -{"uptime": 79741, "vendor": "Palo Alto Networks", "hostname": "pa1", "fqdn": "N/A", "os_version": "7.0.1", "serial_number": "unknown", "model": "PA-VM", "interface_list": ["ethernet1/1", "ethernet1/1.135"]} +{"uptime": 1030141, "vendor": "Palo Alto Networks", "hostname": "pa1", "fqdn": "N/A", "os_version": "7.0.1", "serial_number": "unknown", "model": "PA-VM", "interface_list": ["ethernet1/1", "ethernet1/1.135"]} From cab7340d8f1e7e7ccf8eff486f75a8256bf3ae13 Mon Sep 17 00:00:00 2001 From: GGabriele Date: Fri, 18 Aug 2017 12:13:02 +0200 Subject: [PATCH 08/15] Bumping version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4c7de97..31f2005 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="napalm-panos", - version="0.4.1", + version="0.4.2", packages=find_packages(), author="Gabriele Gerbino", author_email="gabriele@networktocode.com", From b4a1d4fc61423b13a368e4d150d052b332fbb695 Mon Sep 17 00:00:00 2001 From: itdependsnetworks Date: Fri, 15 Dec 2017 09:23:00 -0500 Subject: [PATCH 09/15] add multiple imports --- napalm_panos/panos.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/napalm_panos/panos.py b/napalm_panos/panos.py index 05b6d5e..aa324b9 100644 --- a/napalm_panos/panos.py +++ b/napalm_panos/panos.py @@ -30,7 +30,10 @@ from napalm_base.exceptions import ConnectionException, ReplaceConfigException,\ MergeConfigException -from napalm_base.base import NetworkDriver +try: + from napalm_base import NetworkDriver +except ImportError: + from napalm_base.base import NetworkDriver from napalm_base.utils import py23_compat From 426bbcf3c9011d00f0b9b244d7bac01f9d546fea Mon Sep 17 00:00:00 2001 From: itdependsnetworks Date: Wed, 20 Dec 2017 12:47:43 -0500 Subject: [PATCH 10/15] more import fixes --- napalm_panos/panos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napalm_panos/panos.py b/napalm_panos/panos.py index aa324b9..738fce6 100644 --- a/napalm_panos/panos.py +++ b/napalm_panos/panos.py @@ -31,7 +31,7 @@ MergeConfigException try: - from napalm_base import NetworkDriver + from napalm.base import NetworkDriver except ImportError: from napalm_base.base import NetworkDriver From 28947217447776454f9c0a21aaf9fcc75a046b4c Mon Sep 17 00:00:00 2001 From: itdependsnetworks Date: Fri, 12 Jan 2018 09:00:14 -0500 Subject: [PATCH 11/15] version bump --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 31f2005..ee66516 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="napalm-panos", - version="0.4.2", + version="0.5.0", packages=find_packages(), author="Gabriele Gerbino", author_email="gabriele@networktocode.com", From 2beb76f2baef73e85a40d3b44734f84d67e76e9b Mon Sep 17 00:00:00 2001 From: itdependsnetworks Date: Fri, 12 Jan 2018 14:13:47 -0500 Subject: [PATCH 12/15] update requirements --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index e791047..048bf64 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -napalm-base>=0.18.0 +napalm>=2.3.0 pan-python netmiko>=1.0.0 requests-toolbelt diff --git a/setup.py b/setup.py index ee66516..0ea227e 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="napalm-panos", - version="0.5.0", + version="0.5.1", packages=find_packages(), author="Gabriele Gerbino", author_email="gabriele@networktocode.com", From 598a4136c763c35e867a46eef5fedfa0b9e44044 Mon Sep 17 00:00:00 2001 From: itdependsnetworks Date: Sun, 21 Jan 2018 14:18:22 -0500 Subject: [PATCH 13/15] more updates to napalm base imports --- napalm_panos/panos.py | 15 ++++++++++----- test/unit/TestDriver.py | 2 +- test/unit/conftest.py | 4 ++-- test/unit/test_getters.py | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/napalm_panos/panos.py b/napalm_panos/panos.py index 738fce6..97276ec 100644 --- a/napalm_panos/panos.py +++ b/napalm_panos/panos.py @@ -26,16 +26,21 @@ import time # local modules -from napalm_base.utils.string_parsers import convert_uptime_string_seconds -from napalm_base.exceptions import ConnectionException, ReplaceConfigException,\ - MergeConfigException - try: + from napalm.base.utils.string_parsers import convert_uptime_string_seconds + from napalm.base.exceptions import ConnectionException,\ + ReplaceConfigException,\ + MergeConfigException from napalm.base import NetworkDriver + from napalm.base.utils import py23_compat except ImportError: + from napalm_base.utils.string_parsers import convert_uptime_string_seconds + from napalm_base.exceptions import ConnectionException,\ + ReplaceConfigException,\ + MergeConfigException from napalm_base.base import NetworkDriver + from napalm_base.utils import py23_compat -from napalm_base.utils import py23_compat from netmiko import ConnectHandler from netmiko import __version__ as netmiko_version diff --git a/test/unit/TestDriver.py b/test/unit/TestDriver.py index fd495a3..2304fd5 100644 --- a/test/unit/TestDriver.py +++ b/test/unit/TestDriver.py @@ -16,7 +16,7 @@ import unittest from napalm_panos import panos -from napalm_base.test.base import TestConfigNetworkDriver +from napalm.base.test.base import TestConfigNetworkDriver class TestConfigDriver(unittest.TestCase, TestConfigNetworkDriver): diff --git a/test/unit/conftest.py b/test/unit/conftest.py index 037731e..d188320 100644 --- a/test/unit/conftest.py +++ b/test/unit/conftest.py @@ -2,8 +2,8 @@ from builtins import super import pytest -from napalm_base.test import conftest as parent_conftest -from napalm_base.test.double import BaseTestDouble +from napalm.base.test import conftest as parent_conftest +from napalm.base.test.double import BaseTestDouble from napalm_panos import PANOSDriver as OriginalDriver diff --git a/test/unit/test_getters.py b/test/unit/test_getters.py index 6509001..4e4cb4e 100644 --- a/test/unit/test_getters.py +++ b/test/unit/test_getters.py @@ -1,6 +1,6 @@ """Tests for getters.""" -from napalm_base.test.getters import BaseTestGetters +from napalm.base.test.getters import BaseTestGetters import pytest From 9b8c287cef9988a67ef30d30d31bec5c8dadeb19 Mon Sep 17 00:00:00 2001 From: itdependsnetworks Date: Sun, 21 Jan 2018 23:16:45 -0500 Subject: [PATCH 14/15] pep workaround --- napalm_panos/panos.py | 12 ++++++------ tox.ini | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/napalm_panos/panos.py b/napalm_panos/panos.py index 97276ec..cf504d6 100644 --- a/napalm_panos/panos.py +++ b/napalm_panos/panos.py @@ -28,16 +28,16 @@ # local modules try: from napalm.base.utils.string_parsers import convert_uptime_string_seconds - from napalm.base.exceptions import ConnectionException,\ - ReplaceConfigException,\ - MergeConfigException + from napalm.base.exceptions import ConnectionException + from napalm.base.exceptions import ReplaceConfigException + from napalm.base.exceptions import MergeConfigException from napalm.base import NetworkDriver from napalm.base.utils import py23_compat except ImportError: from napalm_base.utils.string_parsers import convert_uptime_string_seconds - from napalm_base.exceptions import ConnectionException,\ - ReplaceConfigException,\ - MergeConfigException + from napalm_base.exceptions import ConnectionException + from napalm_base.exceptions import ReplaceConfigException + from napalm_base.exceptions import MergeConfigException from napalm_base.base import NetworkDriver from napalm_base.utils import py23_compat diff --git a/tox.ini b/tox.ini index 5ae5d81..910c4f4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py34,py35 +envlist = py27 [testenv] deps = From a95e96e7e531eee536b811305239fc5b24fcdcae Mon Sep 17 00:00:00 2001 From: itdependsnetworks Date: Sun, 21 Jan 2018 23:27:53 -0500 Subject: [PATCH 15/15] add py versions back --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 910c4f4..5ae5d81 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27 +envlist = py27,py34,py35 [testenv] deps =