Port speed (#879)
* Add port speed configuration * Add DeviceInfos support in minigraph parser * Add cfggen test 'test_minigraph_ethernet_interfaces' * Fixed PR comments * Update sonic-swss submodule reference
This commit is contained in:
parent
12ba083b66
commit
48b0beb7ff
@ -30,5 +30,6 @@ COPY ["arp_update", "start.sh", "orchagent.sh", "swssconfig.sh", "/usr/bin/"]
|
||||
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
|
||||
COPY ["ipinip.json.j2", "/usr/share/sonic/templates/"]
|
||||
COPY ["mirror.json.j2", "/usr/share/sonic/templates/"]
|
||||
COPY ["ports.json.j2", "/usr/share/sonic/templates/"]
|
||||
|
||||
ENTRYPOINT ["/usr/bin/supervisord"]
|
||||
|
11
dockers/docker-orchagent/ports.json.j2
Normal file
11
dockers/docker-orchagent/ports.json.j2
Normal file
@ -0,0 +1,11 @@
|
||||
[
|
||||
{% for interface in ethernet_interfaces %}
|
||||
{
|
||||
"PORT_TABLE:{{ interface['name'] }}": {
|
||||
"speed": "{{ interface['speed'] }}"
|
||||
},
|
||||
"OP": "SET"
|
||||
}{% if not loop.last %},{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
]
|
@ -4,6 +4,7 @@ mkdir -p /etc/swss/config.d/
|
||||
|
||||
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/ipinip.json.j2 > /etc/swss/config.d/ipinip.json
|
||||
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/mirror.json.j2 > /etc/swss/config.d/mirror.json
|
||||
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/ports.json.j2 > /etc/swss/config.d/ports.json
|
||||
|
||||
export platform=`sonic-cfggen -m /etc/sonic/minigraph.xml -v platform`
|
||||
|
||||
|
@ -38,7 +38,7 @@ fast_reboot
|
||||
|
||||
HWSKU=`sonic-cfggen -m /etc/sonic/minigraph.xml -v minigraph_hwsku`
|
||||
|
||||
SWSSCONFIG_ARGS="00-copp.config.json ipinip.json mirror.json "
|
||||
SWSSCONFIG_ARGS="00-copp.config.json ipinip.json mirror.json ports.json "
|
||||
|
||||
if [ "$HWSKU" == "Force10-S6000" ]; then
|
||||
SWSSCONFIG_ARGS+="td2.32ports.buffers.json td2.32ports.qos.json "
|
||||
|
@ -325,6 +325,19 @@ def parse_meta(meta, hname):
|
||||
deployment_id = value
|
||||
return syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst, deployment_id
|
||||
|
||||
def parse_deviceinfo(meta, hwsku):
|
||||
ethernet_interfaces = []
|
||||
|
||||
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"))):
|
||||
name = interface.find(str(QName(ns, "InterfaceName"))).text
|
||||
speed = interface.find(str(QName(ns, "Speed"))).text
|
||||
ethernet_interfaces.append({ 'name':name, 'speed':speed })
|
||||
|
||||
return ethernet_interfaces
|
||||
|
||||
def get_console_info(devices, dev, port):
|
||||
for k, v in devices.items():
|
||||
@ -411,6 +424,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
|
||||
neighbors = None
|
||||
devices = None
|
||||
hostname = None
|
||||
ethernet_interfaces = []
|
||||
syslog_servers = []
|
||||
dhcp_servers = []
|
||||
ntp_servers = []
|
||||
@ -440,6 +454,8 @@ def parse_xml(filename, platform=None, port_config_file=None):
|
||||
(u_neighbors, u_devices, _, _, _, _) = parse_png(child, hostname)
|
||||
elif child.tag == str(QName(ns, "MetadataDeclaration")):
|
||||
(syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst, deployment_id) = parse_meta(child, hostname)
|
||||
elif child.tag == str(QName(ns, "DeviceInfos")):
|
||||
ethernet_interfaces = parse_deviceinfo(child, hwsku)
|
||||
|
||||
results = {}
|
||||
results['minigraph_hwsku'] = hwsku
|
||||
@ -488,6 +504,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
|
||||
results['forced_mgmt_routes'] = mgmt_routes
|
||||
results['erspan_dst'] = erspan_dst
|
||||
results['deployment_id'] = deployment_id
|
||||
results['ethernet_interfaces'] = ethernet_interfaces
|
||||
|
||||
return results
|
||||
|
||||
|
@ -200,6 +200,68 @@
|
||||
</Device>
|
||||
</Devices>
|
||||
</PngDec>
|
||||
<DeviceInfos>
|
||||
<DeviceInfo>
|
||||
<AutoNegotiation>true</AutoNegotiation>
|
||||
<EthernetInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
<a:EthernetInterface>
|
||||
<ElementType>DeviceInterface</ElementType>
|
||||
<AlternateSpeeds i:nil="true"/>
|
||||
<EnableAutoNegotiation>true</EnableAutoNegotiation>
|
||||
<EnableFlowControl>true</EnableFlowControl>
|
||||
<Index>1</Index>
|
||||
<InterfaceName>fortyGigE0/0</InterfaceName>
|
||||
<InterfaceType i:nil="true"/>
|
||||
<MultiPortsInterface>false</MultiPortsInterface>
|
||||
<PortName>0</PortName>
|
||||
<Priority>0</Priority>
|
||||
<Speed>10000</Speed>
|
||||
</a:EthernetInterface>
|
||||
<a:EthernetInterface>
|
||||
<ElementType>DeviceInterface</ElementType>
|
||||
<AlternateSpeeds i:nil="true"/>
|
||||
<EnableAutoNegotiation>true</EnableAutoNegotiation>
|
||||
<EnableFlowControl>true</EnableFlowControl>
|
||||
<Index>1</Index>
|
||||
<InterfaceName>fortyGigE0/4</InterfaceName>
|
||||
<InterfaceType i:nil="true"/>
|
||||
<MultiPortsInterface>false</MultiPortsInterface>
|
||||
<PortName>0</PortName>
|
||||
<Priority>0</Priority>
|
||||
<Speed>25000</Speed>
|
||||
</a:EthernetInterface>
|
||||
<a:EthernetInterface>
|
||||
<ElementType>DeviceInterface</ElementType>
|
||||
<AlternateSpeeds i:nil="true"/>
|
||||
<EnableAutoNegotiation>true</EnableAutoNegotiation>
|
||||
<EnableFlowControl>true</EnableFlowControl>
|
||||
<Index>1</Index>
|
||||
<InterfaceName>fortyGigE0/8</InterfaceName>
|
||||
<InterfaceType i:nil="true"/>
|
||||
<MultiPortsInterface>false</MultiPortsInterface>
|
||||
<PortName>0</PortName>
|
||||
<Priority>0</Priority>
|
||||
<Speed>40000</Speed>
|
||||
</a:EthernetInterface>
|
||||
<a:EthernetInterface>
|
||||
<ElementType>DeviceInterface</ElementType>
|
||||
<AlternateSpeeds i:nil="true"/>
|
||||
<EnableAutoNegotiation>true</EnableAutoNegotiation>
|
||||
<EnableFlowControl>true</EnableFlowControl>
|
||||
<Index>1</Index>
|
||||
<InterfaceName>fortyGigE0/12</InterfaceName>
|
||||
<InterfaceType i:nil="true"/>
|
||||
<MultiPortsInterface>false</MultiPortsInterface>
|
||||
<PortName>0</PortName>
|
||||
<Priority>0</Priority>
|
||||
<Speed>1000000</Speed>
|
||||
</a:EthernetInterface>
|
||||
</EthernetInterfaces>
|
||||
<FlowControl>true</FlowControl>
|
||||
<Height>0</Height>
|
||||
<HwSku>Force10-S6000</HwSku>
|
||||
</DeviceInfo>
|
||||
</DeviceInfos>
|
||||
<Hostname>switch-t0</Hostname>
|
||||
<HwSku>Force10-S6000</HwSku>
|
||||
</DeviceMiniGraph>
|
||||
|
@ -119,3 +119,8 @@ class TestCfgGen(TestCase):
|
||||
argument = '-m "' + self.sample_graph_bgp_speaker + '" -p "' + self.port_config + '" -v deployment_id'
|
||||
output = self.run_script(argument)
|
||||
self.assertEqual(output.strip(), "1")
|
||||
|
||||
def test_minigraph_ethernet_interfaces(self):
|
||||
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v ethernet_interfaces'
|
||||
output = self.run_script(argument)
|
||||
self.assertEqual(output.strip(), "[{'speed': '10000', 'name': 'fortyGigE0/0'}, {'speed': '25000', 'name': 'fortyGigE0/4'}, {'speed': '40000', 'name': 'fortyGigE0/8'}, {'speed': '1000000', 'name': 'fortyGigE0/12'}]")
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit f9b55d30276d1a6ab94e7321d9b2a3bf076fd683
|
||||
Subproject commit eaccf67cabd22df0ff7d0117fe55f4261bc961d9
|
Loading…
Reference in New Issue
Block a user