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

[IOS][get_vlans()] Parse VLAN IDs when private VLANs are implemented #1994

Draft
wants to merge 47 commits into
base: develop
Choose a base branch
from

Conversation

vvas1lev
Copy link

@vvas1lev vvas1lev commented Aug 24, 2023

=================
PRIMARY VLAN 2400
=================

XXX#sh vlan id 2400
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
2400 Vlan2400                         active    Po1
VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
2400 enet  102400     1500  -      -      -        -    -        0      0
Remote SPAN VLAN
----------------
Disabled
Primary Secondary Type              Ports
------- --------- ----------------- ------------------------------------------
2400    2432      community         Gi0/1, Gi0/2
2400    2433      community         Gi0/3, Gi0/4

===================
SECONDARY VLAN 2432
===================

XXX#sh vlan id 2432
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
2432 Vlan2432                         active    Po1
VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
2432 enet  102432     1500  -      -      -        -    -        0      0
Remote SPAN VLAN
----------------
Disabled
Primary Secondary Type              Ports
------- --------- ----------------- ------------------------------------------
2400    2432      community         Gi0/1, Gi0/2
Traceback (most recent call last):
  File "C:\Users\XXX\dev\python\net_tool\main.py", line 39, in <module>
    vlans = device.get_vlans()
            ^^^^^^^^^^^^^^^^^^
  File "C:\Users\XXX\dev\python\net_tool\venv\Lib\site-packages\napalm\ios\ios.py", line 3724, in get_vlans
    return self._get_vlan_from_id()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\XXX\dev\python\net_tool\venv\Lib\site-packages\napalm\ios\ios.py", line 3795, in _get_vlan_from_id
    raise ValueError(
ValueError: Error parsing vlan_id 2432, found more values than can be present.

This change results in properly parsing the primary & secondary VLAN IDs.

@vvas1lev vvas1lev marked this pull request as ready for review August 25, 2023 08:58
@vvas1lev vvas1lev changed the title [IOS] Parse VLAN IDs when private VLANs are implemented [IOS][get_vlans()] Parse VLAN IDs when private VLANs are implemented Aug 27, 2023
@mirceaulinic
Copy link
Member

@vvas1lev it seems like there's a conflict after merging #2010 (sorry!) - could you take took please?

@vvas1lev
Copy link
Author

vvas1lev commented Mar 23, 2024

@mirceaulinic > @vvas1lev it seems like there's a conflict after merging #2010 (sorry!) - could you take took please?

Took a quick look but github actions (black) is failing despite it all being OK locally. I'll have another look some time next week.

(venv) X@X napalm % black --check .
All done! ✨ 🍰 ✨
110 files would be left unchanged.

@ktbyers
Copy link
Contributor

ktbyers commented Mar 23, 2024

@vvas1lev Which version of black do you have installed?

It needs to be black verson:

black-24.3.0

@vvas1lev
Copy link
Author

@ktbyers that was it... thanks!

@vvas1lev vvas1lev marked this pull request as draft March 23, 2024 12:12
@mirceaulinic mirceaulinic added this to the 5.0.0 milestone Mar 24, 2024
@mirceaulinic
Copy link
Member

@vvas1lev - FYI the tests are still failing...

continue
else:
vlan_id = vlan_m.group(1)
vlan_name = _vlan_name if _vlan_name else vlan_name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably need to add a strip call on this line somewhere given the failing test output

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave this a try, and even with a strip() the tests would need the following in order to pass with this code:

diff --git a/test/ios/mocked_data/test_get_vlans/no_show_vlan_all_ports/expected_result.json b/test/ios/mocked_data/test_get_vlans/no_show_vlan_all_ports/expected_result.json
index da9cd8e0..ec258ac5 100644
--- a/test/ios/mocked_data/test_get_vlans/no_show_vlan_all_ports/expected_result.json
+++ b/test/ios/mocked_data/test_get_vlans/no_show_vlan_all_ports/expected_result.json
@@ -227,15 +227,13 @@
   "2432": {
     "name": "Vlan2432",
     "interfaces": [
-      "GigabitEthernet0/1",
-      "GigabitEthernet0/2"
+      "Port-channel1"
     ]
   },
   "2433": {
     "name": "Vlan2433",
     "interfaces": [
-      "GigabitEthernet0/3",
-      "GigabitEthernet0/4"
+      "Port-channel1"
     ]
   }
 }

So I believe there's more work required in this PR, re-scheduling for the next release.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mirceaulinic @bewing I figured it'd need more work, which is why I changed it back to draft. I'm just back from PTO, will take a look at this coming week.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool - thanks for the heads up @vvas1lev!

@mirceaulinic mirceaulinic removed this from the 5.0.0 milestone Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants