Skip to content

Commit 24e5a62

Browse files
Sumukha Tumkur Vaniqiluo-msft
Sumukha Tumkur Vani
authored andcommitted
[sonic-cfggen]: Fix for management port speed issue (#2945)
1 parent ff7fe3f commit 24e5a62

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

src/sonic-config-engine/minigraph.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,9 @@ def parse_deviceinfo(meta, hwsku):
395395
for device_info in meta.findall(str(QName(ns, "DeviceInfo"))):
396396
dev_sku = device_info.find(str(QName(ns, "HwSku"))).text
397397
if dev_sku == hwsku:
398-
interfaces = device_info.find(str(QName(ns, "EthernetInterfaces")))
399-
for interface in interfaces.findall(str(QName(ns1, "EthernetInterface"))):
398+
interfaces = device_info.find(str(QName(ns, "EthernetInterfaces"))).findall(str(QName(ns1, "EthernetInterface")))
399+
interfaces = interfaces + device_info.find(str(QName(ns, "ManagementInterfaces"))).findall(str(QName(ns1, "ManagementInterface")))
400+
for interface in interfaces:
400401
alias = interface.find(str(QName(ns, "InterfaceName"))).text
401402
speed = interface.find(str(QName(ns, "Speed"))).text
402403
desc = interface.find(str(QName(ns, "Description")))
@@ -494,6 +495,8 @@ def parse_xml(filename, platform=None, port_config_file=None):
494495
mgmt_intf_count += 1
495496
mgmt_alias_reverse_mapping[alias] = name
496497
results['MGMT_PORT'][name] = {'alias': alias, 'admin_status': 'up'}
498+
if alias in port_speeds_default:
499+
results['MGMT_PORT'][name]['speed'] = port_speeds_default[alias]
497500
results['MGMT_INTERFACE'][(name, key[1])] = mgmt_intf[key]
498501
results['LOOPBACK_INTERFACE'] = lo_intfs
499502

src/sonic-config-engine/tests/simple-sample-graph-case.xml

+13
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,19 @@
325325
<FlowControl>true</FlowControl>
326326
<Height>0</Height>
327327
<HwSku>Force10-S6000</HwSku>
328+
<ManagementInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
329+
<a:ManagementInterface>
330+
<ElementType>DeviceInterface</ElementType>
331+
<AlternateSpeeds i:nil="true"/>
332+
<EnableAutoNegotiation>true</EnableAutoNegotiation>
333+
<EnableFlowControl>true</EnableFlowControl>
334+
<Index>1</Index>
335+
<InterfaceName>eth0</InterfaceName>
336+
<MultiPortsInterface>false</MultiPortsInterface>
337+
<PortName>eth0</PortName>
338+
<Speed>1000</Speed>
339+
</a:ManagementInterface>
340+
</ManagementInterfaces>
328341
</DeviceInfo>
329342
</DeviceInfos>
330343
<Hostname>switch-T0</Hostname>

src/sonic-config-engine/tests/simple-sample-graph-metadata.xml

+13
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,19 @@
310310
<FlowControl>true</FlowControl>
311311
<Height>0</Height>
312312
<HwSku>Force10-S6000</HwSku>
313+
<ManagementInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
314+
<a:ManagementInterface>
315+
<ElementType>DeviceInterface</ElementType>
316+
<AlternateSpeeds i:nil="true"/>
317+
<EnableAutoNegotiation>true</EnableAutoNegotiation>
318+
<EnableFlowControl>true</EnableFlowControl>
319+
<Index>1</Index>
320+
<InterfaceName>Management1</InterfaceName>
321+
<MultiPortsInterface>false</MultiPortsInterface>
322+
<PortName>mgmt1</PortName>
323+
<Speed>1000</Speed>
324+
</a:ManagementInterface>
325+
</ManagementInterfaces>
313326
</DeviceInfo>
314327
</DeviceInfos>
315328
<Hostname>switch-t0</Hostname>

src/sonic-config-engine/tests/simple-sample-graph.xml

+12
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,18 @@
342342
<FlowControl>true</FlowControl>
343343
<Height>0</Height>
344344
<HwSku>Force10-S6000</HwSku>
345+
<ManagementInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
346+
<a:ManagementInterface>
347+
<ElementType>DeviceInterface</ElementType>
348+
<AlternateSpeeds i:nil="true"/>
349+
<EnableAutoNegotiation>true</EnableAutoNegotiation>
350+
<Index>1</Index>
351+
<InterfaceName>Management1</InterfaceName>
352+
<MultiPortsInterface>false</MultiPortsInterface>
353+
<PortName>mgmt1</PortName>
354+
<Speed>1000</Speed>
355+
</a:ManagementInterface>
356+
</ManagementInterfaces>
345357
</DeviceInfo>
346358
</DeviceInfos>
347359
<Hostname>switch-t0</Hostname>

src/sonic-config-engine/tests/test_minigraph_case.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,12 @@ def test_metadata_tacacs(self):
114114
output = self.run_script(argument)
115115
self.assertEqual(output.strip(), "{'10.0.10.7': {'priority': '1', 'tcp_port': '49'}, '10.0.10.8': {'priority': '1', 'tcp_port': '49'}}")
116116

117+
def test_minigraph_mgmt_port(self):
118+
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "MGMT_PORT"'
119+
output = self.run_script(argument)
120+
self.assertEqual(output.strip(), "{'eth0': {'alias': 'eth0', 'admin_status': 'up', 'speed': '1000'}}")
121+
117122
def test_metadata_ntp(self):
118123
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "NTP_SERVER"'
119124
output = self.run_script(argument)
120125
self.assertEqual(output.strip(), "{'10.0.10.1': {}, '10.0.10.2': {}}")
121-

0 commit comments

Comments
 (0)