[sonic-cfggen]: Fix for management port speed issue (#2945)

This commit is contained in:
Sumukha Tumkur Vani 2019-06-01 12:31:14 -07:00 committed by Qi Luo
parent ff7fe3f8df
commit 24e5a62ccc
5 changed files with 48 additions and 3 deletions

View File

@ -395,8 +395,9 @@ def parse_deviceinfo(meta, hwsku):
for device_info in meta.findall(str(QName(ns, "DeviceInfo"))):
dev_sku = device_info.find(str(QName(ns, "HwSku"))).text
if dev_sku == hwsku:
interfaces = device_info.find(str(QName(ns, "EthernetInterfaces")))
for interface in interfaces.findall(str(QName(ns1, "EthernetInterface"))):
interfaces = device_info.find(str(QName(ns, "EthernetInterfaces"))).findall(str(QName(ns1, "EthernetInterface")))
interfaces = interfaces + device_info.find(str(QName(ns, "ManagementInterfaces"))).findall(str(QName(ns1, "ManagementInterface")))
for interface in interfaces:
alias = interface.find(str(QName(ns, "InterfaceName"))).text
speed = interface.find(str(QName(ns, "Speed"))).text
desc = interface.find(str(QName(ns, "Description")))
@ -494,6 +495,8 @@ def parse_xml(filename, platform=None, port_config_file=None):
mgmt_intf_count += 1
mgmt_alias_reverse_mapping[alias] = name
results['MGMT_PORT'][name] = {'alias': alias, 'admin_status': 'up'}
if alias in port_speeds_default:
results['MGMT_PORT'][name]['speed'] = port_speeds_default[alias]
results['MGMT_INTERFACE'][(name, key[1])] = mgmt_intf[key]
results['LOOPBACK_INTERFACE'] = lo_intfs

View File

@ -325,6 +325,19 @@
<FlowControl>true</FlowControl>
<Height>0</Height>
<HwSku>Force10-S6000</HwSku>
<ManagementInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:ManagementInterface>
<ElementType>DeviceInterface</ElementType>
<AlternateSpeeds i:nil="true"/>
<EnableAutoNegotiation>true</EnableAutoNegotiation>
<EnableFlowControl>true</EnableFlowControl>
<Index>1</Index>
<InterfaceName>eth0</InterfaceName>
<MultiPortsInterface>false</MultiPortsInterface>
<PortName>eth0</PortName>
<Speed>1000</Speed>
</a:ManagementInterface>
</ManagementInterfaces>
</DeviceInfo>
</DeviceInfos>
<Hostname>switch-T0</Hostname>

View File

@ -310,6 +310,19 @@
<FlowControl>true</FlowControl>
<Height>0</Height>
<HwSku>Force10-S6000</HwSku>
<ManagementInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:ManagementInterface>
<ElementType>DeviceInterface</ElementType>
<AlternateSpeeds i:nil="true"/>
<EnableAutoNegotiation>true</EnableAutoNegotiation>
<EnableFlowControl>true</EnableFlowControl>
<Index>1</Index>
<InterfaceName>Management1</InterfaceName>
<MultiPortsInterface>false</MultiPortsInterface>
<PortName>mgmt1</PortName>
<Speed>1000</Speed>
</a:ManagementInterface>
</ManagementInterfaces>
</DeviceInfo>
</DeviceInfos>
<Hostname>switch-t0</Hostname>

View File

@ -342,6 +342,18 @@
<FlowControl>true</FlowControl>
<Height>0</Height>
<HwSku>Force10-S6000</HwSku>
<ManagementInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:ManagementInterface>
<ElementType>DeviceInterface</ElementType>
<AlternateSpeeds i:nil="true"/>
<EnableAutoNegotiation>true</EnableAutoNegotiation>
<Index>1</Index>
<InterfaceName>Management1</InterfaceName>
<MultiPortsInterface>false</MultiPortsInterface>
<PortName>mgmt1</PortName>
<Speed>1000</Speed>
</a:ManagementInterface>
</ManagementInterfaces>
</DeviceInfo>
</DeviceInfos>
<Hostname>switch-t0</Hostname>

View File

@ -114,8 +114,12 @@ class TestCfgGenCaseInsensitive(TestCase):
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'10.0.10.7': {'priority': '1', 'tcp_port': '49'}, '10.0.10.8': {'priority': '1', 'tcp_port': '49'}}")
def test_minigraph_mgmt_port(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "MGMT_PORT"'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'eth0': {'alias': 'eth0', 'admin_status': 'up', 'speed': '1000'}}")
def test_metadata_ntp(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "NTP_SERVER"'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'10.0.10.1': {}, '10.0.10.2': {}}")