Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions src/sonic-config-engine/tests/simple-sample-graph-case.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
13 changes: 13 additions & 0 deletions src/sonic-config-engine/tests/simple-sample-graph-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
12 changes: 12 additions & 0 deletions src/sonic-config-engine/tests/simple-sample-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 5 additions & 1 deletion src/sonic-config-engine/tests/test_minigraph_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@ def test_metadata_tacacs(self):
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': {}}")