Skip to content

Commit 72893b3

Browse files
committedOct 21, 2023
Add get_vlans()
1 parent 931faea commit 72893b3

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed
 

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ order matter.
3939
* get_bgp_neighbors
4040
* get_bgp_neighbors_detail
4141
* get_config
42+
* get_vlans

‎napalm_ros/ros.py

+13
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,19 @@ def ping(
499499

500500
return dict(success=ping_results)
501501

502+
def get_vlans(self):
503+
result = dict()
504+
for row in self.api('/interface/bridge/vlan/print'):
505+
for vid in row['vlan-ids'].split(','):
506+
untagged = filter(None, row['untagged'].split(','))
507+
tagged = filter(None, row['tagged'].split(','))
508+
ifs = set(chain(untagged, tagged))
509+
result[vid] = {
510+
"name": "",
511+
"interfaces": list(ifs),
512+
}
513+
return result
514+
502515

503516
def find_rows(rows, key, value):
504517
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"data":
3+
[
4+
{
5+
"disabled": false,
6+
"comment": "",
7+
"tagged": "ether1,ether2",
8+
"untagged": "",
9+
"vlan-ids": "10,20",
10+
"bridge": "bridge1"
11+
}
12+
]
13+
}
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"10": {
3+
"name": "",
4+
"interfaces": [
5+
"ether2",
6+
"ether1"
7+
]
8+
},
9+
"20": {
10+
"name": "",
11+
"interfaces": [
12+
"ether2",
13+
"ether1"
14+
]
15+
}
16+
}

0 commit comments

Comments
 (0)
Please sign in to comment.