Skip to content

Commit

Permalink
[Chassis] Added support of subtype for SpineRouter as UpstreamLC/Down…
Browse files Browse the repository at this point in the history
…StreamLC/Supervisor (sonic-net#20566)

Added support of subtype for SpineRouter as UpstreamLC/DownStreamLC/Supervisor
It is done using MacSec Device Property. Macsec is enable on upstreamLC

---------

Signed-off-by: Abhishek Dosi <[email protected]>
  • Loading branch information
abdosi authored Nov 8, 2024
1 parent 2177af1 commit 54b137c
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 11 deletions.
26 changes: 26 additions & 0 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,23 @@ def get_chassis_type_and_hostname(root, hname):
chassis_hostname = value
return chassis_type, chassis_hostname

def is_chassis_lc_macsec_enabled(root, hname):
macsec_enble = None
for child in root:
if child.tag == str(QName(ns, "MetadataDeclaration")):
devices = child.find(str(QName(ns, "Devices")))
for device_meta in devices.findall(str(QName(ns1, "DeviceMetadata"))):
device_name = device_meta.find(str(QName(ns1, "Name"))).text
if device_name != hname:
continue
properties = device_meta.find(str(QName(ns1, "Properties")))
for device_property in properties.findall(str(QName(ns1, "DeviceProperty"))):
name = device_property.find(str(QName(ns1, "Name"))).text
value = device_property.find(str(QName(ns1, "Value"))).text
if name == "MacSecEnabled":
macsec_enble = value
return macsec_enble

def is_minigraph_for_chassis(chassis_type):
if chassis_type in [CHASSIS_CARD_VOQ, CHASSIS_CARD_PACKET]:
return True
Expand Down Expand Up @@ -2028,6 +2045,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
slot_index = None
max_num_cores = None
card_type = None
macsec_enabled = None

hwsku_qn = QName(ns, "HwSku")
hostname_qn = QName(ns, "Hostname")
Expand All @@ -2041,6 +2059,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
docker_routing_config_mode = child.text

hwsku, hostname, docker_routing_config_mode, chassis_type, chassis_hostname = parse_global_info(root)
macsec_enabled = is_chassis_lc_macsec_enabled(root, hostname)

(ports, alias_map, alias_asic_map) = get_port_config(hwsku=hwsku, platform=platform, port_config_file=port_config_file, asic_name=asic_name, hwsku_config_file=hwsku_config_file)

Expand Down Expand Up @@ -2172,6 +2191,13 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
print("Warning: more than one peer switch was found. Only the first will be parsed: {}".format(results['PEER_SWITCH'].keys()[0]))

results['DEVICE_METADATA']['localhost']['peer_switch'] = list(results['PEER_SWITCH'].keys())[0]
elif results['DEVICE_METADATA']['localhost']['type'] == 'SpineRouter':
if macsec_enabled == 'True':
results['DEVICE_METADATA']['localhost']['subtype'] = 'UpstreamLC'
elif macsec_enabled == 'False':
results['DEVICE_METADATA']['localhost']['subtype'] = 'DownstreamLC'
else:
results['DEVICE_METADATA']['localhost']['subtype'] = 'Supervisor'

# Enable tunnel_qos_remap if downstream_redundancy_types(T1) or redundancy_type(T0) = Gemini/Libra
enable_tunnel_qos_map = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44009,7 +44009,7 @@
<a:DeviceProperty>
<a:Name>MacSecEnabled</a:Name>
<a:Reference i:nil="true" />
<a:Value>True</a:Value>
<a:Value>False</a:Value>
</a:DeviceProperty>
<a:DeviceProperty>
<a:Name>OsVersion</a:Name>
Expand Down Expand Up @@ -48335,4 +48335,4 @@
<HwSku>Sonic-400g-lc-sku</HwSku>
<Version>1.0.1388.35297&#xD;
</Version>
</DeviceMiniGraph>
</DeviceMiniGraph>
Original file line number Diff line number Diff line change
Expand Up @@ -43525,7 +43525,7 @@
<a:DeviceProperty>
<a:Name>MacSecEnabled</a:Name>
<a:Reference i:nil="true"/>
<a:Value>False</a:Value>
<a:Value>True</a:Value>
</a:DeviceProperty>
<a:DeviceProperty>
<a:Name>OsVersion</a:Name>
Expand Down
16 changes: 12 additions & 4 deletions src/sonic-config-engine/tests/test_chassis_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def test_device_metadata(self):
'switch_type': 'voq',
'switch_id': 20,
'max_cores': 64,
'slice_type': 'AZNG_Production'})
'slice_type': 'AZNG_Production',
'subtype': 'UpstreamLC'})

