Commit 2e7b8369 authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix some issues for lockless queries

This patch converts some more jobs with only queries into cheaper luxi
queries (no job created), and fixes some fallout from the lockless
queries changes.

Reviewed-by: ultrotter
parent a5b9d725
......@@ -944,9 +944,8 @@ def GetOnlineNodes(nodes, cl=None, nowarn=False):
if cl is None:
cl = GetClient()
op = opcodes.OpQueryNodes(output_fields=["name", "offline"],
names=nodes)
result = SubmitOpCode(op, cl=cl)
result = cl.QueryNodes(names=nodes, fields=["name", "offline"],
use_locking=False)
offline = [row[0] for row in result if row[1]]
if offline and not nowarn:
ToStderr("Note: skipping offline node(s): %s" % ", ".join(offline))
......
......@@ -202,8 +202,8 @@ def ShowClusterVersion(opts, args):
@return: the desired exit code
"""
op = opcodes.OpQueryClusterInfo()
result = SubmitOpCode(op)
cl = GetClient()
result = cl.QueryClusterInfo()
ToStdout("Software version: %s", result["software_version"])
ToStdout("Internode protocol: %s", result["protocol_version"])
ToStdout("Configuration format: %s", result["config_version"])
......@@ -236,8 +236,8 @@ def ShowClusterConfig(opts, args):
@return: the desired exit code
"""
op = opcodes.OpQueryClusterInfo()
result = SubmitOpCode(op)
cl = GetClient()
result = cl.QueryClusterInfo()
ToStdout("Cluster name: %s", result["name"])
......
......@@ -182,7 +182,6 @@ def EvacuateNode(opts, args):
selected_fields = ["name", "sinst_list"]
src_node = args[0]
op = opcodes.OpQueryNodes(output_fields=selected_fields, names=[src_node])
result = cl.QueryNodes(names=[src_node], fields=selected_fields,
use_locking=True)
src_node, sinst = result[0]
......@@ -238,8 +237,10 @@ def FailoverNode(opts, args):
force = opts.force
selected_fields = ["name", "pinst_list"]
op = opcodes.OpQueryNodes(output_fields=selected_fields, names=args)
result = SubmitOpCode(op, cl=cl)
# these fields are static data anyway, so it doesn't matter, but
# locking=True should be safer
result = cl.QueryNodes(names=args, fields=selected_fields,
use_locking=True)
node, pinst = result[0]
if not pinst:
......@@ -320,10 +321,10 @@ def ShowNodeConfig(opts, args):
@return: the desired exit code
"""
op = opcodes.OpQueryNodes(output_fields=["name", "pip", "sip",
"pinst_list", "sinst_list"],
names=args)
result = SubmitOpCode(op)
cl = GetClient()
result = cl.QueryNodes(fields=["name", "pip", "sip",
"pinst_list", "sinst_list"],
names=args, use_locking=True)
for name, primary_ip, secondary_ip, pinst, sinst in result:
ToStdout("Node name: %s", name)
......
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