From 8bd272cda1115ecb01a7749d4cdadb2ff524bb8f Mon Sep 17 00:00:00 2001 From: Andriy Moroz Date: Wed, 5 Jul 2017 14:44:33 +0300 Subject: [PATCH 1/2] Add port speed configuration --- dockers/docker-orchagent/Dockerfile.j2 | 1 + dockers/docker-orchagent/ports.json.j2 | 10 ++++++++++ dockers/docker-orchagent/start.sh | 1 + dockers/docker-orchagent/swssconfig.sh | 2 +- platform/mellanox/mlnx-sai.mk | 2 +- 5 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 dockers/docker-orchagent/ports.json.j2 diff --git a/dockers/docker-orchagent/Dockerfile.j2 b/dockers/docker-orchagent/Dockerfile.j2 index e4e155163076..86cda329a84f 100755 --- a/dockers/docker-orchagent/Dockerfile.j2 +++ b/dockers/docker-orchagent/Dockerfile.j2 @@ -30,6 +30,7 @@ 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"] diff --git a/dockers/docker-orchagent/ports.json.j2 b/dockers/docker-orchagent/ports.json.j2 new file mode 100644 index 000000000000..b203c0390f4e --- /dev/null +++ b/dockers/docker-orchagent/ports.json.j2 @@ -0,0 +1,10 @@ +[ +{% for port in port_properties %} + { + "PORT_TABLE:{{ port['name'] }}": { + "speed": "{{ port['speed'] }}", + }, + "OP": "SET" + }{% if not loop.last %},{% endif %} +{% endfor %} +] diff --git a/dockers/docker-orchagent/start.sh b/dockers/docker-orchagent/start.sh index 40ef66441c02..5f961a8bd294 100755 --- a/dockers/docker-orchagent/start.sh +++ b/dockers/docker-orchagent/start.sh @@ -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` diff --git a/dockers/docker-orchagent/swssconfig.sh b/dockers/docker-orchagent/swssconfig.sh index ab6c39403b59..1738a70e8325 100755 --- a/dockers/docker-orchagent/swssconfig.sh +++ b/dockers/docker-orchagent/swssconfig.sh @@ -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 " diff --git a/platform/mellanox/mlnx-sai.mk b/platform/mellanox/mlnx-sai.mk index 8d3712cb1378..3e29fb5aad6d 100644 --- a/platform/mellanox/mlnx-sai.mk +++ b/platform/mellanox/mlnx-sai.mk @@ -1,7 +1,7 @@ # Mellanox SAI MLNX_SAI_VERSION = 161120 -MLNX_SAI_REVISION = b57b458ff060adb2b1df629e330431a391a3b83e +MLNX_SAI_REVISION = 7e6598d231285f406096a50ad605d00371815004 export MLNX_SAI_VERSION MLNX_SAI_REVISION From 965b5fbf100665996f3936fd0519a92da854e571 Mon Sep 17 00:00:00 2001 From: Andriy Moroz Date: Thu, 6 Jul 2017 17:13:47 +0300 Subject: [PATCH 2/2] Add DeviceInfos support in minigraph parser --- dockers/docker-orchagent/ports.json.j2 | 7 ++++--- src/sonic-config-engine/minigraph.py | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/dockers/docker-orchagent/ports.json.j2 b/dockers/docker-orchagent/ports.json.j2 index b203c0390f4e..f59ee993eead 100644 --- a/dockers/docker-orchagent/ports.json.j2 +++ b/dockers/docker-orchagent/ports.json.j2 @@ -1,10 +1,11 @@ [ -{% for port in port_properties %} +{% for interface in ethernet_interfaces %} { - "PORT_TABLE:{{ port['name'] }}": { - "speed": "{{ port['speed'] }}", + "PORT_TABLE:{{ interface['name'] }}": { + "speed": "{{ interface['speed'] }}" }, "OP": "SET" }{% if not loop.last %},{% endif %} + {% endfor %} ] diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 8d3e82ea1233..3dd31bfd1137 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -315,6 +315,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): + ethernet_interfaces = [] + + device_info = meta.find(str(QName(ns, "DeviceInfo"))) + 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(): @@ -402,6 +413,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 = [] @@ -431,6 +443,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) Tree = lambda: defaultdict(Tree) @@ -481,6 +495,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