From c78fd09304c08a8d7c4852081206f5c49971ecb5 Mon Sep 17 00:00:00 2001 From: Brad Walker Date: Sat, 16 May 2020 13:02:21 -0600 Subject: [PATCH 1/3] Add invalid mtu to get_interfaces --- napalm_vyos/vyos.py | 1 + .../mocked_data/test_get_interfaces/normal/expected_result.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/napalm_vyos/vyos.py b/napalm_vyos/vyos.py index c2d87d8..670f4bb 100644 --- a/napalm_vyos/vyos.py +++ b/napalm_vyos/vyos.py @@ -349,6 +349,7 @@ class VyOSDriver(NetworkDriver): "is_enabled": bool(is_enabled), "description": py23_compat.text_type(description), "last_flapped": float(-1), + "mtu": -1, "speed": int(speed), "mac_address": py23_compat.text_type(hw_id) } diff --git a/test/unit/mocked_data/test_get_interfaces/normal/expected_result.json b/test/unit/mocked_data/test_get_interfaces/normal/expected_result.json index d4bf26f..2df2314 100644 --- a/test/unit/mocked_data/test_get_interfaces/normal/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces/normal/expected_result.json @@ -1 +1 @@ -{"lo": {"is_enabled": true, "description": "", "last_flapped": -1.0, "is_up": true, "mac_address": "00:00:00:00:00:00", "speed": 0}, "eth1": {"is_enabled": true, "description": "", "last_flapped": -1.0, "is_up": true, "mac_address": "...", "speed": 0}, "eth0": {"is_enabled": true, "description": "", "last_flapped": -1.0, "is_up": true, "mac_address": "...", "speed": 0}} +{"lo": {"is_enabled": true, "description": "", "last_flapped": -1.0, "is_up": true, "mac_address": "00:00:00:00:00:00", "mtu": -1, "speed": 0}, "eth1": {"is_enabled": true, "description": "", "last_flapped": -1.0, "is_up": true, "mac_address": "...", "mtu": -1, "speed": 0}, "eth0": {"is_enabled": true, "description": "", "last_flapped": -1.0, "is_up": true, "mac_address": "...", "mtu": -1, "speed": 0}} From b883dcbbb06f33941ef9d27bb0d0ebb4e2437666 Mon Sep 17 00:00:00 2001 From: Brad Walker Date: Sat, 16 May 2020 13:02:57 -0600 Subject: [PATCH 2/3] Bump to 0.1.7 and require NAPALM 2.5 --- .travis.yml | 5 +++-- requirements.txt | 4 ++-- setup.py | 6 +++--- tox.ini | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index c43fe17..d8982f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ language: python python: - 2.7 -- 3.4 -- 3.5 +- 3.6 +- 3.7 +- 3.8 install: - pip install tox-travis - pip install coveralls diff --git a/requirements.txt b/requirements.txt index 50c91a5..b8b9ff5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -napalm==2.* +napalm>=2.5,<3.0 paramiko -netmiko>=1.1.0 +netmiko<3.0 vyattaconfparser diff --git a/setup.py b/setup.py index bf90a64..e2a096a 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ __author__ = 'Piotr Pieprzycki ' setup( name="napalm-vyos", - version="0.1.6", + version="0.1.7", packages=find_packages(), author="Piotr Pieprzycki", author_email="piotr.pieprzycki@dreamlab.pl", @@ -22,9 +22,9 @@ setup( 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Operating System :: POSIX :: Linux', 'Operating System :: MacOS', ], diff --git a/tox.ini b/tox.ini index 9a30816..46e039c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py35 +envlist = py27,py36,py37,py38 [testenv] deps = From 0420304a6dd4c4dcd8e7bc8472828335cd0cc336 Mon Sep 17 00:00:00 2001 From: Brad Walker Date: Sat, 16 May 2020 14:56:38 -0600 Subject: [PATCH 3/3] Implement get_lldp_neighbors() for simple case --- napalm_vyos/vyos.py | 23 +++++++ .../normal/expected_result.json | 1 + .../normal/show_lldp_neighbors_detail.text | 69 +++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 test/unit/mocked_data/test_get_lldp_neighbors/normal/expected_result.json create mode 100644 test/unit/mocked_data/test_get_lldp_neighbors/normal/show_lldp_neighbors_detail.text diff --git a/napalm_vyos/vyos.py b/napalm_vyos/vyos.py index c2d87d8..e5a6212 100644 --- a/napalm_vyos/vyos.py +++ b/napalm_vyos/vyos.py @@ -597,6 +597,29 @@ class VyOSDriver(NetworkDriver): (minutes * self._MINUTE_SECONDS) + seconds) return uptime + def get_lldp_neighbors(self): + # Multiple neighbors per port are not implemented + # The show lldp neighbors commands lists port descriptions, not IDs + output = self.device.send_command("show lldp neighbors detail") + pattern = r'''(?s)Interface: +(?P\S+), [^\n]+ +.+? + +SysName: +(?P\S+) +.+? + +PortID: +ifname (?P\S+)''' + + def _get_interface(match): + return [ + { + 'hostname': match.group('hostname'), + 'port': match.group('port'), + } + ] + + return { + match.group('interface'): _get_interface(match) + for match in re.finditer(pattern, output) + } + def get_interfaces_counters(self): # 'rx_unicast_packet', 'rx_broadcast_packets', 'tx_unicast_packets', # 'tx_multicast_packets' and 'tx_broadcast_packets' are not implemented yet diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/normal/expected_result.json b/test/unit/mocked_data/test_get_lldp_neighbors/normal/expected_result.json new file mode 100644 index 0000000..7eb6370 --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/normal/expected_result.json @@ -0,0 +1 @@ +{"eth1": [{"hostname": "branch", "port": "eth0"}], "eth2": [{"hostname": "dmz", "port": "eth0"}]} diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/normal/show_lldp_neighbors_detail.text b/test/unit/mocked_data/test_get_lldp_neighbors/normal/show_lldp_neighbors_detail.text new file mode 100644 index 0000000..6657bf0 --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors/normal/show_lldp_neighbors_detail.text @@ -0,0 +1,69 @@ +------------------------------------------------------------------------------- +LLDP neighbors: +------------------------------------------------------------------------------- +Interface: eth1, via: LLDP, RID: 2, Time: 1 day, 18:17:44 + Chassis: + ChassisID: mac 52:54:00:99:84:8a + SysName: branch + SysDescr: VyOS 1.3-rolling-202005151915 + MgmtIP: 10.0.0.3 + Capability: Bridge, off + Capability: Router, on + Capability: Wlan, off + Capability: Station, off + Port: + PortID: ifname eth0 + PortDescr: to DC + TTL: 120 + PMD autoneg: supported: yes, enabled: yes + Adv: 10Base-T, HD: yes, FD: yes + Adv: 100Base-TX, HD: yes, FD: yes + MAU oper type: 100BaseTXFD - 2 pair category 5 UTP, full duplex mode + LLDP-MED: + Device Type: Network Connectivity Device + Capability: Capabilities, yes + Capability: Policy, yes + Capability: Location, yes + Capability: MDI/PSE, yes + Capability: MDI/PD, yes + Capability: Inventory, yes + Inventory: + Hardware Revision: pc-i440fx-4.2 + Software Revision: 4.19.122-amd64-vyos + Firmware Revision: 1.13.0-1ubuntu1 + Manufacturer: QEMU + Model: Standard PC (i440FX + PIIX, 1996 +------------------------------------------------------------------------------- +Interface: eth2, via: LLDP, RID: 1, Time: 1 day, 18:17:45 + Chassis: + ChassisID: mac 52:54:00:98:e5:9f + SysName: dmz + SysDescr: VyOS 1.3-rolling-202005151915 + MgmtIP: 10.0.0.2 + Capability: Bridge, off + Capability: Router, on + Capability: Wlan, off + Capability: Station, off + Port: + PortID: ifname eth0 + PortDescr: to DC + TTL: 120 + PMD autoneg: supported: yes, enabled: yes + Adv: 10Base-T, HD: yes, FD: yes + Adv: 100Base-TX, HD: yes, FD: yes + MAU oper type: 100BaseTXFD - 2 pair category 5 UTP, full duplex mode + LLDP-MED: + Device Type: Network Connectivity Device + Capability: Capabilities, yes + Capability: Policy, yes + Capability: Location, yes + Capability: MDI/PSE, yes + Capability: MDI/PD, yes + Capability: Inventory, yes + Inventory: + Hardware Revision: pc-i440fx-4.2 + Software Revision: 4.19.122-amd64-vyos + Firmware Revision: 1.13.0-1ubuntu1 + Manufacturer: QEMU + Model: Standard PC (i440FX + PIIX, 1996 +------------------------------------------------------------------------------- \ No newline at end of file