Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.5.1 #101

Merged
merged 22 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/FastTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ on:
branches-ignore:
- develop
- master
pull_request:
branches-ignore:
- develop
- master

jobs:

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/PublishToPIP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/ThoroughTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ on:
branches:
- develop
- master
pull_request:
branches:
- develop
- master
# check every 14 days
schedule:
- cron: '0 6 5,20 * *'
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

# cfg for getting cmd outputs
test/unit/fetch_command_output.cfg


# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
118 changes: 67 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Napalm-s350

NAPALM driver for Cisco SMB switches (SF3xx, SF5xx, SG3xx, SG5xx, CBS35x).
NAPALM driver for Cisco SMB switches (SF3xx, SF5xx, SG250, SG3xx, SG5xx, CBS35x).

## Status

Expand Down Expand Up @@ -45,58 +45,58 @@ napalm --user USER --password PASSWORD --vendor s350 --debug HOSTNAME

## Supported devices

This driver initially targets the Cisco SG350 device though other, similar, devices may
This driver initially targets the Cisco SG350 device though other, similar, devices are
be supported.

| function | SG300 | SG500 | SG350 | SG550 | stack SG500 | stack SG550 | CBS350 |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| **Send commands** |
| cli | x | x | x | x | x | x | x |
| **Config manipulation** |
|get_config | x | x | x | x | | | x |
|get_config (filtered) | x | x | x | x | | | x |
|get_config (sanitized) | x | x | x | x | | | x |
|load_merge_candidate | | | | | | | |
|load_replace_candidate | | | | | | | |
|compare_config | | | | | | | |
|commit_config | | | | | | | |
|confirm_commit | | | | | | | |
|has_pending_commit | | | | | | | |
|rollback | | | | | | | |
|discard_config | | | | | | | |
|compliance_report | | | | | | | |
|load_template | | | | | | | |
| **Get information** |
|get_arp_table | x | x | x | x | | | x |
|get_arp_table (with vrf) | NS | NS | NS | NS | | | NS |
|get_bgp_config | | | | | | | |
|get_bgp_neighbors | | | | | | | |
|get_bgp_neighbors_detail | | | | | | | |
|get_environment | | | | | | | |
|get_facts | x | x | x | x | | | x |
|get_firewall_policies | | | | | | | |
|get_interfaces | x | x | x | x | | | x |
|get_interfaces_counters | | | | | | | |
|get_interfaces_ip | x 4 | x 4 | x 4 | x 4 | | | x 4 |
|get_ipv6_neighbors_table | | | | | | | |
|get_lldp_neighbors | x | x | x | x | | | x |
|get_lldp_neighbors_detail | x | x | x | x | | | x |
|get_mac_address_table | | | | | | | |
|get_network_instances | | | | | | | |
|get_ntp_peers | | | | | | | |
|get_ntp_servers | x | x | x | x | | | x |
|get_ntp_stats | | | | | | | |
|get_optics | | | | | | | |
|get_probes_config | | | | | | | |
|get_probes_results | | | | | | | |
|get_route_to | | | | | | | |
|get_snmp_information | | | | | | | |
|get_users | | | | | | | |
|get_vlans | x | x | x | x | | | x |
| **Other actions** |
|is_alive | | | | | | | |
|ping | | | | | | | |
|traceroute | | | | | | | |
| function | SG250 | SG300 | SG500 | SG350 | SG550 | stack SG500 | stack SG550 | CBS350 |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| **Send commands** |
| cli | x | x | x | x | x | x | x | x |
| **Config manipulation** |
|get_config | x | x | x | x | x | | | x |
|get_config (filtered) | x | x | x | x | x | | | x |
|get_config (sanitized) | x | x | x | x | x | | | x |
|load_merge_candidate | | | | | | | | |
|load_replace_candidate | | | | | | | | |
|compare_config | | | | | | | | |
|commit_config | | | | | | | | |
|confirm_commit | | | | | | | | |
|has_pending_commit | | | | | | | | |
|rollback | | | | | | | | |
|discard_config | | | | | | | | |
|compliance_report | | | | | | | | |
|load_template | | | | | | | | |
| **Get information** |
|get_arp_table | x | x | x | x | x | | | x |
|get_arp_table (with vrf) | NS | NS | NS | NS | NS | | | NS |
|get_bgp_config | | | | | | | | |
|get_bgp_neighbors | | | | | | | | |
|get_bgp_neighbors_detail | | | | | | | | |
|get_environment | | | | | | | | |
|get_facts | x | x | x | x | x | | | x |
|get_firewall_policies | | | | | | | | |
|get_interfaces | x | x | x | x | x | | | x |
|get_interfaces_counters | | | | | | | | |
|get_interfaces_ip | x 4 | x 4 | x 4 | x 4 | x 4 | | | x 4 |
|get_ipv6_neighbors_table | | | | | | | | |
|get_lldp_neighbors | x | x | x | x | x | | | x |
|get_lldp_neighbors_detail | x | x | x | x | x | | | x |
|get_mac_address_table | | | | | | | | |
|get_network_instances | | | | | | | | |
|get_ntp_peers | | | | | | | | |
|get_ntp_servers | x | x | x | x | x | | | x |
|get_ntp_stats | | | | | | | | |
|get_optics | | | | | | | | |
|get_probes_config | | | | | | | | |
|get_probes_results | | | | | | | | |
|get_route_to | | | | | | | | |
|get_snmp_information | | | | | | | | |
|get_users | | | | | | | | |
|get_vlans | x | x | x | x | x | | | x |
| **Other actions** |
|is_alive | x | x | x | x | x | x | x | x |
|ping | | | | | | | | |
|traceroute | | | | | | | | |


