-
Notifications
You must be signed in to change notification settings - Fork 563
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
Add get_vlans for Junos #1398
Merged
mirceaulinic
merged 5 commits into
napalm-automation:develop
from
minefuto:junos_get_vlans
Mar 22, 2021
+374
−0
Merged
Add get_vlans for Junos #1398
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7f472a4
Add get_vlans for Junos
minefuto c8284ad
Add test_get_vlans for Junos
minefuto f519d24
Fix get_vlans issue of bridge-domain interface is None
minefuto 09fe92f
Add test_get_vlans issue of bridge-domain interface is None
minefuto 87dcb22
Merge branch 'develop' into junos_get_vlans
mirceaulinic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
test/junos/mocked_data/test_get_vlans/bridge_domain/expected_result.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"10": { | ||
"name": "VLAN10", | ||
"interfaces": [ | ||
"ge-2/0/1.0", | ||
"ge-2/0/2.0", | ||
"ge-2/0/3.0" | ||
] | ||
}, | ||
"2": { | ||
"name": "VLAN2", | ||
"interfaces": [ | ||
"ge-2/0/1.0" | ||
] | ||
}, | ||
"300": { | ||
"name": "VLAN300", | ||
"interfaces": [] | ||
}, | ||
"4000": { | ||
"name": "VLAN4000", | ||
"interfaces": [ | ||
"xe-1/0/0.0", | ||
"xe-1/2/0.0" | ||
] | ||
}, | ||
"4001": { | ||
"name": "VLAN4001", | ||
"interfaces": [] | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
test/junos/mocked_data/test_get_vlans/bridge_domain/facts.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
personality: MX | ||
switch_style: BRIDGE_DOMAIN |
35 changes: 35 additions & 0 deletions
35
test/junos/mocked_data/test_get_vlans/bridge_domain/get-bridge-instance-information.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<l2ald-bridge-instance-information> | ||
<l2ald-bridge-instance-group> | ||
<l2rtb-brief-summary/> | ||
<l2rtb-name>default-switch</l2rtb-name> | ||
<l2rtb-bridging-domain>VLAN10</l2rtb-bridging-domain> | ||
<l2rtb-bridge-vlan>10</l2rtb-bridge-vlan> | ||
<l2rtb-interface-name>ge-2/0/1.0</l2rtb-interface-name> | ||
<l2rtb-interface-name>ge-2/0/2.0</l2rtb-interface-name> | ||
<l2rtb-interface-name>ge-2/0/3.0</l2rtb-interface-name> | ||
</l2ald-bridge-instance-group> | ||
<l2ald-bridge-instance-group> | ||
<l2rtb-name>default-switch</l2rtb-name> | ||
<l2rtb-bridging-domain>VLAN2</l2rtb-bridging-domain> | ||
<l2rtb-bridge-vlan>2</l2rtb-bridge-vlan> | ||
<l2rtb-interface-name>ge-2/0/1.0</l2rtb-interface-name> | ||
</l2ald-bridge-instance-group> | ||
<l2ald-bridge-instance-group> | ||
<l2rtb-name>default-switch</l2rtb-name> | ||
<l2rtb-bridging-domain>VLAN300</l2rtb-bridging-domain> | ||
<l2rtb-bridge-vlan>300</l2rtb-bridge-vlan> | ||
<l2rtb-interface-name/> | ||
</l2ald-bridge-instance-group> | ||
<l2ald-bridge-instance-group> | ||
<l2rtb-name>default-switch</l2rtb-name> | ||
<l2rtb-bridging-domain>VLAN4000</l2rtb-bridging-domain> | ||
<l2rtb-bridge-vlan>4000</l2rtb-bridge-vlan> | ||
<l2rtb-interface-name>xe-1/0/0.0</l2rtb-interface-name> | ||
<l2rtb-interface-name>xe-1/2/0.0</l2rtb-interface-name> | ||
</l2ald-bridge-instance-group> | ||
<l2ald-bridge-instance-group> | ||
<l2rtb-name>default-switch</l2rtb-name> | ||
<l2rtb-bridging-domain>VLAN4001</l2rtb-bridging-domain> | ||
<l2rtb-bridge-vlan>4001</l2rtb-bridge-vlan> | ||
</l2ald-bridge-instance-group> | ||
</l2ald-bridge-instance-information> |
33 changes: 33 additions & 0 deletions
33
test/junos/mocked_data/test_get_vlans/vlan/expected_result.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"10": { | ||
"name": "VLAN10", | ||
"interfaces": [ | ||
"ge-0/0/1.0", | ||
"ge-0/0/2.0", | ||
"ge-0/0/3.0" | ||
] | ||
}, | ||
"2": { | ||
"name": "VLAN2", | ||
"interfaces": [ | ||
"ge-0/0/1.0" | ||
] | ||
}, | ||
"300": { | ||
"name": "VLAN300", | ||
"interfaces": [] | ||
}, | ||
"4000": { | ||
"name": "VLAN4000", | ||
"interfaces": [ | ||
"ge-0/0/4.0", | ||
"ge-0/0/5.0" | ||
] | ||
}, | ||
"0": { | ||
"name": "default", | ||
"interfaces": [ | ||
"ge-0/0/0.0" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
personality: SWITCH | ||
switch_style: VLAN |
114 changes: 114 additions & 0 deletions
114
test/junos/mocked_data/test_get_vlans/vlan/get-vlan-information.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<vlan-information> | ||
<vlan-terse/> | ||
<vlan> | ||
<vlan-instance>0</vlan-instance> | ||
<vlan-name>VLAN10</vlan-name> | ||
<vlan-create-time>Fri Mar 12 11:32:21 2021 | ||
</vlan-create-time> | ||
<vlan-status>Enabled</vlan-status> | ||
<vlan-owner>static</vlan-owner> | ||
<vlan-tag>10</vlan-tag> | ||
<vlan-tag-string>10</vlan-tag-string> | ||
<vlan-index>53</vlan-index> | ||
<vlan-protocol-port>Port Mode</vlan-protocol-port> | ||
<vlan-members-count>3</vlan-members-count> | ||
<vlan-members-upcount>1</vlan-members-upcount> | ||
<vlan-detail> | ||
<vlan-member-list> | ||
<vlan-member> | ||
<vlan-member-interface>ge-0/0/1.0*</vlan-member-interface> | ||
</vlan-member> | ||
<vlan-member> | ||
<vlan-member-interface>ge-0/0/2.0</vlan-member-interface> | ||
</vlan-member> | ||
<vlan-member> | ||
<vlan-member-interface>ge-0/0/3.0</vlan-member-interface> | ||
</vlan-member> | ||
</vlan-member-list> | ||
</vlan-detail> | ||
</vlan> | ||
<vlan> | ||
<vlan-instance>0</vlan-instance> | ||
<vlan-name>VLAN2</vlan-name> | ||
<vlan-create-time>Fri Mar 12 11:32:21 2021 | ||
</vlan-create-time> | ||
<vlan-status>Enabled</vlan-status> | ||
<vlan-owner>static</vlan-owner> | ||
<vlan-tag>2</vlan-tag> | ||
<vlan-tag-string>2</vlan-tag-string> | ||
<vlan-index>54</vlan-index> | ||
<vlan-protocol-port>Port Mode</vlan-protocol-port> | ||
<vlan-members-count>1</vlan-members-count> | ||
<vlan-members-upcount>1</vlan-members-upcount> | ||
<vlan-detail> | ||
<vlan-member-list> | ||
<vlan-member> | ||
<vlan-member-interface>ge-0/0/1.0*</vlan-member-interface> | ||
</vlan-member> | ||
</vlan-member-list> | ||
</vlan-detail> | ||
</vlan> | ||
<vlan> | ||
<vlan-instance>0</vlan-instance> | ||
<vlan-name>VLAN300</vlan-name> | ||
<vlan-create-time>Fri Mar 12 11:32:21 2021 | ||
</vlan-create-time> | ||
<vlan-status>Enabled</vlan-status> | ||
<vlan-owner>static</vlan-owner> | ||
<vlan-tag>300</vlan-tag> | ||
<vlan-tag-string>300</vlan-tag-string> | ||
<vlan-index>55</vlan-index> | ||
<vlan-protocol-port>Port Mode</vlan-protocol-port> | ||
<vlan-detail> | ||
<vlan-member-list> | ||
<vlan-member> | ||
<vlan-member-interface>None</vlan-member-interface> | ||
</vlan-member> | ||
</vlan-member-list> | ||
</vlan-detail> | ||
</vlan> | ||
<vlan> | ||
<vlan-instance>0</vlan-instance> | ||
<vlan-name>VLAN4000</vlan-name> | ||
<vlan-create-time>Fri Mar 12 11:32:21 2021 | ||
</vlan-create-time> | ||
<vlan-status>Enabled</vlan-status> | ||
<vlan-owner>static</vlan-owner> | ||
<vlan-tag>4000</vlan-tag> | ||
<vlan-tag-string>4000</vlan-tag-string> | ||
<vlan-index>56</vlan-index> | ||
<vlan-protocol-port>Port Mode</vlan-protocol-port> | ||
<vlan-members-count>2</vlan-members-count> | ||
<vlan-members-upcount>0</vlan-members-upcount> | ||
<vlan-detail> | ||
<vlan-member-list> | ||
<vlan-member> | ||
<vlan-member-interface>ge-0/0/4.0</vlan-member-interface> | ||
</vlan-member> | ||
<vlan-member> | ||
<vlan-member-interface>ge-0/0/5.0</vlan-member-interface> | ||
</vlan-member> | ||
</vlan-member-list> | ||
</vlan-detail> | ||
</vlan> | ||
<vlan> | ||
<vlan-instance>0</vlan-instance> | ||
<vlan-name>default</vlan-name> | ||
<vlan-create-time>Fri Dec 25 07:14:42 2020 | ||
</vlan-create-time> | ||
<vlan-status>Enabled</vlan-status> | ||
<vlan-owner>static</vlan-owner> | ||
<vlan-tag>0</vlan-tag> | ||
<vlan-index>2</vlan-index> | ||
<vlan-protocol-port>Port Mode</vlan-protocol-port> | ||
<vlan-members-count>1</vlan-members-count> | ||
<vlan-members-upcount>1</vlan-members-upcount> | ||
<vlan-detail> | ||
<vlan-member-list> | ||
<vlan-member> | ||
<vlan-member-interface>ge-0/0/0.0*</vlan-member-interface> | ||
</vlan-member> | ||
</vlan-member-list> | ||
</vlan-detail> | ||
</vlan> | ||
</vlan-information> |
33 changes: 33 additions & 0 deletions
33
test/junos/mocked_data/test_get_vlans/vlan_l2ng/expected_result.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"10": { | ||
"name": "VLAN10", | ||
"interfaces": [ | ||
"xe-0/0/1.0", | ||
"xe-0/0/2.0", | ||
"xe-0/0/3.0" | ||
] | ||
}, | ||
"2": { | ||
"name": "VLAN2", | ||
"interfaces": [ | ||
"xe-0/0/1.0" | ||
] | ||
}, | ||
"300": { | ||
"name": "VLAN300", | ||
"interfaces": [] | ||
}, | ||
"4000": { | ||
"name": "VLAN4000", | ||
"interfaces": [ | ||
"xe-0/0/4.0", | ||
"xe-0/0/5.0" | ||
] | ||
}, | ||
"1": { | ||
"name": "default", | ||
"interfaces": [ | ||
"xe-0/0/0.0" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
personality: SWITCH | ||
switch_style: VLAN_L2NG |
52 changes: 52 additions & 0 deletions
52
test/junos/mocked_data/test_get_vlans/vlan_l2ng/get-vlan-information.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<vlan-information> | ||
<l2ng-l2ald-vlan-instance-group> | ||
<l2ng-l2rtb-brief-summary/> | ||
<l2ng-l2rtb-name>default-switch</l2ng-l2rtb-name> | ||
<l2ng-l2rtb-vlan-name>VLAN10</l2ng-l2rtb-vlan-name> | ||
<l2ng-l2rtb-vlan-tag>10</l2ng-l2rtb-vlan-tag> | ||
<l2ng-l2rtb-vlan-member> | ||
<l2ng-l2rtb-vlan-member-interface>xe-0/0/1.0</l2ng-l2rtb-vlan-member-interface> | ||
</l2ng-l2rtb-vlan-member> | ||
<l2ng-l2rtb-vlan-member> | ||
<l2ng-l2rtb-vlan-member-interface>xe-0/0/2.0*</l2ng-l2rtb-vlan-member-interface> | ||
</l2ng-l2rtb-vlan-member> | ||
<l2ng-l2rtb-vlan-member> | ||
<l2ng-l2rtb-vlan-member-interface>xe-0/0/3.0*</l2ng-l2rtb-vlan-member-interface> | ||
</l2ng-l2rtb-vlan-member> | ||
</l2ng-l2ald-vlan-instance-group> | ||
<l2ng-l2ald-vlan-instance-group> | ||
<l2ng-l2rtb-name>default-switch</l2ng-l2rtb-name> | ||
<l2ng-l2rtb-vlan-name>VLAN2</l2ng-l2rtb-vlan-name> | ||
<l2ng-l2rtb-vlan-tag>2</l2ng-l2rtb-vlan-tag> | ||
<l2ng-l2rtb-vlan-member> | ||
<l2ng-l2rtb-vlan-member-interface>xe-0/0/1.0</l2ng-l2rtb-vlan-member-interface> | ||
</l2ng-l2rtb-vlan-member> | ||
</l2ng-l2ald-vlan-instance-group> | ||
<l2ng-l2ald-vlan-instance-group> | ||
<l2ng-l2rtb-name>default-switch</l2ng-l2rtb-name> | ||
<l2ng-l2rtb-vlan-name>VLAN300</l2ng-l2rtb-vlan-name> | ||
<l2ng-l2rtb-vlan-tag>300</l2ng-l2rtb-vlan-tag> | ||
<l2ng-l2rtb-vlan-member> | ||
<l2ng-l2rtb-vlan-member-interface/> | ||
</l2ng-l2rtb-vlan-member> | ||
</l2ng-l2ald-vlan-instance-group> | ||
<l2ng-l2ald-vlan-instance-group> | ||
<l2ng-l2rtb-name>default-switch</l2ng-l2rtb-name> | ||
<l2ng-l2rtb-vlan-name>VLAN4000</l2ng-l2rtb-vlan-name> | ||
<l2ng-l2rtb-vlan-tag>4000</l2ng-l2rtb-vlan-tag> | ||
<l2ng-l2rtb-vlan-member> | ||
<l2ng-l2rtb-vlan-member-interface>xe-0/0/4.0*</l2ng-l2rtb-vlan-member-interface> | ||
</l2ng-l2rtb-vlan-member> | ||
<l2ng-l2rtb-vlan-member> | ||
<l2ng-l2rtb-vlan-member-interface>xe-0/0/5.0*</l2ng-l2rtb-vlan-member-interface> | ||
</l2ng-l2rtb-vlan-member> | ||
</l2ng-l2ald-vlan-instance-group> | ||
<l2ng-l2ald-vlan-instance-group> | ||
<l2ng-l2rtb-name>default-switch</l2ng-l2rtb-name> | ||
<l2ng-l2rtb-vlan-name>default</l2ng-l2rtb-vlan-name> | ||
<l2ng-l2rtb-vlan-tag>1</l2ng-l2rtb-vlan-tag> | ||
<l2ng-l2rtb-vlan-member> | ||
<l2ng-l2rtb-vlan-member-interface>xe-0/0/0.0</l2ng-l2rtb-vlan-member-interface> | ||
</l2ng-l2rtb-vlan-member> | ||
</l2ng-l2ald-vlan-instance-group> | ||
</vlan-information> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose there are different formats to match because of various switch styles? Is
None
a possibility? If so, would you have access to a device to add another test case for that one too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It returns different values depending on switch_style if there is not binding IF of vlan.
BRIDGE_DOMAIN: l2rtb-interface-name
VLAN: None(string)
VLAN_L2NG: l2ng-l2rtb-vlan-member-interface
I think I have already added the above 3 patterns as a VLAN300 per switch_style.
BRIDGE_DOMAIN, VLAN, VLAN_L2NG
Also, I found an exception on MX(switch_style:BRIDGE_DOMAIN).
It seems it's possible that MX returns None(NoneType) if there is not binding IF of vlan.
I added this pattern only BRIDGE_DOMAIN by f519d24, 09fe92f because I could not found this exception in the others switch_style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thank you @minefuto!