Skip to content

Commit c324cbe

Browse files
caladdbsanders
authored andcommitted
BUGFIX: Sort numeric rack and rank numerically
This will sort multi-digit rack and rack so that this: ``` HOST RACK RANK APPLIANCE OS BOX ENVIRONMENT OSACTION INSTALLACTION COMMENT stacki-667-123 0 0 frontend sles frontend ----------- default default ------- stacki-667-14 667 14 backend sles default ----------- default console ------- stacki-667-15 667 15 backend sles default ----------- default console ------- stacki-667-5 667 5 backend sles default ----------- default console ------- stacki-667-6 667 6 backend sles default ----------- default console ------- stacki-667-7 667 7 backend sles default ----------- default console ------- ``` Will now be sorted in rack order, like this: ``` HOST RACK RANK APPLIANCE OS BOX ENVIRONMENT OSACTION INSTALLACTION COMMENT stacki-667-123 0 0 frontend sles frontend ----------- default default ------- stacki-667-5 667 5 backend sles default ----------- default console ------- stacki-667-6 667 6 backend sles default ----------- default console ------- stacki-667-7 667 7 backend sles default ----------- default console ------- stacki-667-14 667 14 backend sles default ----------- default console ------- stacki-667-15 667 15 backend sles default ----------- default console ------- ```
1 parent eef54c7 commit c324cbe

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

  • common/src/stack/command/stack/argument_processors
  • test-framework/test-suites/integration/tests/list

common/src/stack/command/stack/argument_processors/host.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ def getHostnames(self, names=[], managed_only=False, subnet=None, host_filter=No
104104
# (intable-ness of rack, rack, intable-ness of rank, rank)
105105
key=lambda h: (
106106
not h['rack'].isnumeric(),
107-
h['rack'],
107+
int(h['rack']) if h['rack'].isnumeric() else h['rack'],
108108
not h['rank'].isnumeric(),
109-
h['rank']
109+
int(h['rank']) if h['rank'].isnumeric() else h['rank']
110110
)
111111
)
112112

test-framework/test-suites/integration/tests/list/test_list_host.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,14 @@ def test_hosts_sorting(self, host, add_host):
106106
("stacki-2-12" , "2" , "12" , "backend"),
107107
("stacki-2-10" , "2" , "10" , "backend"),
108108
("backend-1-0" , "1" , "station-11" , "backend"),
109+
("stacki-2-2" , "2" , "2" , "backend"),
109110
("ethernet-2-43" , "2" , "43" , "switch"),
110111
("backend-0-1" , "sector-42" , "2" , "backend"),
111112
("backend-0-3" , "sector-42" , "4" , "backend"),
112113
("backend-0-4" , "sector-42" , "station-8" , "backend"),
113114
("infiniband-2-20" , "2" , "20" , "switch"),
114115
("backend-0-2" , "sector-42" , "3" , "backend"),
116+
("stacki-2-4" , "2" , "4" , "backend"),
115117
]
116118

117119
# backend-0-0 and frontend-0-0 already added at test initialization...
@@ -123,6 +125,8 @@ def test_hosts_sorting(self, host, add_host):
123125
backend-0-0
124126
backend-1-0
125127
ethernet-2-1
128+
stacki-2-2
129+
stacki-2-4
126130
stacki-2-10
127131
stacki-2-11
128132
stacki-2-12

0 commit comments

Comments
 (0)