Skip to content

Commit 25a170e

Browse files
author
Sangita Maity
committed
[dpb|config] Fix the validation logic of breakout mode and update test cases
Signed-off-by: Sangita Maity <[email protected]>
1 parent 9332b8e commit 25a170e

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

config/main.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,8 @@ def _get_breakout_options(ctx, args, incomplete):
110110
else:
111111
breakout_file_input = readJsonFile(breakout_cfg_file)
112112
if interface_name in breakout_file_input[INTF_KEY]:
113-
breakout_mode_list = [v["breakout_modes"] for i, v in breakout_file_input[INTF_KEY].items() if i == interface_name][0]
114-
breakout_mode_options = []
115-
for i in breakout_mode_list.split(','):
116-
breakout_mode_options.append(i)
113+
breakout_mode_options = [mode for i, v in breakout_file_input[INTF_KEY].items() if i == interface_name \
114+
for mode in v["breakout_modes"].keys()]
117115
all_mode_options = [str(c) for c in breakout_mode_options if incomplete in c]
118116
return all_mode_options
119117

@@ -152,7 +150,7 @@ def _validate_interface_mode(ctx, breakout_cfg_file, interface_name, target_brko
152150
return False
153151

154152
# Check whether target breakout mode is available for the user-selected interface or not
155-
if target_brkout_mode not in breakout_file_input[interface_name]["breakout_modes"]:
153+
if target_brkout_mode not in breakout_file_input[interface_name]["breakout_modes"].keys():
156154
click.secho('[ERROR] Target mode {} is not available for the port {}'. format(target_brkout_mode, interface_name), fg='red')
157155
return False
158156

tests/config_dpb_test.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,41 @@
2121
"Ethernet0": {
2222
"index": "1,1,1,1",
2323
"lanes": "65,66,67,68",
24-
"alias_at_lanes": "Eth1/1, Eth1/2, Eth1/3, Eth1/4",
25-
"breakout_modes": "1x100G[40G],2x50G,4x25G[10G]"
24+
"breakout_modes": {
25+
"1x100G[40G]": ["Eth1"],
26+
"2x50G": ["Eth1/1", "Eth1/2"],
27+
"4x25G[10G]": ["Eth1/1", "Eth1/2", "Eth1/3", "Eth1/4"]
28+
}
2629
},
2730
"Ethernet4": {
2831
"index": "2,2,2,2",
2932
"lanes": "69,70,71,72",
30-
"alias_at_lanes": "Eth2/1, Eth2/2, Eth2/3, Eth2/4",
31-
"breakout_modes": "1x100G[40G],2x50G,4x25G[10G],1x50G(2)+2x25G(2)"
33+
"breakout_modes": {
34+
"1x100G[40G]": ["Eth2"],
35+
"2x50G": ["Eth2/1", "Eth2/2"],
36+
"4x25G[10G]": ["Eth2/1", "Eth2/2", "Eth2/3", "Eth2/4"],
37+
"1x50G(2)+2x25G(2)": ["Eth2/1", "Eth2/2", "Eth2/3"]
38+
}
3239
},
3340
"Ethernet8": {
3441
"index": "3,3,3,3",
3542
"lanes": "73,74,75,76",
3643
"alias_at_lanes": "Eth3/1, Eth3/2, Eth3/3, Eth3/4",
37-
"breakout_modes": "1x100G[40G],2x50G,4x25G[10G],1x50G(2)+2x25G(2)"
44+
"breakout_modes": {
45+
"1x100G[40G]": ["Eth3"],
46+
"2x50G": ["Eth3/1", "Eth3/2"],
47+
"4x25G[10G]": ["Eth3/1", "Eth3/2", "Eth3/3", "Eth3/4"],
48+
"1x50G(2)+2x25G(2)": ["Eth3/1", "Eth3/2", "Eth3/3"]
49+
}
3850
},
3951
"Ethernet12": {
4052
"index": "4,4,4,4",
4153
"lanes": "77,78,79,80",
42-
"alias_at_lanes": "Eth4/1, Eth4/2, Eth4/3, Eth4/4",
43-
"breakout_modes": "1x100G[40G],2x50G,4x25G[10G]"
54+
"breakout_modes": {
55+
"1x100G[40G]": ["Eth4"],
56+
"2x50G": ["Eth4/1", "Eth4/2"],
57+
"4x25G[10G]": ["Eth4/1", "Eth1/2", "Eth4/3", "Eth4/4"]
58+
}
4459
}
4560
}
4661
}

0 commit comments

Comments
 (0)