Skip to content

Commit

Permalink
Merge pull request #1095 from chonty/ios-get_network_instances
Browse files Browse the repository at this point in the history
IOS driver get_network_instances fix
  • Loading branch information
mirceaulinic authored Aug 6, 2020
2 parents ce790e3 + cb09cbf commit 0e23a55
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 103 deletions.
9 changes: 8 additions & 1 deletion napalm/ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -3405,7 +3405,14 @@ def get_network_instances(self, name=""):
if "No interfaces" in first_part:
interfaces = {}
else:
interfaces = {itf: {} for itf in if_regex.group(1).split()}
interfaces = {
canonical_interface_name(itf, {"Vl": "Vlan"}): {}
for itf in if_regex.group(1).split()
}

# remove interfaces in the VRF from the default VRF
for item in interfaces:
del instances["default"]["interfaces"]["interface"][item]

instances[vrf_name] = {
"name": vrf_name,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"default": {
"name": "default",
"type": "DEFAULT_INSTANCE",
"state": {
"route_distinguisher": ""
},
"interfaces": {
"interface": {
"Ethernet0/0": {},
"Ethernet0/1": {},
"Ethernet0/2": {},
"Ethernet0/3": {},
"Ethernet1/0": {},
"Ethernet1/1": {},
"Ethernet1/2": {},
"Ethernet1/3": {},
"Ethernet2/0": {},
"Ethernet2/1": {},
"Ethernet2/2": {},
"Ethernet2/3": {},
"Ethernet3/0": {},
"Ethernet3/1": {},
"Ethernet3/2": {},
"Ethernet3/3": {},
"Vlan1": {},
"Vlan2": {},
"Vlan3": {},
"Vlan4": {}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 172.29.29.220 YES manual up up
Ethernet0/1 unassigned YES unset up up
Ethernet0/2 unassigned YES unset up up
Ethernet0/3 unassigned YES unset up up
Ethernet1/0 unassigned YES unset up up
Ethernet1/1 unassigned YES unset up up
Ethernet1/2 unassigned YES unset up up
Ethernet1/3 unassigned YES unset up up
Ethernet2/0 unassigned YES unset up up
Ethernet2/1 unassigned YES unset up up
Ethernet2/2 unassigned YES unset up up
Ethernet2/3 unassigned YES unset up up
Ethernet3/0 unassigned YES unset up up
Ethernet3/1 unassigned YES unset up up
Ethernet3/2 unassigned YES unset up up
Ethernet3/3 unassigned YES unset up up
Vlan1 unassigned YES unset administratively down down
Vlan2 2.2.2.2 YES manual up up
Vlan3 3.3.3.3 YES manual up up
Vlan4 4.4.4.4 YES manual up up
Empty file.
Original file line number Diff line number Diff line change
@@ -1,78 +1,66 @@
{
"default":{
"interfaces":{
"interface":{
"GigabitEthernet0/0/0":{

},
"Gi0/0/0.152":{

},
"GigabitEthernet0/0/2":{

},
"Gi0/0/0.1774":{

},
"GigabitEthernet0/0/4":{

},
"Gi0/0/0.1772":{

},
"GigabitEthernet0/0/3":{

},
"Gi0/0/0.154":{

},
"GigabitEthernet0/0/1":{

},
"GigabitEthernet0":{

},
"Gi0/0/0.1776":{

},
"Gi0/0/0.600":{

},
"Loopback2":{

}
}
},
"state":{
"route_distinguisher":""
"default": {
"name": "default",
"type": "DEFAULT_INSTANCE",
"state": {
"route_distinguisher": ""
},
"type":"DEFAULT_INSTANCE",
"name":"default"
},
"Mgmt-intf":{
"interfaces":{
"interface":{
"Gi0":{

}
"interfaces": {
"interface": {
"Ethernet0/0": {},
"Ethernet0/1": {},
"Ethernet0/2": {},
"Ethernet0/3": {},
"Ethernet1/0": {},
"Ethernet1/1": {},
"Ethernet1/2": {},
"Ethernet1/3": {},
"Ethernet2/0": {},
"Ethernet2/1": {},
"Ethernet2/2": {},
"Ethernet2/3": {},
"Ethernet3/0": {},
"Ethernet3/1": {},
"Ethernet3/2": {},
"Ethernet3/3": {},
"Vlan1": {}
}
},
"state":{
"route_distinguisher":""
},
"type":"L3VRF",
"name":"Mgmt-intf"
}
},
"opsnet":{
"interfaces":{
"interface":{

"CustA": {
"name": "CustA",
"type": "L3VRF",
"state": {
"route_distinguisher": "1:1"
},
"interfaces": {
"interface": {
"Vlan2": {}
}
}
},
"CustB": {
"name": "CustB",
"type": "L3VRF",
"state": {
"route_distinguisher": "2:2"
},
"state":{
"route_distinguisher":"10283:1021312690"
"interfaces": {
"interface": {
"Vlan3": {}
}
}
},
"CustC": {
"name": "CustC",
"type": "L3VRF",
"state": {
"route_distinguisher": "3:3"
},
"type":"L3VRF",
"name":"opsnet"
"interfaces": {
"interface": {
"Vlan4": {}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
Load for five secs: 0%/0%; one minute: 1%; five minutes: 1%
Time source is NTP, 09:30:03.851 DST Wed Nov 8 2017

Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0/0 unassigned YES NVRAM up up
Gi0/0/0.152 192.168.241.21 YES NVRAM up up
Gi0/0/0.154 192.168.241.30 YES NVRAM up up
Gi0/0/0.600 192.168.241.141 YES NVRAM up up
Gi0/0/0.1772 120.177.177.1 YES NVRAM up up
Gi0/0/0.1774 101.177.177.1 YES NVRAM up up
Gi0/0/0.1776 100.177.177.1 YES NVRAM up up
GigabitEthernet0/0/1 unassigned YES NVRAM administratively down down
GigabitEthernet0/0/2 unassigned YES NVRAM administratively down down
GigabitEthernet0/0/3 unassigned YES NVRAM administratively down down
GigabitEthernet0/0/4 unassigned YES NVRAM administratively down down
GigabitEthernet0 192.168.243.80 YES NVRAM up up
Loopback2 192.168.242.152 YES NVRAM up up
Ethernet0/0 172.29.29.220 YES manual up up
Ethernet0/1 unassigned YES unset up up
Ethernet0/2 unassigned YES unset up up
Ethernet0/3 unassigned YES unset up up
Ethernet1/0 unassigned YES unset up up
Ethernet1/1 unassigned YES unset up up
Ethernet1/2 unassigned YES unset up up
Ethernet1/3 unassigned YES unset up up
Ethernet2/0 unassigned YES unset up up
Ethernet2/1 unassigned YES unset up up
Ethernet2/2 unassigned YES unset up up
Ethernet2/3 unassigned YES unset up up
Ethernet3/0 unassigned YES unset up up
Ethernet3/1 unassigned YES unset up up
Ethernet3/2 unassigned YES unset up up
Ethernet3/3 unassigned YES unset up up
Vlan1 unassigned YES unset administratively down down
Vlan2 2.2.2.2 YES manual up up
Vlan3 3.3.3.3 YES manual up up
Vlan4 4.4.4.4 YES manual up up
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
Load for five secs: 0%/0%; one minute: 0%; five minutes: 1%
Time source is NTP, 09:28:50.737 DST Wed Nov 8 2017

VRF Mgmt-intf (VRF Id = 1); default RD <not set>; default VPNID <not set>
VRF CustA (VRF Id = 1); default RD 1:1; default VPNID <not set>
New CLI format, supports multiple address-families
Flags: 0x1808
Flags: 0x180C
Interfaces:
Gi0
Vl2
Address family ipv4 unicast (Table ID = 0x1):
Flags: 0x0
No Export VPN route-target communities
Expand All @@ -15,7 +12,14 @@ Address family ipv4 unicast (Table ID = 0x1):
No export route-map
VRF label distribution protocol: not configured
VRF label allocation mode: per-prefix
Address family ipv6 unicast (Table ID = 0x1E000001):
Address family ipv6 unicast not active

VRF CustB (VRF Id = 2); default RD 2:2; default VPNID <not set>
New CLI format, supports multiple address-families
Flags: 0x180C
Interfaces:
Vl3
Address family ipv4 unicast (Table ID = 0x2):
Flags: 0x0
No Export VPN route-target communities
No Import VPN route-target communities
Expand All @@ -24,22 +28,21 @@ Address family ipv6 unicast (Table ID = 0x1E000001):
No export route-map
VRF label distribution protocol: not configured
VRF label allocation mode: per-prefix
Address family ipv4 multicast not active
Address family ipv6 unicast not active

VRF opsnet (VRF Id = 2); default RD 10283:1021312690; default VPNID <not set>
VRF CustC (VRF Id = 3); default RD 3:3; default VPNID <not set>
New CLI format, supports multiple address-families
Flags: 0x180C
No interfaces
Address family ipv4 unicast (Table ID = 0x2):
Interfaces:
Vl4
Address family ipv4 unicast (Table ID = 0x3):
Flags: 0x0
Export VPN route-target communities
RT:10283:50000
Import VPN route-target communities
RT:10283:50000
No Export VPN route-target communities
No Import VPN route-target communities
No import route-map
No global export route-map
No export route-map
VRF label distribution protocol: not configured
VRF label allocation mode: per-prefix
Address family ipv6 unicast not active
Address family ipv4 multicast not active

0 comments on commit 0e23a55

Please sign in to comment.