Commit 2af8b9c9 authored by Klaus Aehlig's avatar Klaus Aehlig

Remove explicit reference to the query socket

Now that luxid's socket is the default socket anyway, do not
pass the "query=True" parameter to GetClient. This will allow
to get rid of this keyword argument, as masterd will go away.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 39bdcf76
......@@ -531,7 +531,7 @@ def ListTags(opts, args):
"""
kind, name = _ExtractTagsObject(opts, args)
cl = GetClient(query=True)
cl = GetClient()
result = cl.QueryTags(kind, name)
result = list(result)
result.sort()
......@@ -2932,18 +2932,15 @@ def RunWhileClusterStopped(feedback_fn, fn, *args):
# This ensures we're running on the master daemon
cl = GetClient()
# Query client
qcl = GetClient(query=True)
(cluster_name, master_node) = \
cl.QueryConfigValues(["cluster_name", "master_node"])
online_nodes = GetOnlineNodes([], cl=qcl)
ssh_ports = GetNodesSshPorts(online_nodes, qcl)
online_nodes = GetOnlineNodes([], cl=cl)
ssh_ports = GetNodesSshPorts(online_nodes, cl)
# Don't keep a reference to the client. The master daemon will go away.
del cl
del qcl
assert master_node in online_nodes
......@@ -3554,7 +3551,7 @@ def GetOnlineNodes(nodes, cl=None, nowarn=False, secondary_ips=False,
"""
if cl is None:
cl = GetClient(query=True)
cl = GetClient()
qfilter = []
......
......@@ -50,7 +50,7 @@ def PrintExportList(opts, args):
qfilter = qlang.MakeSimpleFilter("node", opts.nodes)
cl = GetClient(query=True)
cl = GetClient()
return GenericList(constants.QR_EXPORT, selected_fields, None, opts.units,
opts.separator, not opts.no_headers,
......@@ -67,7 +67,7 @@ def ListExportFields(opts, args):
@return: the desired exit code
"""
cl = GetClient(query=True)
cl = GetClient()
return GenericListFields(constants.QR_EXPORT, args, opts.separator,
not opts.no_headers, cl=cl)
......
......@@ -412,7 +412,7 @@ def ShowClusterVersion(opts, args):
@return: the desired exit code
"""
cl = GetClient(query=True)
cl = GetClient()
result = cl.QueryClusterInfo()
ToStdout("Software version: %s", result["software_version"])
ToStdout("Internode protocol: %s", result["protocol_version"])
......@@ -468,7 +468,7 @@ def ShowClusterConfig(opts, args):
@return: the desired exit code
"""
cl = GetClient(query=True)
cl = GetClient()
result = cl.QueryClusterInfo()
if result["tags"]:
......@@ -579,7 +579,7 @@ def ClusterCopyFile(opts, args):
errors.ECODE_INVAL)
cl = GetClient()
qcl = GetClient(query=True)
qcl = GetClient()
try:
cluster_name = cl.QueryConfigValues(["cluster_name"])[0]
......@@ -610,7 +610,7 @@ def RunClusterCommand(opts, args):
"""
cl = GetClient()
qcl = GetClient(query=True)
qcl = GetClient()
command = " ".join(args)
......@@ -1566,7 +1566,7 @@ def Epo(opts, args, qcl=None, _on_fn=_EpoOn, _off_fn=_EpoOff,
if qcl is None:
# Query client
qcl = GetClient(query=True)
qcl = GetClient()
if opts.groups:
node_query_list = \
......@@ -1633,7 +1633,7 @@ def ShowCreateCommand(opts, args):
Currently it works only for ipolicy specs.
"""
cl = GetClient(query=True)
cl = GetClient()
result = cl.QueryClusterInfo()
ToStdout(_GetCreateCommand(result))
......
......@@ -122,7 +122,7 @@ def ListGroups(opts, args):
"ndparams": (_FmtDict, False),
}
cl = GetClient(query=True)
cl = GetClient()
return GenericList(constants.QR_GROUP, desired_fields, args, None,
opts.separator, not opts.no_headers,
......@@ -140,7 +140,7 @@ def ListGroupFields(opts, args):
@return: the desired exit code
"""
cl = GetClient(query=True)
cl = GetClient()
return GenericListFields(constants.QR_GROUP, args, opts.separator,
not opts.no_headers, cl=cl)
......@@ -278,7 +278,7 @@ def GroupInfo(_, args):
"""Shows info about node group.
"""
cl = GetClient(query=True)
cl = GetClient()
selected_fields = ["name",
"ndparams", "custom_ndparams",
"diskparams", "custom_diskparams",
......@@ -307,7 +307,7 @@ def ShowCreateCommand(opts, args):
Currently it works only for ipolicy specs.
"""
cl = GetClient(query=True)
cl = GetClient()
selected_fields = ["name"]
if opts.include_defaults:
selected_fields += ["ipolicy"]
......
......@@ -95,7 +95,7 @@ def _ExpandMultiNames(mode, names, client=None):
# pylint: disable=W0142
if client is None:
client = GetClient(query=True)
client = GetClient()
if mode == _EXPAND_CLUSTER:
if names:
raise errors.OpPrereqError("Cluster filter mode takes no arguments",
......@@ -182,8 +182,7 @@ def GenericManyOps(operation, fn):
if opts.multi_mode is None:
opts.multi_mode = _EXPAND_INSTANCES
cl = GetClient()
qcl = GetClient(query=True)
inames = _ExpandMultiNames(opts.multi_mode, args, client=qcl)
inames = _ExpandMultiNames(opts.multi_mode, args, client=cl)
if not inames:
if opts.multi_mode == _EXPAND_CLUSTER:
ToStdout("Cluster is empty, no instances to shutdown")
......@@ -224,7 +223,7 @@ def ListInstances(opts, args):
for item in value),
False))
cl = GetClient(query=True)
cl = GetClient()
return GenericList(constants.QR_INSTANCE, selected_fields, args, opts.units,
opts.separator, not opts.no_headers,
......@@ -422,10 +421,9 @@ def RemoveInstance(opts, args):
instance_name = args[0]
force = opts.force
cl = GetClient()
qcl = GetClient(query=True)
if not force:
_EnsureInstancesExist(qcl, [instance_name])
_EnsureInstancesExist(cl, [instance_name])
usertext = ("This will remove the volumes of the instance %s"
" (including mirrors), thus removing all the data"
......@@ -855,18 +853,15 @@ def ConnectToInstanceConsole(opts, args):
instance_name = args[0]
cl = GetClient()
qcl = GetClient(query=True)
try:
cluster_name = cl.QueryConfigValues(["cluster_name"])[0]
((console_data, oper_state), ) = \
qcl.QueryInstances([instance_name], ["console", "oper_state"], False)
cl.QueryInstances([instance_name], ["console", "oper_state"], False)
finally:
# Ensure client connection is closed while external commands are run
cl.Close()
qcl.Close()
del cl
del qcl
if not console_data:
if oper_state:
......
......@@ -109,7 +109,7 @@ def ListJobs(opts, args):
qfilter = qlang.MakeSimpleFilter("status", opts.status_filter)
cl = GetClient(query=True)
cl = GetClient()
return GenericList(constants.QR_JOB, selected_fields, args, None,
opts.separator, not opts.no_headers,
......@@ -128,7 +128,7 @@ def ListJobFields(opts, args):
@return: the desired exit code
"""
cl = GetClient(query=True)
cl = GetClient()
return GenericListFields(constants.QR_JOB, args, opts.separator,
not opts.no_headers, cl=cl)
......@@ -303,7 +303,7 @@ def ShowJobs(opts, args):
]
qfilter = qlang.MakeSimpleFilter("id", _ParseJobIds(args))
cl = GetClient(query=True)
cl = GetClient()
result = cl.Query(constants.QR_JOB, selected_fields, qfilter).data
first = True
......
......@@ -111,10 +111,9 @@ def ConnectNetwork(opts, args):
"""
cl = GetClient()
qcl = GetClient(query=True)
(network, mode, link) = args[:3]
groups = _GetDefaultGroups(qcl, args[3:])
groups = _GetDefaultGroups(cl, args[3:])
# TODO: Change logic to support "--submit"
for group in groups:
......@@ -137,10 +136,9 @@ def DisconnectNetwork(opts, args):
"""
cl = GetClient()
qcl = GetClient(query=True)
(network, ) = args[:1]
groups = _GetDefaultGroups(qcl, args[1:])
groups = _GetDefaultGroups(cl, args[1:])
# TODO: Change logic to support "--submit"
for group in groups:
......@@ -169,7 +167,7 @@ def ListNetworks(opts, args):
"tags": (",".join, False),
}
cl = GetClient(query=True)
cl = GetClient()
return GenericList(constants.QR_NETWORK, desired_fields, args, None,
opts.separator, not opts.no_headers,
verbose=opts.verbose, format_override=fmtoverride,
......@@ -186,7 +184,7 @@ def ListNetworkFields(opts, args):
@return: the desired exit code
"""
cl = GetClient(query=True)
cl = GetClient()
return GenericListFields(constants.QR_NETWORK, args, opts.separator,
not opts.no_headers, cl=cl)
......@@ -203,7 +201,7 @@ def ShowNetworkConfig(_, args):
@return: the desired exit code
"""
cl = GetClient(query=True)
cl = GetClient()
result = cl.QueryNetworks(fields=["name", "network", "gateway",
"network6", "gateway6",
"mac_prefix",
......
......@@ -233,7 +233,6 @@ def AddNode(opts, args):
"""
cl = GetClient()
query_cl = GetClient(query=True)
node = netutils.GetHostname(name=args[0]).name
readd = opts.readd
......@@ -242,17 +241,17 @@ def AddNode(opts, args):
try:
# Passing [] to QueryGroups means query the default group:
node_groups = [opts.nodegroup] if opts.nodegroup is not None else []
output = query_cl.QueryGroups(names=node_groups, fields=["ndp/ssh_port"],
use_locking=False)
output = cl.QueryGroups(names=node_groups, fields=["ndp/ssh_port"],
use_locking=False)
(ssh_port, ) = output[0]
except (errors.OpPrereqError, errors.OpExecError):
pass
try:
output = query_cl.QueryNodes(names=[node],
fields=["name", "sip", "master",
"ndp/ssh_port"],
use_locking=False)
output = cl.QueryNodes(names=[node],
fields=["name", "sip", "master",
"ndp/ssh_port"],
use_locking=False)
node_exists, sip, is_master, ssh_port = output[0]
except (errors.OpPrereqError, errors.OpExecError):
node_exists = ""
......@@ -320,7 +319,7 @@ def ListNodes(opts, args):
fmtoverride = dict.fromkeys(["pinst_list", "sinst_list", "tags"],
(",".join, False))
cl = GetClient(query=True)
cl = GetClient()
return GenericList(constants.QR_NODE, selected_fields, args, opts.units,
opts.separator, not opts.no_headers,
......@@ -338,7 +337,7 @@ def ListNodeFields(opts, args):
@return: the desired exit code
"""
cl = GetClient(query=True)
cl = GetClient()
return GenericListFields(constants.QR_NODE, args, opts.separator,
not opts.no_headers, cl=cl)
......@@ -381,7 +380,7 @@ def EvacuateNode(opts, args):
cl = GetClient()
qcl = GetClient(query=True)
qcl = GetClient()
result = qcl.QueryNodes(names=args, fields=fields, use_locking=False)
qcl.Close()
......@@ -440,7 +439,7 @@ 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)
qcl = GetClient()
result = qcl.QueryNodes(names=args, fields=selected_fields,
use_locking=False)
qcl.Close()
......@@ -482,7 +481,7 @@ def MigrateNode(opts, args):
force = opts.force
selected_fields = ["name", "pinst_list"]
qcl = GetClient(query=True)
qcl = GetClient()
result = qcl.QueryNodes(names=args, fields=selected_fields, use_locking=False)
qcl.Close()
((node, pinst), ) = result
......@@ -578,7 +577,7 @@ def ShowNodeConfig(opts, args):
@return: the desired exit code
"""
cl = GetClient(query=True)
cl = GetClient()
result = cl.QueryNodes(fields=["name", "pip", "sip",
"pinst_list", "sinst_list",
"master_candidate", "drained", "offline",
......
......@@ -225,7 +225,7 @@ class R_2_info(baserlib.OpcodeResource):
"""Returns cluster information.
"""
client = self.GetClient(query=True)
client = self.GetClient()
return client.QueryClusterInfo()
......@@ -296,7 +296,7 @@ class R_2_jobs(baserlib.ResourceBase):
@return: a dictionary with jobs id and uri.
"""
client = self.GetClient(query=True)
client = self.GetClient()
if self.useBulk():
bulkdata = client.QueryJobs(None, J_FIELDS_BULK)
......@@ -325,7 +325,7 @@ class R_2_jobs_id(baserlib.ResourceBase):
"""
job_id = self.items[0]
result = self.GetClient(query=True).QueryJobs([job_id, ], J_FIELDS)[0]
result = self.GetClient().QueryJobs([job_id, ], J_FIELDS)[0]
if result is None:
raise http.HttpNotFound()
return baserlib.MapFields(J_FIELDS, result)
......@@ -397,7 +397,7 @@ class R_2_nodes(baserlib.OpcodeResource):
"""Returns a list of all nodes.
"""
client = self.GetClient(query=True)
client = self.GetClient()
if self.useBulk():
bulkdata = client.QueryNodes([], N_FIELDS, False)
......@@ -419,7 +419,7 @@ class R_2_nodes_name(baserlib.OpcodeResource):
"""
node_name = self.items[0]
client = self.GetClient(query=True)
client = self.GetClient()
result = baserlib.HandleItemQueryErrors(client.QueryNodes,
names=[node_name], fields=N_FIELDS,
......@@ -457,7 +457,7 @@ class R_2_nodes_name_role(baserlib.OpcodeResource):
"""
node_name = self.items[0]
client = self.GetClient(query=True)
client = self.GetClient()
result = client.QueryNodes(names=[node_name], fields=["role"],
use_locking=self.useLocking())
......@@ -673,7 +673,7 @@ class R_2_networks(baserlib.OpcodeResource):
"""Returns a list of all networks.
"""
client = self.GetClient(query=True)
client = self.GetClient()
if self.useBulk():
bulkdata = client.QueryNetworks([], NET_FIELDS, False)
......@@ -696,7 +696,7 @@ class R_2_networks_name(baserlib.OpcodeResource):
"""
network_name = self.items[0]
client = self.GetClient(query=True)
client = self.GetClient()
result = baserlib.HandleItemQueryErrors(client.QueryNetworks,
names=[network_name],
......@@ -789,7 +789,7 @@ class R_2_groups(baserlib.OpcodeResource):
"""Returns a list of all node groups.
"""
client = self.GetClient(query=True)
client = self.GetClient()
if self.useBulk():
bulkdata = client.QueryGroups([], G_FIELDS, False)
......@@ -812,7 +812,7 @@ class R_2_groups_name(baserlib.OpcodeResource):
"""
group_name = self.items[0]
client = self.GetClient(query=True)
client = self.GetClient()
result = baserlib.HandleItemQueryErrors(client.QueryGroups,
names=[group_name], fields=G_FIELDS,
......@@ -917,7 +917,7 @@ class R_2_instances(baserlib.OpcodeResource):
"""Returns a list of all available instances.
"""
client = self.GetClient(query=True)
client = self.GetClient()
use_locking = self.useLocking()
if self.useBulk():
......@@ -998,7 +998,7 @@ class R_2_instances_name(baserlib.OpcodeResource):
"""Send information about an instance.
"""
client = self.GetClient(query=True)
client = self.GetClient()
instance_name = self.items[0]
result = baserlib.HandleItemQueryErrors(client.QueryInstances,
......@@ -1384,7 +1384,7 @@ class R_2_instances_name_console(baserlib.ResourceBase):
"""
instance_name = self.items[0]
client = self.GetClient(query=True)
client = self.GetClient()
((console, oper_state), ) = \
client.QueryInstances([instance_name], ["console", "oper_state"], False)
......@@ -1529,7 +1529,7 @@ class _R_Tags(baserlib.OpcodeResource):
if not self.name:
raise http.HttpBadRequest("Missing name on tag request")
cl = self.GetClient(query=True)
cl = self.GetClient()
tags = list(cl.QueryTags(kind, self.name))
elif kind == constants.TAG_CLUSTER:
......
......@@ -363,7 +363,7 @@ class ClientOps:
elif what == constants.QR_JOB:
return queue.QueryJobs(fields, qfilter)
elif what in constants.QR_VIA_LUXI:
luxi_client = runtime.GetClient(query=True)
luxi_client = runtime.GetClient()
result = luxi_client.Query(what, fields, qfilter).ToDict()
else:
raise errors.OpPrereqError("Resource type '%s' unknown" % what,
......
......@@ -549,7 +549,7 @@ class Burner(object):
else:
names = []
try:
qcl = GetClient(query=True)
qcl = GetClient()
result = qcl.QueryNodes(names, ["name", "offline", "drained"], False)
except errors.GenericError, err:
err_code, msg = cli.FormatError(err)
......@@ -753,7 +753,7 @@ class Burner(object):
islice(cycle(self.nodes), 2, None),
self.instances)
qcl = GetClient(query=True)
qcl = GetClient()
for pnode, snode, enode, instance in mytor:
Log("instance %s", instance, indent=1)
# read the full name of the instance
......
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