Commit c1391810 authored by Michael Hanselmann's avatar Michael Hanselmann

masterd: Simplify code for field queries

Instead of going via cmdlib and using special cases for different
resources, the list of fields is used directly.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent abd66bf8
......@@ -496,15 +496,6 @@ class _QueryBase:
# Return expanded names
return self.wanted
@classmethod
def FieldsQuery(cls, fields):
"""Returns list of available fields.
@return: List of L{objects.QueryFieldDefinition}
"""
return query.QueryFields(cls.FIELDS, fields)
def ExpandNames(self, lu):
"""Expand names for this query.
......@@ -4044,7 +4035,7 @@ class LUQueryFields(NoHooksLU):
self.needed_locks = {}
def Exec(self, feedback_fn):
return self.qcls.FieldsQuery(self.op.fields)
return query.QueryFields(self.qcls.FIELDS, self.op.fields)
class LUNodeModifyStorage(NoHooksLU):
......
......@@ -250,18 +250,13 @@ class ClientOps:
elif method == luxi.REQ_QUERY_FIELDS:
req = objects.QueryFieldsRequest.FromDict(args)
if req.what in constants.QR_VIA_OP:
result = self._Query(opcodes.OpQueryFields(what=req.what,
fields=req.fields))
elif req.what == constants.QR_LOCK:
return query.QueryFields(query.LOCK_FIELDS, req.fields)
elif req.what in constants.QR_VIA_LUXI:
raise NotImplementedError
else:
try:
fielddefs = query.ALL_FIELDS[req.what]
except KeyError:
raise errors.OpPrereqError("Resource type '%s' unknown" % req.what,
errors.ECODE_INVAL)
return result
return query.QueryFields(fielddefs, req.fields)
elif method == luxi.REQ_QUERY_JOBS:
(job_ids, fields) = args
......
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