Commit a0dcf7c2 authored by Oleksiy Mishchenko's avatar Oleksiy Mishchenko
Browse files

RAPI: Switch from opcodes to no native 2.0 queries.

Reviewed-by: imsnah
parent b7cb9024
......@@ -125,11 +125,11 @@ CONNECTOR.update({
"/tags": rlib1.R_tags,
"/info": rlib1.R_info,
"/nodes": rlib1.R_nodes,
"/nodes": rlib2.R_2_nodes,
re.compile(r'^/nodes/([\w\._-]+)$'): rlib1.R_nodes_name,
re.compile(r'^/nodes/([\w\._-]+)/tags$'): rlib1.R_nodes_name_tags,
"/instances": rlib1.R_instances,
"/instances": rlib2.R_2_instances,
re.compile(r'^/instances/([\w\._-]+)$'): rlib1.R_instances_name,
re.compile(r'^/instances/([\w\._-]+)/tags$'): rlib1.R_instances_name_tags,
......
......@@ -128,14 +128,13 @@ class R_2_nodes(baserlib.R_Generic):
]
"""
op = ganeti.opcodes.OpQueryNodes(output_fields=["name"], names=[])
nodeslist = baserlib.ExtractField(ganeti.cli.SubmitOpCode(op), 0)
client = luxi.Client()
nodesdata = client.QueryNodes([], ["name"])
nodeslist = [row[0] for row in nodesdata]
if 'bulk' in self.queryargs:
op = ganeti.opcodes.OpQueryNodes(output_fields=N_FIELDS,
names=nodeslist)
result = ganeti.cli.SubmitOpCode(op)
return baserlib.MapBulkFields(result, N_FIELDS)
bulkdata = client.QueryNodes(nodeslist, N_FIELDS)
return baserlib.MapBulkFields(bulkdata, N_FIELDS)
return baserlib.BuildUriList(nodeslist, "/2/nodes/%s",
uri_fields=("id", "uri"))
......@@ -190,15 +189,14 @@ class R_2_instances(baserlib.R_Generic):
]
"""
op = ganeti.opcodes.OpQueryInstances(output_fields=["name"], names=[])
instanceslist = baserlib.ExtractField(ganeti.cli.SubmitOpCode(op), 0)
client = luxi.Client()
instancesdata = client.QueryInstances([], ["name"])
instanceslist = [row[0] for row in instancesdata]
if 'bulk' in self.queryargs:
op = ganeti.opcodes.OpQueryInstances(output_fields=I_FIELDS,
names=instanceslist)
result = ganeti.cli.SubmitOpCode(op)
return baserlib.MapBulkFields(result, I_FIELDS)
if 'bulk' in self.queryargs:
bulkdata = client.QueryInstances(instanceslist, I_FIELDS)
return baserlib.MapBulkFields(bulkdata, I_FIELDS)
else:
return baserlib.BuildUriList(instanceslist, "/2/instances/%s",
......
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