[Chassis] parse 400g zr port config from minigraph (#11616)
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan arlakshm@microsoft.com Why I did it Generate the port configuration required 400G ZR port from minigraph. How I did it Add parse logic to get tx_power and laser_freq from LinkMetadata section of the minigraph. Add UT for packet-chassis and voq chassis How to verify it UT Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
This commit is contained in:
parent
25e48f9a12
commit
f9bfa47e8f
@ -972,7 +972,8 @@ def parse_linkmeta(meta, hname):
|
||||
lower_tor_hostname = ''
|
||||
auto_negotiation = None
|
||||
macsec_enabled = False
|
||||
|
||||
tx_power = None
|
||||
laser_freq = None
|
||||
properties = linkmeta.find(str(QName(ns1, "Properties")))
|
||||
for device_property in properties.findall(str(QName(ns1, "DeviceProperty"))):
|
||||
name = device_property.find(str(QName(ns1, "Name"))).text
|
||||
@ -989,6 +990,10 @@ def parse_linkmeta(meta, hname):
|
||||
auto_negotiation = value
|
||||
elif name == "MacSecEnabled":
|
||||
macsec_enabled = value
|
||||
elif name == "TxPower":
|
||||
tx_power = value
|
||||
elif name == "Frequency":
|
||||
laser_freq = value
|
||||
|
||||
linkmetas[port] = {}
|
||||
if fec_disabled:
|
||||
@ -1002,6 +1007,11 @@ def parse_linkmeta(meta, hname):
|
||||
linkmetas[port]["AutoNegotiation"] = auto_negotiation
|
||||
if macsec_enabled:
|
||||
linkmetas[port]["MacSecEnabled"] = macsec_enabled
|
||||
if tx_power:
|
||||
linkmetas[port]["tx_power"] = tx_power
|
||||
# Convert the freq in GHz
|
||||
if laser_freq:
|
||||
linkmetas[port]["laser_freq"] = int(float(laser_freq)*1000)
|
||||
return linkmetas
|
||||
|
||||
def parse_macsec_profile(val_string):
|
||||
@ -1613,6 +1623,14 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
||||
if macsec_enabled and 'PrimaryKey' in macsec_profile:
|
||||
port['macsec'] = macsec_profile['PrimaryKey']
|
||||
|
||||
tx_power = linkmetas.get(alias, {}).get('tx_power')
|
||||
if tx_power:
|
||||
port['tx_power'] = tx_power
|
||||
|
||||
laser_freq = linkmetas.get(alias, {}).get('laser_freq')
|
||||
if laser_freq:
|
||||
port['laser_freq'] = laser_freq
|
||||
|
||||
# set port description if parsed from deviceinfo
|
||||
for port_name in port_descriptions:
|
||||
# ignore port not in port_config.ini
|
||||
|
@ -222,6 +222,25 @@
|
||||
</IPNextHops>
|
||||
</DeviceDataPlaneInfo>
|
||||
</DpgDec>
|
||||
<LinkMetadataDeclaration>
|
||||
<Link xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
<a:LinkMetadata>
|
||||
<a:Name i:nil="true"/>
|
||||
<a:Properties>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>Frequency</a:Name>
|
||||
<a:Value>131</a:Value>
|
||||
</a:DeviceProperty>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>TxPower</a:Name>
|
||||
<a:Value>7.5</a:Value>
|
||||
</a:DeviceProperty>
|
||||
</a:Properties>
|
||||
<a:Key>str2-8808-lc2-1:Eth1/1/13;ARISTA01-RH:Ethernet1/1</a:Key>
|
||||
</a:LinkMetadata>
|
||||
</Link>
|
||||
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
</LinkMetadataDeclaration>
|
||||
<PngDec>
|
||||
<DeviceInterfaceLinks>
|
||||
<DeviceLinkBase>
|
||||
|
@ -79,6 +79,20 @@
|
||||
</a:Properties>
|
||||
<a:Key>linecard-1:Ethernet1/1;ARISTA01-RH:Ethernet1/1</a:Key>
|
||||
</a:LinkMetadata>
|
||||
<a:LinkMetadata>
|
||||
<a:Name i:nil="true"/>
|
||||
<a:Properties>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>Frequency</a:Name>
|
||||
<a:Value>195.875</a:Value>
|
||||
</a:DeviceProperty>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>TxPower</a:Name>
|
||||
<a:Value>-10</a:Value>
|
||||
</a:DeviceProperty>
|
||||
</a:Properties>
|
||||
<a:Key>linecard-1:Ethernet2/1;ARISTA01-RH:Ethernet1/1</a:Key>
|
||||
</a:LinkMetadata>
|
||||
</Link>
|
||||
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
</LinkMetadataDeclaration>
|
||||
|
@ -1008,3 +1008,17 @@ class TestCfgGen(TestCase):
|
||||
utils.to_dict(output.strip()),
|
||||
utils.to_dict("{('PortChannel32.2', '192.168.1.4/24'): {}, 'PortChannel32.2': {'admin_status': 'up'}, ('PortChannel33.2', '192.168.2.4/24'): {}, 'PortChannel33.2': {'admin_status': 'up'}}")
|
||||
)
|
||||
|
||||
def test_minigraph_voq_400g_zr_port_config(self):
|
||||
argument = "-j {} -m {} -p {} -v \"PORT[\'Ethernet4\']\"".format(self.macsec_profile, self.sample_graph_voq, self.voq_port_config)
|
||||
output = self.run_script(argument)
|
||||
output_dict = utils.to_dict(output.strip())
|
||||
self.assertEqual(output_dict['tx_power'], '-10')
|
||||
self.assertEqual(output_dict['laser_freq'], 195875)
|
||||
|
||||
def test_minigraph_packet_chassis_400g_zr_port_config(self):
|
||||
argument = "-m {} -p {} -n asic1 -v \"PORT[\'Ethernet13\']\"".format(self.packet_chassis_graph, self.packet_chassis_port_ini)
|
||||
output = self.run_script(argument)
|
||||
output_dict = utils.to_dict(output.strip())
|
||||
self.assertEqual(output_dict['tx_power'], '7.5')
|
||||
self.assertEqual(output_dict['laser_freq'], 131000)
|
Loading…
Reference in New Issue
Block a user