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 400g zr port config from minigraph #11616

Merged
merged 2 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,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
Expand All @@ -990,6 +991,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:
Expand All @@ -1003,6 +1008,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
arlakshm marked this conversation as resolved.
Show resolved Hide resolved
# 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):
Expand Down Expand Up @@ -1615,6 +1625,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
Expand Down
19 changes: 19 additions & 0 deletions src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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</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>
Expand Down
14 changes: 14 additions & 0 deletions src/sonic-config-engine/tests/sample-voq-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
arlakshm marked this conversation as resolved.
Show resolved Hide resolved
</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>
Expand Down
14 changes: 14 additions & 0 deletions src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,3 +1008,17 @@ def test_minigraph_bgp_packet_chassis_vlan_subintf(self):
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')
self.assertEqual(output_dict['laser_freq'], 131000)