#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
except socket.error, err:
if err.args and err.args[0] == errno.EAGAIN:
continue
raise
except socket.error, err:
if err.args and err.args[0] == errno.EAGAIN:
continue
raise
logging.error("LUXI request not a dict: %r", msg)
raise ProtocolError("Invalid LUXI request (not a dict)")
logging.error("LUXI request not a dict: %r", msg)
raise ProtocolError("Invalid LUXI request (not a dict)")
- method = request.get(KEY_METHOD, None) # pylint: disable-msg=E1103
- args = request.get(KEY_ARGS, None) # pylint: disable-msg=E1103
- version = request.get(KEY_VERSION, None) # pylint: disable-msg=E1103
+ method = request.get(KEY_METHOD, None) # pylint: disable=E1103
+ args = request.get(KEY_ARGS, None) # pylint: disable=E1103
+ version = request.get(KEY_VERSION, None) # pylint: disable=E1103
if method is None or args is None:
logging.error("LUXI request missing method or arguments: %r", msg)
if method is None or args is None:
logging.error("LUXI request missing method or arguments: %r", msg)
raise ProtocolError("Invalid response from server: %r" % data)
return (data[KEY_SUCCESS], data[KEY_RESULT],
raise ProtocolError("Invalid response from server: %r" % data)
return (data[KEY_SUCCESS], data[KEY_RESULT],
def CallLuxiMethod(transport_cb, method, args, version=None):
def CallLuxiMethod(transport_cb, method, args, version=None):
def CallMethod(self, method, args):
"""Send a generic request and return the response.
"""
def CallMethod(self, method, args):
"""Send a generic request and return the response.
"""
+ if not isinstance(args, (list, tuple)):
+ raise errors.ProgrammerError("Invalid parameter passed to CallMethod:"
+ " expected list, got %s" % type(args))
return CallLuxiMethod(self._SendMethodCall, method, args,
version=constants.LUXI_VERSION)
def SetQueueDrainFlag(self, drain_flag):
return CallLuxiMethod(self._SendMethodCall, method, args,
version=constants.LUXI_VERSION)
def SetQueueDrainFlag(self, drain_flag):
def SubmitJob(self, ops):
ops_state = map(lambda op: op.__getstate__(), ops)
def SubmitJob(self, ops):
ops_state = map(lambda op: op.__getstate__(), ops)
return self.CallMethod(REQ_SUBMIT_MANY_JOBS, jobs_state)
def CancelJob(self, job_id):
return self.CallMethod(REQ_SUBMIT_MANY_JOBS, jobs_state)
def CancelJob(self, job_id):
def AutoArchiveJobs(self, age):
timeout = (DEF_RWTO - 1) / 2
def AutoArchiveJobs(self, age):
timeout = (DEF_RWTO - 1) / 2
- def Query(self, what, fields, filter_):
+ def Query(self, what, fields, qfilter):
- req = objects.QueryRequest(what=what, fields=fields, filter=filter_)
- result = self.CallMethod(REQ_QUERY, req.ToDict())
+ result = self.CallMethod(REQ_QUERY, (what, fields, qfilter))
return objects.QueryResponse.FromDict(result)
def QueryFields(self, what, fields):
"""Query for available fields.
return objects.QueryResponse.FromDict(result)
def QueryFields(self, what, fields):
"""Query for available fields.
@type fields: None or list of strings
@param fields: List of requested fields
@rtype: L{objects.QueryFieldsResponse}
"""
@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())
+ result = self.CallMethod(REQ_QUERY_FIELDS, (what, fields))
return objects.QueryFieldsResponse.FromDict(result)
def QueryJobs(self, job_ids, fields):
return objects.QueryFieldsResponse.FromDict(result)
def QueryJobs(self, job_ids, fields):
return self.CallMethod(REQ_QUERY_CLUSTER_INFO, ())
def QueryConfigValues(self, fields):
return self.CallMethod(REQ_QUERY_CLUSTER_INFO, ())
def QueryConfigValues(self, fields):
def QueryTags(self, kind, name):
return self.CallMethod(REQ_QUERY_TAGS, (kind, name))
def QueryLocks(self, fields, sync):
def QueryTags(self, kind, name):
return self.CallMethod(REQ_QUERY_TAGS, (kind, name))
def QueryLocks(self, fields, sync):