def test_port(self):
argument = ['-m', self.sample_graph, '-p',
Expand Down Expand Up @@ -444,8 +445,10 @@ def test_device_metadata(self):
'chassis_hostname': 'str-sonic',
'deployment_id': '3',
'cluster': 'TestbedForstr-sonic',
'subtype': 'DownstreamLC',
'switch_type': 'voq',
'max_cores': 64})
'max_cores': 64,
})

def test_device_metadata_for_namespace(self):
argument = [
Expand Down Expand Up @@ -473,7 +476,8 @@ def test_device_metadata_for_namespace(self):
'asic_name': 'asic0',
'switch_type': 'voq',
'switch_id': 8,
'max_cores': 64})
'max_cores': 64,
'subtype': 'DownstreamLC'})

def test_system_port(self):
argument = ['-m', self.sample_graph,
Expand Down Expand Up @@ -920,6 +924,7 @@ def test_device_metadata(self):
"chassis_hostname": "str-sonic",
"deployment_id": "3",
"cluster": "TestbedForstr-sonic",
"subtype": "Supervisor",
"switch_type": "fabric",
"sub_role": "fabric",
"max_cores": 64
Expand Down Expand Up @@ -950,7 +955,8 @@ def test_device_metadata_for_namespace(self):
"sub_role": "Fabric",
"asic_name": "asic0",
"switch_type": "fabric",
"max_cores": 64
"max_cores": 64,
"subtype": "Supervisor",
}
)

Expand Down Expand Up @@ -1054,6 +1060,7 @@ def test_device_metadata(self):
"chassis_hostname": "str-sonic",
"deployment_id": "3",
"cluster": "TestbedForstr-sonic",
"subtype": "Supervisor",
"switch_type": "chassis-packet",
"sub_role": "BackEnd",
"max_cores": 64
Expand Down Expand Up @@ -1082,6 +1089,7 @@ def test_device_metadata_for_namespace(self):
"deployment_id": "3",
"cluster": "TestbedForstr-sonic",
"sub_role": "BackEnd",
"subtype": "Supervisor",
"asic_name": "asic0",
"switch_type": "chassis-packet",
"max_cores": 64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,17 @@
"DEVICE_METADATA_VALID_CLUSTER": {
"desc": "Verifying valid cluster configuration."
},
"DEVICE_METADATA_VALID_SUBTYPE": {
"desc": "Verifying valid subtype value"
"DEVICE_METADATA_VALID_SUBTYPE0": {
"desc": "Verifying valid subtype value dualtor"
},
"DEVICE_METADATA_VALID_SUBTYPE1": {
"desc": "Verifying valid subtype value supervisor"
},
"DEVICE_METADATA_VALID_SUBTYPE2": {
"desc": "Verifying valid subtype value upstreamLC"
},
"DEVICE_METADATA_VALID_SUBTYPE3": {
"desc": "Verifying valid subtype value downstreamLC"
},
"DEVICE_METADATA_INVALID_SUBTYPE": {
"desc": "Verifying invalid subtype value",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
}
}
},
"DEVICE_METADATA_VALID_SUBTYPE": {
"DEVICE_METADATA_VALID_SUBTYPE0": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"sonic-device_metadata:localhost": {
Expand All @@ -265,6 +265,33 @@
}
}
},
"DEVICE_METADATA_VALID_SUBTYPE1": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"sonic-device_metadata:localhost": {
"subtype": "Supervisor"
}
}
}
},
"DEVICE_METADATA_VALID_SUBTYPE2": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"sonic-device_metadata:localhost": {
"subtype": "UpstreamLC"
}
}
}
},
"DEVICE_METADATA_VALID_SUBTYPE3": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"sonic-device_metadata:localhost": {
"subtype": "DownstreamLC"
}
}
}
},
"DEVICE_METADATA_INVALID_SUBTYPE": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ module sonic-device_metadata {

leaf subtype {
type string {
pattern "DualToR|SmartSwitch";
pattern "DualToR|SmartSwitch|Supervisor|UpstreamLC|DownstreamLC";
}
}

Expand Down

0 comments on commit 54b137c

Please sign in to comment.