Commit 9fbf0098 authored by Iustin Pop's avatar Iustin Pop
Browse files

Enable query socket usage in gnt-node/gnt-group



This switches gnt-node/gnt-group (and their equivalent RAPI resources)
to go over the query socket.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent cd67e337
......@@ -124,10 +124,12 @@ def ListGroups(opts, args):
"ndparams": (_FmtDict, False),
}
cl = GetClient(query=True)
return GenericList(constants.QR_GROUP, desired_fields, args, None,
opts.separator, not opts.no_headers,
format_override=fmtoverride, verbose=opts.verbose,
force_filter=opts.force_filter)
force_filter=opts.force_filter, cl=cl)
def ListGroupFields(opts, args):
......@@ -140,8 +142,10 @@ def ListGroupFields(opts, args):
@return: the desired exit code
"""
cl = GetClient(query=True)
return GenericListFields(constants.QR_GROUP, args, opts.separator,
not opts.no_headers)
not opts.no_headers, cl=cl)
def SetGroupParams(opts, args):
......@@ -295,7 +299,7 @@ def GroupInfo(_, args):
"""Shows info about node group.
"""
cl = GetClient()
cl = GetClient(query=True)
selected_fields = ["name",
"ndparams", "custom_ndparams",
"diskparams", "custom_diskparams",
......
......@@ -253,10 +253,12 @@ def ListNodes(opts, args):
fmtoverride = dict.fromkeys(["pinst_list", "sinst_list", "tags"],
(",".join, False))
cl = GetClient(query=True)
return GenericList(constants.QR_NODE, selected_fields, args, opts.units,
opts.separator, not opts.no_headers,
format_override=fmtoverride, verbose=opts.verbose,
force_filter=opts.force_filter)
force_filter=opts.force_filter, cl=cl)
def ListNodeFields(opts, args):
......@@ -269,8 +271,10 @@ def ListNodeFields(opts, args):
@return: the desired exit code
"""
cl = GetClient(query=True)
return GenericListFields(constants.QR_NODE, args, opts.separator,
not opts.no_headers)
not opts.no_headers, cl=cl)
def EvacuateNode(opts, args):
......@@ -310,7 +314,10 @@ def EvacuateNode(opts, args):
cl = GetClient()
result = cl.QueryNodes(names=args, fields=fields, use_locking=False)
qcl = GetClient(query=True)
result = qcl.QueryNodes(names=args, fields=fields, use_locking=False)
qcl.Close()
instances = set(itertools.chain(*itertools.chain(*itertools.chain(result))))
if not instances:
......@@ -366,8 +373,10 @@ def FailoverNode(opts, args):
# these fields are static data anyway, so it doesn't matter, but
# locking=True should be safer
qcl = GetClient(query=True)
result = cl.QueryNodes(names=args, fields=selected_fields,
use_locking=False)
qcl.Close()
node, pinst = result[0]
if not pinst:
......@@ -406,7 +415,9 @@ def MigrateNode(opts, args):
force = opts.force
selected_fields = ["name", "pinst_list"]
qcl = GetClient(query=True)
result = cl.QueryNodes(names=args, fields=selected_fields, use_locking=False)
qcl.Close()
((node, pinst), ) = result
if not pinst:
......@@ -468,7 +479,7 @@ def ShowNodeConfig(opts, args):
@return: the desired exit code
"""
cl = GetClient()
cl = GetClient(query=True)
result = cl.QueryNodes(fields=["name", "pip", "sip",
"pinst_list", "sinst_list",
"master_candidate", "drained", "offline",
......
......@@ -388,7 +388,7 @@ class R_2_nodes(baserlib.OpcodeResource):
"""Returns a list of all nodes.
"""
client = self.GetClient()
client = self.GetClient(query=True)
if self.useBulk():
bulkdata = client.QueryNodes([], N_FIELDS, False)
......@@ -411,7 +411,7 @@ class R_2_nodes_name(baserlib.OpcodeResource):
"""
node_name = self.items[0]
client = self.GetClient()
client = self.GetClient(query=True)
result = baserlib.HandleItemQueryErrors(client.QueryNodes,
names=[node_name], fields=N_FIELDS,
......@@ -449,7 +449,7 @@ class R_2_nodes_name_role(baserlib.OpcodeResource):
"""
node_name = self.items[0]
client = self.GetClient()
client = self.GetClient(query=True)
result = client.QueryNodes(names=[node_name], fields=["role"],
use_locking=self.useLocking())
......@@ -666,7 +666,7 @@ class R_2_groups(baserlib.OpcodeResource):
"""Returns a list of all node groups.
"""
client = self.GetClient()
client = self.GetClient(query=True)
if self.useBulk():
bulkdata = client.QueryGroups([], G_FIELDS, False)
......@@ -689,7 +689,7 @@ class R_2_groups_name(baserlib.OpcodeResource):
"""
group_name = self.items[0]
client = self.GetClient()
client = self.GetClient(query=True)
result = baserlib.HandleItemQueryErrors(client.QueryGroups,
names=[group_name], fields=G_FIELDS,
......
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