Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port speed #879

Merged
merged 7 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions dockers/docker-orchagent/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 11 additions & 0 deletions dockers/docker-orchagent/ports.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{% for interface in ethernet_interfaces %}
{
"PORT_TABLE:{{ interface['name'] }}": {
"speed": "{{ interface['speed'] }}"
},
"OP": "SET"
}{% if not loop.last %},{% endif %}

{% endfor %}
]
1 change: 1 addition & 0 deletions dockers/docker-orchagent/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-orchagent/swssconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
15 changes: 15 additions & 0 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,17 @@ 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, hname):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change hname to hwsku

ethernet_interfaces = []

device_info = meta.find(str(QName(ns, "DeviceInfo")))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In DeviceInfos, there are many deviceinfo. You need findall deviceinfo. and for each deviceinfo, you need to find the hwsku and only choose the hwsku that is same as 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():
Expand Down Expand Up @@ -409,6 +420,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 = []
Expand Down Expand Up @@ -438,6 +450,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, hostname)
Copy link
Collaborator

@lguohan lguohan Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to parse_deviceinfo(child, hwsku)


results = {}
results['minigraph_hwsku'] = hwsku
Expand Down Expand Up @@ -486,6 +500,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

Expand Down
59 changes: 59 additions & 0 deletions src/sonic-config-engine/tests/simple-sample-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,65 @@
</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>Ethernet0</InterfaceName>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> fortyGigE0/0

<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>Ethernet4</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>Ethernet8</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>Ethernet12</InterfaceName>
<InterfaceType i:nil="true"/>
<MultiPortsInterface>false</MultiPortsInterface>
<PortName>0</PortName>
<Priority>0</Priority>
<Speed>1000000</Speed>
</a:EthernetInterface>
</EthernetInterfaces>
</DeviceInfo>
Copy link
Collaborator

@lguohan lguohan Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add hwsku in the deviceinfo

<HwSku>Force10-S6000</HwSku>

</DeviceInfos>
<Hostname>switch-t0</Hostname>
<HwSku>Force10-S6000</HwSku>
</DeviceMiniGraph>
5 changes: 5 additions & 0 deletions src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,8 @@ def test_minigraph_deployment_id(self):
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': 'Ethernet0'}, {'speed': '25000', 'name': 'Ethernet4'}, {'speed': '40000', 'name': 'Ethernet8'}, {'speed': '1000000', 'name': 'Ethernet12'}]")