From dd95237684ac70e15b7d8a94b616511c7341a36d Mon Sep 17 00:00:00 2001 From: liora Date: Sun, 13 Jun 2021 03:31:18 +0000 Subject: [PATCH 1/6] [sonic-buildimage] Update submodules for zero ports support Signed-off-by: liora --- .gitmodules | 8 ++++---- src/sonic-py-swsssdk | 2 +- src/sonic-snmpagent | 2 +- src/sonic-swss | 2 +- src/sonic-utilities | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitmodules b/.gitmodules index 96e5645dcaee..a30b97c0133d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,7 +9,7 @@ url = https://github.com/Azure/sonic-sairedis [submodule "sonic-swss"] path = src/sonic-swss - url = https://github.com/Azure/sonic-swss + url = https://github.com/liorghub/sonic-swss [submodule "src/p4c-bm/p4c-bm"] path = platform/p4/p4c-bm/p4c-bm url = https://github.com/krambn/p4c-bm @@ -25,16 +25,16 @@ url = https://github.com/Azure/sonic-dbsyncd [submodule "src/sonic-py-swsssdk"] path = src/sonic-py-swsssdk - url = https://github.com/Azure/sonic-py-swsssdk.git + url = https://github.com/liorghub/sonic-py-swsssdk.git [submodule "src/sonic-snmpagent"] path = src/sonic-snmpagent - url = https://github.com/Azure/sonic-snmpagent + url = https://github.com/liorghub/sonic-snmpagent [submodule "src/ptf"] path = src/ptf url = https://github.com/p4lang/ptf.git [submodule "src/sonic-utilities"] path = src/sonic-utilities - url = https://github.com/Azure/sonic-utilities + url = https://github.com/liorghub/sonic-utilities [submodule "platform/broadcom/sonic-platform-modules-arista"] path = platform/broadcom/sonic-platform-modules-arista url = https://github.com/aristanetworks/sonic diff --git a/src/sonic-py-swsssdk b/src/sonic-py-swsssdk index 6e42d58c15fc..40637b8d2b5a 160000 --- a/src/sonic-py-swsssdk +++ b/src/sonic-py-swsssdk @@ -1 +1 @@ -Subproject commit 6e42d58c15fc78977e59462bfc8cba2bb3017ae2 +Subproject commit 40637b8d2b5a6c2b179b8e6b45d241e1bb843c92 diff --git a/src/sonic-snmpagent b/src/sonic-snmpagent index 28b9dfd3a294..cd55670cc211 160000 --- a/src/sonic-snmpagent +++ b/src/sonic-snmpagent @@ -1 +1 @@ -Subproject commit 28b9dfd3a294904150b2d33bd3ff35a1a637d28d +Subproject commit cd55670cc2110648af8f30af98515264eeabf56a diff --git a/src/sonic-swss b/src/sonic-swss index dad128777e90..828a49c99195 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit dad128777e90df61ca312f694ce142e400a78b40 +Subproject commit 828a49c991956e1c24069a22bd58d3a3dc4042ba diff --git a/src/sonic-utilities b/src/sonic-utilities index 00bd0cea4f26..4632c559cad7 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit 00bd0cea4f260ca8cecc382a6bcea05272dfd070 +Subproject commit 4632c559cad79fe8280e9e56c02773730af51b05 From e662e65695f203010e6e81d1a41a151c3b8e7f6f Mon Sep 17 00:00:00 2001 From: liora Date: Mon, 28 Jun 2021 14:37:58 +0000 Subject: [PATCH 2/6] Revert "[sonic-buildimage] Update submodules for zero ports support" This reverts commit 75ff366cf9e2b7b4d5088bc06be681037dc479da. --- .gitmodules | 8 ++++---- src/sonic-py-swsssdk | 2 +- src/sonic-snmpagent | 2 +- src/sonic-swss | 2 +- src/sonic-utilities | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitmodules b/.gitmodules index a30b97c0133d..96e5645dcaee 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,7 +9,7 @@ url = https://github.com/Azure/sonic-sairedis [submodule "sonic-swss"] path = src/sonic-swss - url = https://github.com/liorghub/sonic-swss + url = https://github.com/Azure/sonic-swss [submodule "src/p4c-bm/p4c-bm"] path = platform/p4/p4c-bm/p4c-bm url = https://github.com/krambn/p4c-bm @@ -25,16 +25,16 @@ url = https://github.com/Azure/sonic-dbsyncd [submodule "src/sonic-py-swsssdk"] path = src/sonic-py-swsssdk - url = https://github.com/liorghub/sonic-py-swsssdk.git + url = https://github.com/Azure/sonic-py-swsssdk.git [submodule "src/sonic-snmpagent"] path = src/sonic-snmpagent - url = https://github.com/liorghub/sonic-snmpagent + url = https://github.com/Azure/sonic-snmpagent [submodule "src/ptf"] path = src/ptf url = https://github.com/p4lang/ptf.git [submodule "src/sonic-utilities"] path = src/sonic-utilities - url = https://github.com/liorghub/sonic-utilities + url = https://github.com/Azure/sonic-utilities [submodule "platform/broadcom/sonic-platform-modules-arista"] path = platform/broadcom/sonic-platform-modules-arista url = https://github.com/aristanetworks/sonic diff --git a/src/sonic-py-swsssdk b/src/sonic-py-swsssdk index 40637b8d2b5a..6e42d58c15fc 160000 --- a/src/sonic-py-swsssdk +++ b/src/sonic-py-swsssdk @@ -1 +1 @@ -Subproject commit 40637b8d2b5a6c2b179b8e6b45d241e1bb843c92 +Subproject commit 6e42d58c15fc78977e59462bfc8cba2bb3017ae2 diff --git a/src/sonic-snmpagent b/src/sonic-snmpagent index cd55670cc211..28b9dfd3a294 160000 --- a/src/sonic-snmpagent +++ b/src/sonic-snmpagent @@ -1 +1 @@ -Subproject commit cd55670cc2110648af8f30af98515264eeabf56a +Subproject commit 28b9dfd3a294904150b2d33bd3ff35a1a637d28d diff --git a/src/sonic-swss b/src/sonic-swss index 828a49c99195..dad128777e90 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 828a49c991956e1c24069a22bd58d3a3dc4042ba +Subproject commit dad128777e90df61ca312f694ce142e400a78b40 diff --git a/src/sonic-utilities b/src/sonic-utilities index 4632c559cad7..00bd0cea4f26 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit 4632c559cad79fe8280e9e56c02773730af51b05 +Subproject commit 00bd0cea4f260ca8cecc382a6bcea05272dfd070 From db76a6fa61dcb3a6c9ac0dea306e20ed00561cf2 Mon Sep 17 00:00:00 2001 From: liora Date: Sun, 13 Jun 2021 02:38:00 +0000 Subject: [PATCH 3/6] [sonic-cfggen] Allow cfggen to work on system without ports Signed-off-by: liora --- src/sonic-config-engine/sonic-cfggen | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index 26692399d950..c341b32ddd68 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -317,9 +317,6 @@ def main(): if args.port_config is None: args.port_config = device_info.get_path_to_port_config_file(hwsku) (ports, _, _) = get_port_config(hwsku, platform, args.port_config, asic_id) - if not ports: - print('Failed to get port config', file=sys.stderr) - sys.exit(1) deep_update(data, {'PORT': ports}) brkout_table = get_breakout_mode(hwsku, platform, args.port_config) From fd1f5cebad2a359ef217c5dd707c0503b97419d2 Mon Sep 17 00:00:00 2001 From: liora Date: Sun, 13 Jun 2021 02:38:00 +0000 Subject: [PATCH 4/6] [sonic-cfggen] Allow cfggen to work on system without ports Signed-off-by: liora --- src/sonic-config-engine/sonic-cfggen | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index c341b32ddd68..93f5cd125478 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -317,6 +317,9 @@ def main(): if args.port_config is None: args.port_config = device_info.get_path_to_port_config_file(hwsku) (ports, _, _) = get_port_config(hwsku, platform, args.port_config, asic_id) + if ports is None: + print('Failed to get port config', file=sys.stderr) + sys.exit(1) deep_update(data, {'PORT': ports}) brkout_table = get_breakout_mode(hwsku, platform, args.port_config) From 668db75ba8af5feffa4f2ea7522c790b78dfcf7b Mon Sep 17 00:00:00 2001 From: liora Date: Sun, 13 Jun 2021 02:38:00 +0000 Subject: [PATCH 5/6] [sonic-cfggen] Allow cfggen to work on system without ports Signed-off-by: liora --- src/sonic-config-engine/portconfig.py | 8 ++++---- .../tests/test_cfggen_platformJson.py | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/sonic-config-engine/portconfig.py b/src/sonic-config-engine/portconfig.py index 2eceb81bcac4..260632b754f9 100644 --- a/src/sonic-config-engine/portconfig.py +++ b/src/sonic-config-engine/portconfig.py @@ -261,9 +261,9 @@ def parse_platform_json_file(hwsku_json_file, platform_json_file): port_dict = readJson(platform_json_file) hwsku_dict = readJson(hwsku_json_file) - if not port_dict: + if port_dict is None: raise Exception("port_dict is none") - if not hwsku_dict: + if hwsku_dict is None: raise Exception("hwsku_dict is none") if INTF_KEY not in port_dict or INTF_KEY not in hwsku_dict: @@ -285,8 +285,8 @@ def parse_platform_json_file(hwsku_json_file, platform_json_file): ports.update(child_ports) - if not ports: - raise Exception("Ports dictionary is empty") + if ports is None: + raise Exception("Ports dictionary is None") for i in ports.keys(): port_alias_map[ports[i]["alias"]]= i diff --git a/src/sonic-config-engine/tests/test_cfggen_platformJson.py b/src/sonic-config-engine/tests/test_cfggen_platformJson.py index 4c7fc9729e78..acd6a42bfa9f 100644 --- a/src/sonic-config-engine/tests/test_cfggen_platformJson.py +++ b/src/sonic-config-engine/tests/test_cfggen_platformJson.py @@ -6,6 +6,8 @@ import tests.common_utils as utils from unittest import TestCase +from unittest import mock +from portconfig import get_port_config, INTF_KEY # Global Variable @@ -85,3 +87,10 @@ def test_platform_json_all_ethernet_interfaces(self): output_dict = ast.literal_eval(output.strip()) expected = ast.literal_eval(json.dumps(fh_data)) self.assertDictEqual(output_dict, expected) + + @mock.patch('portconfig.readJson', mock.MagicMock(return_value={INTF_KEY:{}})) + @mock.patch('os.path.isfile', mock.MagicMock(return_value=True)) + def test_platform_json_no_interfaces(self): + (ports, _, _) = get_port_config(port_config_file=self.platform_json) + self.assertNotEqual(ports, None) + self.assertEqual(ports, {}) From 95abadd92209e0c9b172f4b8236e8b5bc4685a2c Mon Sep 17 00:00:00 2001 From: liora Date: Sun, 13 Jun 2021 02:38:00 +0000 Subject: [PATCH 6/6] [sonic-cfggen] Allow cfggen to work on system without ports Signed-off-by: liora --- src/sonic-config-engine/tests/test_cfggen_platformJson.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sonic-config-engine/tests/test_cfggen_platformJson.py b/src/sonic-config-engine/tests/test_cfggen_platformJson.py index acd6a42bfa9f..1765fb4f3a2c 100644 --- a/src/sonic-config-engine/tests/test_cfggen_platformJson.py +++ b/src/sonic-config-engine/tests/test_cfggen_platformJson.py @@ -2,13 +2,17 @@ import json import os import subprocess +import sys import tests.common_utils as utils from unittest import TestCase -from unittest import mock from portconfig import get_port_config, INTF_KEY +if sys.version_info.major == 3: + from unittest import mock +else: + import mock # Global Variable PLATFORM_OUTPUT_FILE = "platform_output.json"