From 9bdc3df25c06bf2cee221f0e70ceba12830874a9 Mon Sep 17 00:00:00 2001 From: Wei Bai Date: Sat, 13 Jul 2019 18:26:57 +0800 Subject: [PATCH 1/2] Remove unnecessary checks --- src/sonic-config-engine/minigraph.py | 44 +++++++++++----------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 4c1238a21568..7392c2dd5db9 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -457,44 +457,38 @@ def parse_spine_chassis_fe(results, vni, lo_intfs, phyport_intfs, pc_intfs, pc_m 'vni': chassis_vni }} - # Find L3 physical interfaces that should be enslaved to Vnet + # For each IP interface for intf in phyport_intfs: - # We only care about L3 physical interfaces - if is_ip_prefix_in_key(intf) == False: + # A IP interface may have multiple entries. + # For exmaple, "Ethernet0": {}", "Ethernet0|192.168.1.1": {}" + # We only care about the one without IP information + if is_ip_prefix_in_key(intf) == True: continue - - # intf = (intf name, IP prefix) - intf_name = intf[0] - neighbor_router = results['DEVICE_NEIGHBOR'][intf_name]['name'] + + neighbor_router = results['DEVICE_NEIGHBOR'][intf]['name'] # If the neighbor router is an external router if devices[neighbor_router]['type'] != chassis_backend_role: - # Enslave the interface to a Vnet - if intf_name in phyport_intfs: - phyport_intfs[intf_name] = {'vnet_name': chassis_vnet} - else: - print >> sys.stderr, 'Warning: cannot find the key %s' % (intf_name) - - # Find L3 port chennel interfaces that should be enslaved to Vnet + phyport_intfs[intf] = {'vnet_name': chassis_vnet} + + # For each port channel IP interface for pc_intf in pc_intfs: - # We only care about L3 port channel interfaces - if is_ip_prefix_in_key(pc_intf) == False: + # A port channel IP interface may have multiple entries. + # For exmaple, "Portchannel0": {}", "Portchannel0|192.168.1.1": {}" + # We only care about the one without IP information + if is_ip_prefix_in_key(pc_intf) == True: continue - # Get port channel interface name - # pc intf = (pc intf name, IP prefix) - pc_intf_name = pc_intf[0] - intf_name = None # Get a physical interface that belongs to this port channel for pc_member in pc_members: - if pc_member[0] == pc_intf_name: + if pc_member[0] == pc_intf: intf_name = pc_member[1] break if intf_name == None: - print >> sys.stderr, 'Warning: cannot find any interfaces that belong to %s' % (pc_intf_name) + print >> sys.stderr, 'Warning: cannot find any interfaces that belong to %s' % (pc_intf) continue # Get the neighbor router of this port channel interface @@ -502,12 +496,8 @@ def parse_spine_chassis_fe(results, vni, lo_intfs, phyport_intfs, pc_intfs, pc_m # If the neighbor router is an external router if devices[neighbor_router]['type'] != chassis_backend_role: - # Enslave the port channel interface to a Vnet - if pc_intf_name in pc_intfs: - pc_intfs[pc_intf_name] = {'vnet_name': chassis_vnet} - else: - print >> sys.stderr, 'Warning: cannot find the key %s' % (pc_intf_name) + pc_intfs[pc_intf] = {'vnet_name': chassis_vnet} def parse_xml(filename, platform=None, port_config_file=None): From e0a7a74b24897ea87c343cfde85f3fff81207234 Mon Sep 17 00:00:00 2001 From: Wei Bai Date: Sat, 13 Jul 2019 18:29:31 +0800 Subject: [PATCH 2/2] Fix a typo --- src/sonic-config-engine/minigraph.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 7392c2dd5db9..850c9967e720 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -460,7 +460,7 @@ def parse_spine_chassis_fe(results, vni, lo_intfs, phyport_intfs, pc_intfs, pc_m # For each IP interface for intf in phyport_intfs: # A IP interface may have multiple entries. - # For exmaple, "Ethernet0": {}", "Ethernet0|192.168.1.1": {}" + # For example, "Ethernet0": {}", "Ethernet0|192.168.1.1": {}" # We only care about the one without IP information if is_ip_prefix_in_key(intf) == True: continue @@ -475,7 +475,7 @@ def parse_spine_chassis_fe(results, vni, lo_intfs, phyport_intfs, pc_intfs, pc_m # For each port channel IP interface for pc_intf in pc_intfs: # A port channel IP interface may have multiple entries. - # For exmaple, "Portchannel0": {}", "Portchannel0|192.168.1.1": {}" + # For example, "Portchannel0": {}", "Portchannel0|192.168.1.1": {}" # We only care about the one without IP information if is_ip_prefix_in_key(pc_intf) == True: continue