Commit 907af698 authored by Adeodato Simo's avatar Adeodato Simo
Browse files

Fix sorting bug in LUQueryGroups



In LUQueryGroups.Exec(), NiceSort was being applied to group UUIDs, and
not to group names. We use a temporary name to UUID map to sort the list
of UUIDs by group name instead.
Signed-off-by: default avatarAdeodato Simo <dato@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent bd92fca1
......@@ -10260,13 +10260,14 @@ class LUQueryGroups(NoHooksLU):
"""
all_groups = self.cfg.GetAllNodeGroupsInfo()
name_to_uuid = dict((g.name, g.uuid) for g in all_groups.values())
if not self.op.names:
my_groups = utils.NiceSort(all_groups.keys())
sorted_names = utils.NiceSort(name_to_uuid.keys())
my_groups = [name_to_uuid[n] for n in sorted_names]
else:
# Accept names to be either names or UUIDs.
all_uuid = frozenset(all_groups.keys())
name_to_uuid = dict((g.name, g.uuid) for g in all_groups.values())
my_groups = []
missing = []
......@@ -10312,8 +10313,8 @@ class LUQueryGroups(NoHooksLU):
output = []
for name in my_groups:
group = all_groups[name]
for uuid in my_groups:
group = all_groups[uuid]
group_output = []
for field in self.op.output_fields:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment