Skip to content

Commit 7e78d40

Browse files
baiwei0427prsunny
authored andcommitted
[sonic-cfggen]: Improve T2 chassis frontend parsing (#3155)
* Remove unnecessary checks
1 parent 0ef7dc5 commit 7e78d40

File tree

1 file changed

+17
-27
lines changed

1 file changed

+17
-27
lines changed

src/sonic-config-engine/minigraph.py

+17-27
Original file line numberDiff line numberDiff line change
@@ -457,57 +457,47 @@ def parse_spine_chassis_fe(results, vni, lo_intfs, phyport_intfs, pc_intfs, pc_m
457457
'vni': chassis_vni
458458
}}
459459

460-
# Find L3 physical interfaces that should be enslaved to Vnet
460+
# For each IP interface
461461
for intf in phyport_intfs:
462-
# We only care about L3 physical interfaces
463-
if is_ip_prefix_in_key(intf) == False:
462+
# A IP interface may have multiple entries.
463+
# For example, "Ethernet0": {}", "Ethernet0|192.168.1.1": {}"
464+
# We only care about the one without IP information
465+
if is_ip_prefix_in_key(intf) == True:
464466
continue
465-
466-
# intf = (intf name, IP prefix)
467-
intf_name = intf[0]
468-
neighbor_router = results['DEVICE_NEIGHBOR'][intf_name]['name']
467+
468+
neighbor_router = results['DEVICE_NEIGHBOR'][intf]['name']
469469

470470
# If the neighbor router is an external router
471471
if devices[neighbor_router]['type'] != chassis_backend_role:
472-
473472
# Enslave the interface to a Vnet
474-
if intf_name in phyport_intfs:
475-
phyport_intfs[intf_name] = {'vnet_name': chassis_vnet}
476-
else:
477-
print >> sys.stderr, 'Warning: cannot find the key %s' % (intf_name)
478-
479-
# Find L3 port chennel interfaces that should be enslaved to Vnet
473+
phyport_intfs[intf] = {'vnet_name': chassis_vnet}
474+
475+
# For each port channel IP interface
480476
for pc_intf in pc_intfs:
481-
# We only care about L3 port channel interfaces
482-
if is_ip_prefix_in_key(pc_intf) == False:
477+
# A port channel IP interface may have multiple entries.
478+
# For example, "Portchannel0": {}", "Portchannel0|192.168.1.1": {}"
479+
# We only care about the one without IP information
480+
if is_ip_prefix_in_key(pc_intf) == True:
483481
continue
484482

485-
# Get port channel interface name
486-
# pc intf = (pc intf name, IP prefix)
487-
pc_intf_name = pc_intf[0]
488-
489483
intf_name = None
490484
# Get a physical interface that belongs to this port channel
491485
for pc_member in pc_members:
492-
if pc_member[0] == pc_intf_name:
486+
if pc_member[0] == pc_intf:
493487
intf_name = pc_member[1]
494488
break
495489

496490
if intf_name == None:
497-
print >> sys.stderr, 'Warning: cannot find any interfaces that belong to %s' % (pc_intf_name)
491+
print >> sys.stderr, 'Warning: cannot find any interfaces that belong to %s' % (pc_intf)
498492
continue
499493

500494
# Get the neighbor router of this port channel interface
501495
neighbor_router = results['DEVICE_NEIGHBOR'][intf_name]['name']
502496

503497
# If the neighbor router is an external router
504498
if devices[neighbor_router]['type'] != chassis_backend_role:
505-
506499
# Enslave the port channel interface to a Vnet
507-
if pc_intf_name in pc_intfs:
508-
pc_intfs[pc_intf_name] = {'vnet_name': chassis_vnet}
509-
else:
510-
print >> sys.stderr, 'Warning: cannot find the key %s' % (pc_intf_name)
500+
pc_intfs[pc_intf] = {'vnet_name': chassis_vnet}
511501

512502

513503
def parse_xml(filename, platform=None, port_config_file=None):

0 commit comments

Comments
 (0)