From f222ff949b4b77b0c17de75e7d50a4184b26865e Mon Sep 17 00:00:00 2001 From: Bobby McGonigle Date: Wed, 4 Dec 2024 18:56:22 -0800 Subject: [PATCH] Fix optional params not applying to all interfaces (#20313) Currently optional params only get applied to the first child port in group. We want optional parameters to apply to all child ports in group. For example: "Ethernet0": { "default_brkout_mode": "2x400G", "autoneg": "on" }, In this scenario we want autoneg on to be in the config_db entry for both interfaces that belong to the group; Ethernet0 and Ethernet4. Currently this only gets applied to Ethernet0: (Pdb++) pp child_ports {'Ethernet0': {'alias': 'Ethernet1/1', 'autoneg': 'on', 'index': '1', 'lanes': '17,18,19,20', 'speed': '400000', 'subport': '1'}, 'Ethernet4': {'alias': 'Ethernet1/5', 'index': '1', 'lanes': '21,22,23,24', 'speed': '400000', 'subport': '2'}} With this change it now gets applied to all interfaces in the group as expected (Pdb) pp child_ports {'Ethernet0': {'alias': 'Ethernet1/1', 'autoneg': 'on', 'index': '1', 'lanes': '17,18,19,20', 'speed': '400000', 'subport': '1'}, 'Ethernet4': {'alias': 'Ethernet1/5', 'autoneg': 'on', 'index': '1', 'lanes': '21,22,23,24', 'speed': '400000', 'subport': '2'}} Why I did it I need to apply optional hwsku params for a group of interfaces. How I did it Just changed to iterate over every child port in group. How to verify it Introduction to the problem shows verification of the solution. Check the output manually and also fixed the unit test to correspond and pass. --- src/sonic-config-engine/portconfig.py | 3 ++- .../tests/sample_output/platform_output.json | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sonic-config-engine/portconfig.py b/src/sonic-config-engine/portconfig.py index 788774d34969..b2550b12125f 100644 --- a/src/sonic-config-engine/portconfig.py +++ b/src/sonic-config-engine/portconfig.py @@ -430,7 +430,8 @@ def parse_platform_json_file(hwsku_json_file, platform_json_file): if child_port in hwsku_entry: for key, item in hwsku_entry[child_port].items(): if key in OPTIONAL_HWSKU_ATTRIBUTES: - child_ports.get(child_port)[key] = item + for child in child_ports: + child_ports.get(child)[key] = item ports.update(child_ports) diff --git a/src/sonic-config-engine/tests/sample_output/platform_output.json b/src/sonic-config-engine/tests/sample_output/platform_output.json index 51c26754e982..b820717499a1 100644 --- a/src/sonic-config-engine/tests/sample_output/platform_output.json +++ b/src/sonic-config-engine/tests/sample_output/platform_output.json @@ -976,7 +976,8 @@ "alias": "Eth36/1", "pfc_asym": "off", "subport": "1", - "speed": "25000" + "speed": "25000", + "role": "Dpc" }, "Ethernet141": { "index": "36", @@ -987,7 +988,8 @@ "alias": "Eth36/2", "pfc_asym": "off", "speed": "25000", - "subport": "2" + "subport": "2", + "role": "Dpc" }, "Ethernet142": { "index": "36",