Commit bd92fca1 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

cmdlib: Sort list of fields for QueryFields


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 0538c375
......@@ -39,6 +39,7 @@ import OpenSSL
import socket
import tempfile
import shutil
import operator
from ganeti import ssh
from ganeti import utils
......@@ -545,9 +546,11 @@ class _QueryBase:
"""
if fields is None:
# Client requests all fields
fdefs = query.GetAllFields(cls.FIELDS.values())
# Client requests all fields, sort by name
fdefs = sorted(query.GetAllFields(cls.FIELDS.values()),
key=operator.attrgetter("name"))
else:
# Keep order as requested by client
fdefs = query.Query(cls.FIELDS, fields).GetFields()
return objects.QueryFieldsResponse(fields=fdefs).ToDict()
......
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