Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse backend switches to vlan sub port interface #3413

Merged
merged 7 commits into from
Oct 17, 2019
23 changes: 22 additions & 1 deletion src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
spine_chassis_frontend_role = 'SpineChassisFrontendRouter'
chassis_backend_role = 'ChassisBackendRouter'

backend_device_types = ['BackEndToRRouter', 'BackEndLeafRouter']
VLAN_SUB_INTERFACE_SEPARATOR = '.'
VLAN_SUB_INTERFACE_VLAN_ID = '10'

# Default Virtual Network Index (VNI)
vni_default = 8000

Expand Down Expand Up @@ -598,6 +602,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
vlan_intfs = {}
pc_intfs = {}
vlan_invert_mapping = { v['alias']:k for k,v in vlans.items() if v.has_key('alias') }
vlan_sub_intfs = {}

for intf in intfs:
if intf[0][0:4] == 'Vlan':
Expand All @@ -609,11 +614,27 @@ def parse_xml(filename, platform=None, port_config_file=None):
elif intf[0][0:11] == 'PortChannel':
pc_intfs[intf] = {}
pc_intfs[intf[0]] = {}
if current_device['type'] in backend_device_types:
intf_info = list(intf)
intf_info[0] = intf_info[0] + VLAN_SUB_INTERFACE_SEPARATOR + VLAN_SUB_INTERFACE_VLAN_ID
sub_intf = tuple(intf_info)
vlan_sub_intfs[sub_intf[0]] = {"admin_status" : "up"}
vlan_sub_intfs[sub_intf] = {}
else:
phyport_intfs[intf] = {}
phyport_intfs[intf[0]] = {}
if current_device['type'] in backend_device_types:
intf_info = list(intf)
intf_info[0] = intf_info[0] + VLAN_SUB_INTERFACE_SEPARATOR + VLAN_SUB_INTERFACE_VLAN_ID
sub_intf = tuple(intf_info)
vlan_sub_intfs[sub_intf[0]] = {"admin_status" : "up"}
vlan_sub_intfs[sub_intf] = {}

if current_device['type'] not in backend_device_types:
results['INTERFACE'] = phyport_intfs
else:
results['VLAN_SUB_INTERFACE'] = vlan_sub_intfs

results['INTERFACE'] = phyport_intfs
results['VLAN_INTERFACE'] = vlan_intfs

for port_name in port_speeds_default:
Expand Down