import time
import errno
import logging
+import warnings
from ganeti import serializer
from ganeti import constants
from ganeti import errors
from ganeti import utils
+from ganeti import objects
KEY_METHOD = "method"
REQ_CANCEL_JOB = "CancelJob"
REQ_ARCHIVE_JOB = "ArchiveJob"
REQ_AUTOARCHIVE_JOBS = "AutoArchiveJobs"
+REQ_QUERY = "Query"
+REQ_QUERY_FIELDS = "QueryFields"
REQ_QUERY_JOBS = "QueryJobs"
REQ_QUERY_INSTANCES = "QueryInstances"
REQ_QUERY_NODES = "QueryNodes"
+REQ_QUERY_GROUPS = "QueryGroups"
REQ_QUERY_EXPORTS = "QueryExports"
REQ_QUERY_CONFIG_VALUES = "QueryConfigValues"
REQ_QUERY_CLUSTER_INFO = "QueryClusterInfo"
self._CloseTransport()
raise
+ def Close(self):
+ """Close the underlying connection.
+
+ """
+ self._CloseTransport()
+
def CallMethod(self, method, args):
"""Send a generic request and return the response.
break
return result
+ def Query(self, what, fields, filter_):
+ """Query for resources/items.
+
+ @param what: One of L{constants.QR_OP_LUXI}
+ @type fields: List of strings
+ @param fields: List of requested fields
+ @type filter_: None or list
+ @param filter_: Query filter
+ @rtype: L{objects.QueryResponse}
+
+ """
+ req = objects.QueryRequest(what=what, fields=fields, filter=filter_)
+ result = self.CallMethod(REQ_QUERY, req.ToDict())
+ return objects.QueryResponse.FromDict(result)
+
+ def QueryFields(self, what, fields):
+ """Query for available fields.
+
+ @param what: One of L{constants.QR_OP_LUXI}
+ @type fields: None or list of strings
+ @param fields: List of requested fields
+ @rtype: L{objects.QueryFieldsResponse}
+
+ """
+ req = objects.QueryFieldsRequest(what=what, fields=fields)
+ result = self.CallMethod(REQ_QUERY_FIELDS, req.ToDict())
+ return objects.QueryFieldsResponse.FromDict(result)
+
def QueryJobs(self, job_ids, fields):
return self.CallMethod(REQ_QUERY_JOBS, (job_ids, fields))
def QueryNodes(self, names, fields, use_locking):
return self.CallMethod(REQ_QUERY_NODES, (names, fields, use_locking))
+ def QueryGroups(self, names, fields, use_locking):
+ return self.CallMethod(REQ_QUERY_GROUPS, (names, fields, use_locking))
+
def QueryExports(self, nodes, use_locking):
return self.CallMethod(REQ_QUERY_EXPORTS, (nodes, use_locking))
return self.CallMethod(REQ_QUERY_TAGS, (kind, name))
def QueryLocks(self, fields, sync):
+ warnings.warn("This LUXI call is deprecated and will be removed, use"
+ " Query(\"%s\", ...) instead" % constants.QR_LOCK)
return self.CallMethod(REQ_QUERY_LOCKS, (fields, sync))