4
4
5
5
import click
6
6
import utilities_common .cli as clicommon
7
+ from natsort import natsorted
7
8
from sonic_py_common import multi_asic
8
9
from swsscommon import swsscommon
9
10
from swsssdk import ConfigDBConnector
@@ -190,7 +191,7 @@ def status(port, json_output):
190
191
port_status_dict ["MUX_CABLE" ] = {}
191
192
for namespace in namespaces :
192
193
asic_id = multi_asic .get_asic_index_from_namespace (namespace )
193
- for key in port_table_keys [asic_id ]:
194
+ for key in natsorted ( port_table_keys [asic_id ]) :
194
195
port = key .split ("|" )[1 ]
195
196
muxcable_info_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
196
197
per_npu_statedb [asic_id ].STATE_DB , 'MUX_CABLE_TABLE|{}' .format (port ))
@@ -201,7 +202,7 @@ def status(port, json_output):
201
202
print_data = []
202
203
for namespace in namespaces :
203
204
asic_id = multi_asic .get_asic_index_from_namespace (namespace )
204
- for key in port_table_keys [asic_id ]:
205
+ for key in natsorted ( port_table_keys [asic_id ]) :
205
206
port = key .split ("|" )[1 ]
206
207
muxcable_info_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
207
208
per_npu_statedb [asic_id ].STATE_DB , 'MUX_CABLE_TABLE|{}' .format (port ))
@@ -317,7 +318,7 @@ def config(port, json_output):
317
318
port_status_dict ["MUX_CABLE" ]["PORTS" ] = {}
318
319
for namespace in namespaces :
319
320
asic_id = multi_asic .get_asic_index_from_namespace (namespace )
320
- for port in port_mux_tbl_keys [asic_id ]:
321
+ for port in natsorted ( port_mux_tbl_keys [asic_id ]) :
321
322
create_json_dump_per_port_config (port_status_dict , per_npu_configdb , asic_id , port )
322
323
323
324
click .echo ("{}" .format (json .dumps (port_status_dict , indent = 4 )))
@@ -326,7 +327,7 @@ def config(port, json_output):
326
327
print_peer_tor = []
327
328
for namespace in namespaces :
328
329
asic_id = multi_asic .get_asic_index_from_namespace (namespace )
329
- for port in port_mux_tbl_keys [asic_id ]:
330
+ for port in natsorted ( port_mux_tbl_keys [asic_id ]) :
330
331
create_table_dump_per_port_config (print_data , per_npu_configdb , asic_id , port )
331
332
332
333
headers = ['SWITCH_NAME' , 'PEER_TOR' ]
0 commit comments