NS - not supported - devices do not have support for that feature
Expand All @@ -106,6 +106,22 @@ NS - not supported - devices do not have support for that feature

To be sure we can support new device we use test files.

### Fetch command output tool
There is tool for getting necessary infromatin form running switch
```
cd test/unit

# DEVICE_TYPE as PID: in "show inventory" output
# INTERFACE an inteface
# LLDP_INTERFACE inteface for getting LLDP inforation
./fetch_command_output.sh -u USER -p PASSWORD -t DEVICE_TYPE -v s350 \
-d SWITCH_IP_or_FQDN -i INTERFACE -l LLDP_INTERFACE
```

Output files from that tool are in "test/unit/command_output/$DEVICE_TYPE"

### By hand

We need text output of those commands, to add new device:
```
show arp
Expand Down
23 changes: 19 additions & 4 deletions napalm_s350/s350.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ def _send_command(self, command):
try:
if isinstance(command, list):
for cmd in command:
output = self.device.send_command(cmd)
output = self.device.send_command(cmd, read_timeout=self.timeout)
if "% Invalid" not in output:
break
else:
output = self.device.send_command(command)
output = self.device.send_command(command, read_timeout=self.timeout)
return output.strip()
except (socket.error, EOFError) as e:
raise ConnectionClosedException(str(e))
Expand Down Expand Up @@ -245,13 +245,28 @@ def get_facts(self):
uptime = self._parse_uptime(uptime_str)

# serial_number and model
# take first device
inventory = self._get_facts_parse_inventory(show_inv)["1"]
serial_number = inventory["sn"]
model = inventory["pid"]

# fqdn
domainname = napalm.base.helpers.textfsm_extractor(self, "hosts", show_hosts)[0]
domainname = domainname["domain_name"]
# take first domain name
domainname = "Unknown"
atDTh = False
atDT = False
for line in show_hosts.splitlines():
if line.startswith("Default Domain Table"):
atDTh = True
continue
if atDTh and line.startswith("--------"):
atDT = True
continue
if atDT:
fields = line.split(" ")
domainname = fields[0]
break

if domainname == "Domain":
domainname = "Unknown"
if domainname != "Unknown" and hostname != "Unknown":
Expand Down
1 change: 0 additions & 1 deletion napalm_s350/utils/__init__.py

This file was deleted.

8 changes: 0 additions & 8 deletions napalm_s350/utils/textfsm_templates/hosts.tpl

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="napalm-s350",
version="0.5.0",
version="0.5.1",
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",
Expand Down
10 changes: 10 additions & 0 deletions test/unit/command_output/SG250-10P/show_arp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Total number of entries: 5


VLAN Interface IP address HW address status
--------------------- --------------- ------------------- ---------------
vlan 1 gi10 30.70.0.3 00:00:0a:0a:aa:02 dynamic
vlan 1 gi10 30.70.0.3 a0:02:aa:aa:fa:aa dynamic
vlan 1 gi10 30.70.0.3 a0:02:aa:aa:fa:aa dynamic
vlan 1 gi10 30.70.3.33 00:a0:a2:a2:2f:a2 dynamic
vlan 1 gi10 30.70.33.3 aa:a2:a2:aa:fa:2a dynamic
38 changes: 38 additions & 0 deletions test/unit/command_output/SG250-10P/show_hosts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Name/address lookup is enabled
Domain Timeout: 2 seconds
Domain Retry: 1 times
Domain Polling Interval: 8 seconds


Default Domain Table

Domain Source Interface Preference
-------------------------------------------- ------- --------- ----------
Domain name is not configured


Name Server Table

IP Address Source Interface Preference
-------------------------------------------- ------- --------- ----------
30.70.3.33 static 1


Cache Table
Flags: (STA/DYN, OK/NE/??)
STA - Static, DYN - Dynamic
OK - Okay, NE - Negative Cache, ?? - No Response

Remaining
Host Addresses Type State TTL
------------------------- ------------------------ ---- ------ ----------
tftp 30.70.3.33 IPv4 STA,OK
ntp.examples.com 30.70.3.33 IPv4 DYN,OK 0003:38:43
ntp.examples.com no resolution IPv6 DYN,??
ntp.ph.examp.com 30.30.3.33 IPv4 DYN,OK 0003:38:43
ntp.ph.examp.com no resolution IPv6 DYN,??
pnpserver.qqq.aa no resolution IPv6 DYN,NE 0020:55:13
pnpserver.qqq.aa no resolution IPv4 DYN,NE 0020:55:13
pingu.examples.com 30.70.3.33 IPv4 DYN,OK 0003:38:43
ns-cb-1.examples.com 30.70.3.300 IPv4 DYN,OK 0003:38:43
ns-cb-2.examples.com 30.70.3.300 IPv4 DYN,OK 0003:38:43
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Gathering information...

Name: gi1
Switchport: enable
Administrative Mode: access
Operational Mode: up
Access Mode VLAN: 1
Trunking Native Mode VLAN: 1
Trunking VLANs: 1,7-8,10-11,30-31,100,200,480,490-491,1000-1001
2-6,9,12-29,32-99,101-199,201-479,481-489,492-999,
1002-4094 (Inactive)
General PVID: 1
General VLANs: none
General Egress Tagged VLANs: none
General Forbidden VLANs: none
General Ingress Filtering: enabled
General Acceptable Frame Type: all
General GVRP status: disabled
Customer Mode VLAN: none



Classification rules:
19 changes: 19 additions & 0 deletions test/unit/command_output/SG250-10P/show_interfaces_description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Port Description
------- -----------
gi1
gi2
gi3
gi4
gi5
gi6
gi7
gi8
gi9
gi10 Trunk to switchkuch-1

Ch Description
------- -----------
Po1
Po2
Po3
Po4
21 changes: 21 additions & 0 deletions test/unit/command_output/SG250-10P/show_interfaces_status.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Flow Link Back Mdix
Port Type Duplex Speed Neg ctrl State Pressure Mode
-------- ------------ ------ ----- -------- ---- ----------- -------- -------
gi1 1G-Copper Half 10 Enabled Off Up Disabled On
gi2 1G-Copper Half 10 Enabled Off Up Disabled On
gi3 1G-Copper Full 1000 Enabled Off Up Disabled Off
gi4 1G-Copper Full 100 Enabled Off Up Disabled On
gi5 1G-Copper Full 100 Enabled Off Up Disabled On
gi6 1G-Copper Full 100 Enabled Off Up Disabled On
gi7 1G-Copper Half 10 Enabled Off Up Disabled On
gi8 1G-Copper Full 100 Enabled Off Up Disabled Off
gi9 1G-Combo-C -- -- -- -- Down -- --
gi10 1G-Combo-C Full 100 Enabled Off Up Disabled Off

Flow Link
Ch Type Duplex Speed Neg control State
-------- ------- ------ ----- -------- ------- -----------
Po1 -- -- -- -- -- Not Present
Po2 -- -- -- -- -- Not Present
Po3 -- -- -- -- -- Not Present
Po4 -- -- -- -- -- Not Present
2 changes: 2 additions & 0 deletions test/unit/command_output/SG250-10P/show_inventory.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NAME: "1" DESCR: "SG250-10P 10-Port Gigabit PoE Smart Switch"
PID: SG250-10P-K9 VID: V04 SN: ABC12234XYZ
4 changes: 4 additions & 0 deletions test/unit/command_output/SG250-10P/show_ip_interface.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
IP Address I/F I/F Status Type Directed Prec Redirect Status
admin/oper Broadcast
------------------ --------- ---------- ------- --------- ---- -------- ------
30.70.0.37/17 vlan 1 UP/UP Static disable No enable Valid
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Interface Interface IPv6 Link Local MLD Number of
State State IPv6 Address Version Global Addresses
---------- --------- --------- ------------------------- ------- ----------------
vlan 1 up/up enabled fe80::c644:a0ff:fe3b:17d2 2 0
Loading