napalm-automation-community / napalm-s350

NAPALM driver for Cisco SMB switches (SF3xx, SF5xx, SG3xx, SG5xx).
Apache License 2.0
16 stars 13 forks source link

Incorrect Parsing of show interfaces status on SG300 #59

Closed nniehoff closed 3 years ago

nniehoff commented 3 years ago

I have a couple of SG300-28s. When testing get_interfaces I get the following stack trace:

Traceback (most recent call last):
  File "/source/napalm_example.py", line 24, in <module>
    nick = device.get_interfaces()
  File "/root/.cache/pypoetry/virtualenvs/home-python-PmaILF-S-py3.9/lib/python3.9/site-packages/napalm_s350/s350.py", line 293, in get_interfaces
    interface, _, _, speed, _, _, link_state, _, _ = status_line.split()
ValueError: not enough values to unpack (expected 9, got 7)

Looking at the switch itself in this case the output of show interfaces status is:

#show interfaces status
                                             Flow Link          Back   Mdix
Port     Type         Duplex  Speed Neg      ctrl State       Pressure Mode
-------- ------------ ------  ----- -------- ---- ----------- -------- -------
gi1      1G-Copper    Full    1000  Enabled  Off  Up          Disabled On
gi2      1G-Copper      --      --     --     --  Down           --     --
gi3      1G-Copper    Full    1000  Enabled  Off  Up          Disabled Off
gi4      1G-Copper    Full    1000  Enabled  Off  Up          Disabled Off
gi5      1G-Copper    Full    1000  Enabled  Off  Up          Disabled Off
gi6      1G-Copper    Full    100   Enabled  Off  Up          Disabled On
gi7      1G-Copper    Full    100   Enabled  Off  Up          Disabled On
gi8      1G-Copper      --      --     --     --  Down           --     --
gi9      1G-Copper      --      --     --     --  Down           --     --
gi10     1G-Copper      --      --     --     --  Down           --     --
gi11     1G-Copper    Full    1000  Enabled  Off  Up          Disabled On
gi12     1G-Copper    Full    1000  Enabled  Off  Up          Disabled Off
gi13     1G-Copper      --      --     --     --  Down           --     --
gi14     1G-Copper      --      --     --     --  Down           --     --
gi15     1G-Copper    Full    1000  Enabled  Off  Up          Disabled On
gi16     1G-Copper    Full    1000  Enabled  Off  Up          Disabled On
gi17     1G-Copper    Full    1000  Enabled  Off  Up          Disabled Off
gi18     1G-Copper    Full    1000  Enabled  Off  Up          Disabled On
gi19     1G-Copper    Full    100   Enabled  Off  Up          Disabled Off
gi20     1G-Copper      --      --     --     --  Down           --     --
gi21     1G-Copper      --      --     --     --  Down           --     --
gi22     1G-Copper      --      --     --     --  Down           --     --
gi23     1G-Copper    Full    1000  Enabled  Off  Up          Disabled On
gi24     1G-Copper    Full    1000  Enabled  Off  Up          Disabled On
gi25     1G-Copper    Full    1000  Enabled  Off  Up          Disabled On
gi26     1G-Copper    Full    1000  Enabled  Off  Up          Disabled On
gi27     1G-Combo-C     --      --     --     --  Down           --     --
gi28     1G-Combo-C     --      --     --     --  Down           --     --

                                          Flow    Link
Ch       Type    Duplex  Speed  Neg      control  State
-------- ------- ------  -----  -------- -------  -----------
Po1      1G      Full    1000   Enabled  Off      Up
Po2         --     --      --      --       --    Not Present
Po3         --     --      --      --       --    Not Present
Po4      1G      Full    1000   Enabled  Off      Up
Po5         --     --      --      --       --    Not Present
Po6         --     --      --      --       --    Not Present
Po7         --     --      --      --       --    Not Present
Po8         --     --      --      --       --    Not Present

Debugging a bit the parser is incorrect for Port-Channel interfaces. I did this testing with the current master branch. I had a similar issue with 0.2.3 but with the recent changes for the SG300 series I thought I would try master and I get a bit further.

Phill93 commented 3 years ago

Could you please try this? -> #60

nniehoff commented 3 years ago

@Phill93 Looks good, thanks. I went ahead and tested the following as well for the SG300:

pprint(device.get_config())
pprint(device.get_config(full=True))
pprint(device.get_facts())
pprint(device.get_interfaces_ip())
pprint(device.get_lldp_neighbors())
pprint(device.get_lldp_neighbors_detail())
pprint(device.get_ntp_servers())

They all look good. Let me know if there is anything else you'd like me to test. Any idea when the next point release will be available?