@@ -124,6 +124,7 @@ def parse_dpg(dpg, hname):
124
124
125
125
ipintfs = child .find (str (QName (ns , "IPInterfaces" )))
126
126
intfs = []
127
+ intfnames = {}
127
128
vlan_map = {}
128
129
pc_map = {}
129
130
for ipintf in ipintfs .findall (str (QName (ns , "IPInterface" ))):
@@ -177,6 +178,7 @@ def parse_dpg(dpg, hname):
177
178
if peer_addr_val is not None :
178
179
intf ['peer_addr' ] = ipaddress .IPAddress (peer_addr_val )
179
180
intfs .append (intf )
181
+ intfnames [intf ['alias' ]] = { 'alias' : intf ['name' ] }
180
182
181
183
pcintfs = child .find (str (QName (ns , "PortChannelInterfaces" )))
182
184
pc_intfs = []
@@ -237,10 +239,27 @@ def parse_dpg(dpg, hname):
237
239
vlan_attributes .update (addrtuple )
238
240
vlan_intfs .append (copy .deepcopy (vlan_attributes ))
239
241
vlans [vintfname ] = vlan_attributes
240
-
241
-
242
- return intfs , lo_intfs , mgmt_intf , vlan_intfs , pc_intfs , vlans , pcs
243
- return None , None , None , None , None
242
+ aclintfs = child .find (str (QName (ns , "AclInterfaces" )))
243
+ acls = {}
244
+ for aclintf in aclintfs .findall (str (QName (ns , "AclInterface" ))):
245
+ aclname = aclintf .find (str (QName (ns , "InAcl" ))).text
246
+ aclattach = aclintf .find (str (QName (ns , "AttachTo" ))).text .split (';' )
247
+ acl_intfs = []
248
+ for member in aclattach :
249
+ member = member .strip ()
250
+ if port_alias_map .has_key (member ):
251
+ member = port_alias_map [member ]
252
+ if pcs .has_key (member ):
253
+ acl_intfs .extend (pcs [member ]['members' ]) # For ACL attaching to port channels, we break them into port channel members
254
+ elif vlans .has_key (member ):
255
+ print >> sys .stderr , "Warning: ACL " + aclname + " is attached to a Vlan interface, which is currently not supported"
256
+ elif intfnames .has_key (member ):
257
+ acl_intfs .append (member )
258
+ if acl_intfs :
259
+ acls [aclname ] = acl_intfs
260
+
261
+ return intfs , lo_intfs , mgmt_intf , vlan_intfs , pc_intfs , intfnames , vlans , pcs , acls
262
+ return None , None , None , None , None , None , None , None
244
263
245
264
def parse_cpg (cpg , hname ):
246
265
bgp_sessions = []
@@ -394,7 +413,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
394
413
395
414
for child in root :
396
415
if child .tag == str (QName (ns , "DpgDec" )):
397
- (intfs , lo_intfs , mgmt_intf , vlan_intfs , pc_intfs , vlans , pcs ) = parse_dpg (child , hostname )
416
+ (intfs , lo_intfs , mgmt_intf , vlan_intfs , pc_intfs , ports , vlans , pcs , acls ) = parse_dpg (child , hostname )
398
417
elif child .tag == str (QName (ns , "CpgDec" )):
399
418
(bgp_sessions , bgp_asn ) = parse_cpg (child , hostname )
400
419
elif child .tag == str (QName (ns , "PngDec" )):
@@ -418,9 +437,11 @@ def parse_xml(filename, platform=None, port_config_file=None):
418
437
results ['minigraph_vlan_interfaces' ] = vlan_intfs
419
438
results ['minigraph_portchannel_interfaces' ] = pc_intfs
420
439
results ['minigraph_vlans' ] = vlans
440
+ results ['minigraph_ports' ] = ports
421
441
results ['minigraph_portchannels' ] = pcs
422
442
results ['minigraph_mgmt_interface' ] = mgmt_intf
423
443
results ['minigraph_lo_interfaces' ] = lo_intfs
444
+ results ['minigraph_acls' ] = acls
424
445
results ['minigraph_neighbors' ] = neighbors
425
446
results ['minigraph_devices' ] = devices
426
447
results ['minigraph_underlay_neighbors' ] = u_neighbors
0 commit comments