Commit ee6c7b94 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Implement query for instances

Queries don't create jobs and are more efficient. Log messages
are not yet stored anywhere.

Reviewed-by: iustinp
parent 23752136
......@@ -227,9 +227,25 @@ class ClientOps:
(job_ids, fields) = args
return queue.QueryJobs(job_ids, fields)
elif method == luxi.REQ_QUERY_INSTANCES:
(names, fields) = args
op = opcodes.OpQueryInstances(names=names, output_fields=fields)
return self._Query(op)
raise ValueError("Invalid operation")
def _DummyLog(self, *args):
def _Query(self, op):
"""Runs the specified opcode and returns the result.
proc = mcpu.Processor(self.server.context)
# TODO: Where should log messages go?
return proc.ExecOpCode(op, self._DummyLog)
class GanetiContext(object):
"""Context common to all ganeti threads.
......@@ -47,6 +47,7 @@ REQ_SUBMIT_JOB = "SubmitJob"
REQ_CANCEL_JOB = "CancelJob"
REQ_ARCHIVE_JOB = "ArchiveJob"
REQ_QUERY_JOBS = "QueryJobs"
REQ_QUERY_INSTANCES = "QueryInstances"
......@@ -288,4 +289,7 @@ class Client(object):
def QueryJobs(self, job_ids, fields):
return self.CallMethod(REQ_QUERY_JOBS, (job_ids, fields))
def QueryInstances(self, names, fields):
return self.CallMethod(REQ_QUERY_INSTANCES, (names, fields))
# TODO: class Server(object)
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