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

device.get_vlans() doesn't operate as expected for Cisco IOS / IE switches that support spaces in the vlan name. #1407

Open
1 task done
alphabet5 opened this issue Mar 23, 2021 · 1 comment

Comments

@alphabet5
Copy link

Description of Issue/Question

Note: Please check https://guides.github.com/features/mastering-markdown/
to see how to properly format your request.

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

(Place an x between the square brackets where applicable)

  • Yes
  • [] No

Setup

{
    "uptime": 1212540,
    "vendor": "Cisco",
    "os_version": "IE4000  Software (IE4000-UNIVERSALK9-M), Version 15.2(4)EA9, RELEASE SOFTWARE (fc2)",
    "serial_number": "REMOVED",
    "model": "IE-4000-4TC4G-E",
    "hostname": "Switch",
    "fqdn": "Switch",
    "interface_list": [
        "Vlan1",
        "GigabitEthernet1/1",
        "GigabitEthernet1/2",
        "GigabitEthernet1/3",
        "GigabitEthernet1/4",
        "FastEthernet1/5",
        "FastEthernet1/6",
        "FastEthernet1/7",
        "FastEthernet1/8"
    ]
}

napalm version

(Paste verbatim output from pip freeze | grep napalm between quotes below)

napalm==3.2.0

Network operating system version

(Paste verbatim output from show version - or equivalent - between quotes below)

IE4000  Software (IE4000-UNIVERSALK9-M), Version 15.2(4)EA9, RELEASE SOFTWARE (fc2)

Steps to Reproduce the Issue

  1. Create a vlan with a space in the name on the switch.
  2. Run device.get_vlans()

Looking at sh vlan br from the switch

Switch#sh vlan br

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Gi1/3, Gi1/4
10   PLC CONTROL NETWORK              active    Fa1/6, Fa1/7
14   OTHER IO NETWORK                  active    Gi1/2, Fa1/5, Fa1/8
1002 fddi-default                     act/unsup
1003 token-ring-default               act/unsup
1004 fddinet-default                  act/unsup
1005 trnet-default                    act/unsup

Looking at device.get_vlans()

{
    "1": {
        "name": "default",
        "interfaces": [
            "GigabitEthernet1/1",
            "GigabitEthernet1/3",
            "GigabitEthernet1/4"
        ]
    },
    "10": {
        "name": "PLC",
        "interfaces": []
    },
    "14": {
        "name": "OTHER",
        "interfaces": []
    },
    "1002": {
        "name": "fddi-default",
        "interfaces": [
            "GigabitEthernet1/1"
        ]
    },
    "1003": {
        "name": "token-ring-default",
        "interfaces": [
            "GigabitEthernet1/1"
        ]
    },
    "1004": {
        "name": "fddinet-default",
        "interfaces": [
            "GigabitEthernet1/1"
        ]
    },
    "1005": {
        "name": "trnet-default",
        "interfaces": [
            "GigabitEthernet1/1"
        ]
    }
}

I've traced it down to the regex on line ~3589 of _get_vlans_by_id in napalm/napalm/ios/ios.py, which doesn't support spaces in the vlan names.

interface_regex = r"{}\s+{}\s+\S+\s+([A-Z][a-z].*)$".format(
            vlan_id, vlan_name
        )

Error Traceback

(Paste the complete traceback of the exception between quotes below)

N/A
@network-shark
Copy link
Contributor

@alphabet5 Can you check the latest napalm version , if this works for you ? I have fixed it in #2010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants