Revision 28b71a76
b/lib/constants.py | ||
---|---|---|
947 | 947 |
#: List of resources which can be queried using L{opcodes.OpQuery} |
948 | 948 |
QR_OP_QUERY = frozenset([QR_INSTANCE, QR_NODE]) |
949 | 949 |
|
950 |
#: List of resources which can be queried using LUXI |
|
951 |
QR_OP_LUXI = QR_OP_QUERY.union([ |
|
952 |
]) |
|
953 |
|
|
950 | 954 |
# Query field types |
951 | 955 |
QFT_UNKNOWN = "unknown" |
952 | 956 |
QFT_TEXT = "text" |
b/lib/luxi.py | ||
---|---|---|
39 | 39 |
from ganeti import constants |
40 | 40 |
from ganeti import errors |
41 | 41 |
from ganeti import utils |
42 |
from ganeti import objects |
|
42 | 43 |
|
43 | 44 |
|
44 | 45 |
KEY_METHOD = "method" |
... | ... | |
53 | 54 |
REQ_CANCEL_JOB = "CancelJob" |
54 | 55 |
REQ_ARCHIVE_JOB = "ArchiveJob" |
55 | 56 |
REQ_AUTOARCHIVE_JOBS = "AutoArchiveJobs" |
57 |
REQ_QUERY = "Query" |
|
58 |
REQ_QUERY_FIELDS = "QueryFields" |
|
56 | 59 |
REQ_QUERY_JOBS = "QueryJobs" |
57 | 60 |
REQ_QUERY_INSTANCES = "QueryInstances" |
58 | 61 |
REQ_QUERY_NODES = "QueryNodes" |
... | ... | |
487 | 490 |
break |
488 | 491 |
return result |
489 | 492 |
|
493 |
def Query(self, what, fields, filter_): |
|
494 |
"""Query for resources/items. |
|
495 |
|
|
496 |
@param what: One of L{constants.QR_OP_LUXI} |
|
497 |
@type fields: List of strings |
|
498 |
@param fields: List of requested fields |
|
499 |
@type filter_: None or list |
|
500 |
@param filter_: Query filter |
|
501 |
@rtype: L{objects.QueryResponse} |
|
502 |
|
|
503 |
""" |
|
504 |
req = objects.QueryRequest(what=what, fields=fields, filter=filter_) |
|
505 |
result = self.CallMethod(REQ_QUERY, req.ToDict()) |
|
506 |
return objects.QueryResponse.FromDict(result) |
|
507 |
|
|
508 |
def QueryFields(self, what, fields): |
|
509 |
"""Query for available fields. |
|
510 |
|
|
511 |
@param what: One of L{constants.QR_OP_LUXI} |
|
512 |
@type fields: None or list of strings |
|
513 |
@param fields: List of requested fields |
|
514 |
@rtype: L{objects.QueryFieldsResponse} |
|
515 |
|
|
516 |
""" |
|
517 |
req = objects.QueryFieldsRequest(what=what, fields=fields) |
|
518 |
result = self.CallMethod(REQ_QUERY_FIELDS, req.ToDict()) |
|
519 |
return objects.QueryFieldsResponse.FromDict(result) |
|
520 |
|
|
490 | 521 |
def QueryJobs(self, job_ids, fields): |
491 | 522 |
return self.CallMethod(REQ_QUERY_JOBS, (job_ids, fields)) |
492 | 523 |
|
b/lib/server/masterd.py | ||
---|---|---|
55 | 55 |
from ganeti import rpc |
56 | 56 |
from ganeti import bootstrap |
57 | 57 |
from ganeti import netutils |
58 |
from ganeti import objects |
|
58 | 59 |
|
59 | 60 |
|
60 | 61 |
CLIENT_REQUEST_WORKERS = 16 |
... | ... | |
227 | 228 |
return queue.WaitForJobChanges(job_id, fields, prev_job_info, |
228 | 229 |
prev_log_serial, timeout) |
229 | 230 |
|
231 |
elif method == luxi.REQ_QUERY: |
|
232 |
req = objects.QueryRequest.FromDict(args) |
|
233 |
|
|
234 |
if req.what in constants.QR_OP_QUERY: |
|
235 |
result = self._Query(opcodes.OpQuery(what=req.what, fields=req.fields, |
|
236 |
filter=req.filter)) |
|
237 |
elif req.what in constants.QR_OP_LUXI: |
|
238 |
raise NotImplementedError |
|
239 |
else: |
|
240 |
raise errors.OpPrereqError("Resource type '%s' unknown" % req.what, |
|
241 |
errors.ECODE_INVAL) |
|
242 |
|
|
243 |
return result |
|
244 |
|
|
245 |
elif method == luxi.REQ_QUERY_FIELDS: |
|
246 |
req = objects.QueryFieldsRequest.FromDict(args) |
|
247 |
|
|
248 |
if req.what in constants.QR_OP_QUERY: |
|
249 |
result = self._Query(opcodes.OpQueryFields(what=req.what, |
|
250 |
fields=req.fields)) |
|
251 |
elif req.what in constants.QR_OP_LUXI: |
|
252 |
raise NotImplementedError |
|
253 |
else: |
|
254 |
raise errors.OpPrereqError("Resource type '%s' unknown" % req.what, |
|
255 |
errors.ECODE_INVAL) |
|
256 |
|
|
257 |
return result |
|
258 |
|
|
230 | 259 |
elif method == luxi.REQ_QUERY_JOBS: |
231 | 260 |
(job_ids, fields) = args |
232 | 261 |
if isinstance(job_ids, (tuple, list)) and job_ids: |
Also available in: Unified diff