diff --git a/README.md b/README.md index 5328151..a122499 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,14 @@ from napalm import get_network_driver driver = get_network_driver("procurve") +# Uncomment if you need debug logging of the raw commands sent to the +# device and any data received +#import logging +#logging.basicConfig(filename="procurve.debug.log", level=logging.DEBUG) +#logger = logging.getLogger("netmiko") + +driver = get_network_driver("procurve") + device = driver( "10.0.0.254", "manager", diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..d152311 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +filterwarnings = + ignore:direct construction of .*Item has been deprecated:DeprecationWarning diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/expected_result.json b/test/unit/mocked_data/test_get_lldp_neighbors/2920/expected_result.json new file mode 100644 index 0000000..89283ed --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/expected_result.json @@ -0,0 +1,44 @@ +{ + "1": [ + { + "port": "48 7b 6b 39 88 8b", + "hostname": "a1001.atlas.local" + } + ], + "30": [ + { + "port": "d8 50 e6 c3 a4 2f", + "hostname": "a1030.atlas.local" + } + ], + "A1": [ + { + "port": "Ten-GigabitEthernet0/0/10", + "hostname": "Coredata" + } + ], + "A2": [ + { + "port": "Ten-GigabitEthernet1/0/10", + "hostname": "Coredata" + } + ], + "B1": [ + { + "port": "Ten-GigabitEthernet2/0/10", + "hostname": "Coredata" + } + ], + "B2": [ + { + "port": "Ten-GigabitEthernet3/0/10", + "hostname": "Coredata" + } + ], + "OOBM": [ + { + "port": "Ethernet1/0/30", + "hostname": "mgs010b" + } + ] +} diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_1_1.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_1_1.txt new file mode 100644 index 0000000..ce29e0b --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_1_1.txt @@ -0,0 +1 @@ +lldpRemSysDesc.0.1.1 = Debian GNU/Linux 8 (jessie) Linux 4.9.0-0.bpo.6-amd64 #1 SMP Debian 4.9.88-1+deb9u1~bpo8+1 (2018-05-13) x86_64 diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_30_1.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_30_1.txt new file mode 100644 index 0000000..d67030c --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_30_1.txt @@ -0,0 +1 @@ +lldpRemSysDesc.0.30.1 = Debian GNU/Linux 10 (buster) Linux 4.19.0-10-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_49_1.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_49_1.txt new file mode 100644 index 0000000..d293588 --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_49_1.txt @@ -0,0 +1 @@ +lldpRemSysDesc.0.49.1 = HPE Comware Platform Software, Software Version 7.1.045, Release 1152 diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_50_1.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_50_1.txt new file mode 100644 index 0000000..819ab5d --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_50_1.txt @@ -0,0 +1 @@ +lldpRemSysDesc.0.50.1 = HPE Comware Platform Software, Software Version 7.1.045, Release 1152 diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_51_1.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_51_1.txt new file mode 100644 index 0000000..c66fab1 --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_51_1.txt @@ -0,0 +1 @@ +lldpRemSysDesc.0.51.1 = HPE Comware Platform Software, Software Version 7.1.045, Release 1152 diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_52_1.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_52_1.txt new file mode 100644 index 0000000..e5bdc8f --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/getMIB_lldpRemSysDesc_0_52_1.txt @@ -0,0 +1 @@ +lldpRemSysDesc.0.52.1 = HPE Comware Platform Software, Software Version 7.1.045, Release 1152 diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device.txt new file mode 100644 index 0000000..c70ba62 --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device.txt @@ -0,0 +1,12 @@ + + LLDP Remote Devices Information + + LocalPort | ChassisId PortId PortDescr SysName + --------- + ------------------ ------------------ --------- ------------------ + 1 | 48 7b 6b 39 88 8b 48 7b 6b 39 88 8b eth0 a1001.atlas.local + 30 | d8 50 e6 c3 a4 2e d8 50 e6 c3 a4 2f enp3s0 a1030.atlas.local + A1 | cc 3e 5f 2f c4 90 Ten-GigabitEthe... Ten-Gi... Coredata + A2 | cc 3e 5f 2f c4 90 Ten-GigabitEthe... Ten-Gi... Coredata + B1 | cc 3e 5f 2f c4 90 Ten-GigabitEthe... Ten-Gi... Coredata + B2 | cc 3e 5f 2f c4 90 Ten-GigabitEthe... Ten-Gi... Coredata + OOBM | cc 3e 5f cf 12 48 Ethernet1/0/30 Ethern... mgs010b diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_1.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_1.txt new file mode 100644 index 0000000..30bf431 --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_1.txt @@ -0,0 +1,20 @@ + + LLDP Remote Device Information Detail + + Local Port : 1 + ChassisType : mac-address + ChassisId : 48 7b 6b 39 88 8b + PortType : mac-address + PortId : 48 7b 6b 39 88 8b + SysName : a1001.atlas.local + System Descr : Debian GNU/Linux 8 (jessie) Linux 4.9.0-0.bpo.6-amd64 #1 ... + PortDescr : eth0 + Pvid : + + System Capabilities Supported : bridge, wlan-access-point, router + System Capabilities Enabled : station-only + + Remote Management Address + Type : ipv4 + Address : 10.10.10.1 + diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_30.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_30.txt new file mode 100644 index 0000000..eed661c --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_30.txt @@ -0,0 +1,22 @@ + + LLDP Remote Device Information Detail + + Local Port : 30 + ChassisType : mac-address + ChassisId : d8 50 e6 c3 a4 2e + PortType : mac-address + PortId : d8 50 e6 c3 a4 2f + SysName : a1030.atlas.local + System Descr : Debian GNU/Linux 10 (buster) Linux 4.19.0-10-amd64 #1 SMP... + PortDescr : enp3s0 + Pvid : + + System Capabilities Supported : bridge, wlan-access-point, router + System Capabilities Enabled : station-only + + Remote Management Address + Type : ipv4 + Address : 172.23.10.30 + Type : ipv6 + Address : fe80::da50:e6ff:fec3:a42e + diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_A1.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_A1.txt new file mode 100644 index 0000000..d53c9be --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_A1.txt @@ -0,0 +1,28 @@ + + LLDP Remote Device Information Detail + + Local Port : A1 + ChassisType : mac-address + ChassisId : cc 3e 5f 2f c4 90 + PortType : interface-name + PortId : Ten-GigabitEthernet0/0/10 + SysName : Coredata + System Descr : HPE Comware Platform Software, Software Version 7.1.045, ... + PortDescr : Ten-GigabitEthernet0/0/10 Interface + Pvid : 1 + + System Capabilities Supported : bridge, router + System Capabilities Enabled : bridge, router + + Remote Management Address + Type : all802 + Address : 00 0f e2 07 f2 e0 + + Poe Plus Information Detail + + Poe Device Type : Type2 PSE + Power Source : Unknown + Power Priority : Unknown + Requested Power Value : 0.0 Watts + Actual Power Value : 0.0 Watts + diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_A2.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_A2.txt new file mode 100644 index 0000000..3d63715 --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_A2.txt @@ -0,0 +1,26 @@ + + Local Port : A2 + ChassisType : mac-address + ChassisId : cc 3e 5f 2f c4 90 + PortType : interface-name + PortId : Ten-GigabitEthernet1/0/10 + SysName : Coredata + System Descr : HPE Comware Platform Software, Software Version 7.1.045, ... + PortDescr : Ten-GigabitEthernet1/0/10 Interface + Pvid : 1 + + System Capabilities Supported : bridge, router + System Capabilities Enabled : bridge, router + + Remote Management Address + Type : all802 + Address : 00 0f e2 07 f2 e0 + + Poe Plus Information Detail + + Poe Device Type : Type2 PSE + Power Source : Unknown + Power Priority : Unknown + Requested Power Value : 0.0 Watts + Actual Power Value : 0.0 Watts + diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_B1.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_B1.txt new file mode 100644 index 0000000..38ae05b --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_B1.txt @@ -0,0 +1,26 @@ + + Local Port : B1 + ChassisType : mac-address + ChassisId : cc 3e 5f 2f c4 90 + PortType : interface-name + PortId : Ten-GigabitEthernet2/0/10 + SysName : Coredata + System Descr : HPE Comware Platform Software, Software Version 7.1.045, ... + PortDescr : Ten-GigabitEthernet2/0/10 Interface + Pvid : 1 + + System Capabilities Supported : bridge, router + System Capabilities Enabled : bridge, router + + Remote Management Address + Type : all802 + Address : 00 0f e2 07 f2 e0 + + Poe Plus Information Detail + + Poe Device Type : Type2 PSE + Power Source : Unknown + Power Priority : Unknown + Requested Power Value : 0.0 Watts + Actual Power Value : 0.0 Watts + diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_B2.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_B2.txt new file mode 100644 index 0000000..8a75e0a --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_ethernet_B2.txt @@ -0,0 +1,26 @@ + + Local Port : B2 + ChassisType : mac-address + ChassisId : cc 3e 5f 2f c4 90 + PortType : interface-name + PortId : Ten-GigabitEthernet3/0/10 + SysName : Coredata + System Descr : HPE Comware Platform Software, Software Version 7.1.045, ... + PortDescr : Ten-GigabitEthernet3/0/10 Interface + Pvid : 1 + + System Capabilities Supported : bridge, router + System Capabilities Enabled : bridge, router + + Remote Management Address + Type : all802 + Address : 00 0f e2 07 f2 e0 + + Poe Plus Information Detail + + Poe Device Type : Type2 PSE + Power Source : Unknown + Power Priority : Unknown + Requested Power Value : 0.0 Watts + Actual Power Value : 0.0 Watts + diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_oobm.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_oobm.txt new file mode 100644 index 0000000..a38d890 --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/show_lldp_info_remote_device_oobm.txt @@ -0,0 +1,19 @@ + + LLDP Remote Device Information Detail + + Local Port : OOBM + ChassisType : mac-address + ChassisId : cc 3e 5f cf 12 48 + PortType : interface-name + PortId : Ethernet1/0/30 + SysName : mgs010b + System Descr : 1910-48 Switch Software Version 5.20.99, Release 1116 + PortDescr : Ethernet1/0/30 Interface + Pvid : + + System Capabilities Supported : bridge, router + System Capabilities Enabled : bridge, router + + Remote Management Address + Type : ipv4 + Address : 172.25.13.10 diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/2920/walkMIB_ifName.txt b/test/unit/mocked_data/test_get_lldp_neighbors/2920/walkMIB_ifName.txt new file mode 100644 index 0000000..9346506 --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/2920/walkMIB_ifName.txt @@ -0,0 +1,64 @@ +ifName.1 = 1 +ifName.2 = 2 +ifName.3 = 3 +ifName.4 = 4 +ifName.5 = 5 +ifName.6 = 6 +ifName.7 = 7 +ifName.8 = 8 +ifName.9 = 9 +ifName.10 = 10 +ifName.11 = 11 +ifName.12 = 12 +ifName.13 = 13 +ifName.14 = 14 +ifName.15 = 15 +ifName.16 = 16 +ifName.17 = 17 +ifName.18 = 18 +ifName.19 = 19 +ifName.20 = 20 +ifName.21 = 21 +ifName.22 = 22 +ifName.23 = 23 +ifName.24 = 24 +ifName.25 = 25 +ifName.26 = 26 +ifName.27 = 27 +ifName.28 = 28 +ifName.29 = 29 +ifName.30 = 30 +ifName.31 = 31 +ifName.32 = 32 +ifName.33 = 33 +ifName.34 = 34 +ifName.35 = 35 +ifName.36 = 36 +ifName.37 = 37 +ifName.38 = 38 +ifName.39 = 39 +ifName.40 = 40 +ifName.41 = 41 +ifName.42 = 42 +ifName.43 = 43 +ifName.44 = 44 +ifName.45 = 45 +ifName.46 = 46 +ifName.47 = 47 +ifName.48 = 48 +ifName.49 = A1 +ifName.50 = A2 +ifName.51 = B1 +ifName.52 = B2 +ifName.270 = Dyn1 +ifName.330 = DEFAULT_VLAN +ifName.4425 = lo0 +ifName.4426 = lo1 +ifName.4427 = lo2 +ifName.4428 = lo3 +ifName.4429 = lo4 +ifName.4430 = lo5 +ifName.4431 = lo6 +ifName.4432 = lo7 +ifName.4433 = oobm0 +ifName.4438 = lo0