Revision 28b71a76 lib/luxi.py
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 |
|
Also available in: Unified diff