Skip to content

Commit 93fbb8f

Browse files
authored
[201811][sonic-config-engine] Parse AutoNegotiation element from LinkMetadata section of minigraph file (#7048)
Backport of #7031 to the 201811 branch #### Why I did it To enable parsing the `AutoNegotiation` element from the LinkMetadata section of minigraph file #### How I did it Parse the value `AutoNegotiation` element from the `LinkMetadata` section of minigraph file. If the element is present, an `autoneg` key will be added to the port in the `PORT` table of Config DB with a value of either `0` or `1` If an `autoneg` value is present in port_config.ini, the value from the minigraph will take precedence, overriding that value. Also remove `AutoNegotiation` and `EnableAutoNegotiation` elements from the `DeviceInfo` section, as we will use this data in the `LinkMetadata` section to determine whether to enable auto-negotiation for a port.
1 parent 6c2fd18 commit 93fbb8f

10 files changed

+1302
-137
lines changed

src/sonic-config-engine/minigraph.py

+10
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ def parse_linkmeta(meta, hname):
422422
for linkmeta in link.findall(str(QName(ns1, "LinkMetadata"))):
423423
port = None
424424
fec_disabled = None
425+
auto_negotiation = None
425426

426427
# Sample: ARISTA05T1:Ethernet1/33;switch-t0:fortyGigE0/4
427428
key = linkmeta.find(str(QName(ns1, "Key"))).text
@@ -441,10 +442,14 @@ def parse_linkmeta(meta, hname):
441442
value = device_property.find(str(QName(ns1, "Value"))).text
442443
if name == "FECDisabled":
443444
fec_disabled = value
445+
elif name == "AutoNegotiation":
446+
auto_negotiation = value
444447

445448
linkmetas[port] = {}
446449
if fec_disabled:
447450
linkmetas[port]["FECDisabled"] = fec_disabled
451+
if auto_negotiation:
452+
linkmetas[port]["AutoNegotiation"] = auto_negotiation
448453
return linkmetas
449454

450455

@@ -638,6 +643,11 @@ def parse_xml(filename, platform=None, port_config_file=None):
638643
if port.get('speed') == '100000' and linkmetas.get(alias, {}).get('FECDisabled', '').lower() != 'true':
639644
port['fec'] = 'rs'
640645

646+
# If AutoNegotiation is available in the minigraph, we override any value we may have received from port_config.ini
647+
autoneg = linkmetas.get(alias, {}).get('AutoNegotiation')
648+
if autoneg:
649+
port['autoneg'] = '1' if autoneg.lower() == 'true' else '0'
650+
641651
# set port description if parsed from deviceinfo
642652
for port_name in port_descriptions:
643653
# ignore port not in port_config.ini

0 commit comments

Comments
 (0)