diff --git a/lib/ssh.py b/lib/ssh.py index c9cc1806f5d9713e65ff87d0ee3f3e981d9820af..71d30eda42a9ca5b58d5df2b24e56f849ca671d4 100644 --- a/lib/ssh.py +++ b/lib/ssh.py @@ -71,8 +71,8 @@ class SshRunner: """Wrapper for SSH commands. """ - def __init__(self, cfg): - self.cfg = cfg + def __init__(self, cluster_name): + self.cluster_name = cluster_name def _BuildSshOptions(self, batch, ask_key, use_cluster_key, strict_host_check): @@ -84,7 +84,7 @@ class SshRunner: ] if use_cluster_key: - options.append("-oHostKeyAlias=%s" % self.cfg.GetClusterName()) + options.append("-oHostKeyAlias=%s" % self.cluster_name) # TODO: Too many boolean options, maybe convert them to more descriptive # constants. diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster index 1b397dbbd7d591a4d8177f9e8d83d685a46af6f7..02019c07422ce6e5f0d842f7f765065b61a0e04d 100755 --- a/scripts/gnt-cluster +++ b/scripts/gnt-cluster @@ -160,20 +160,20 @@ def ClusterCopyFile(opts, args): nodes - list containing the name of target nodes; if empty, all nodes """ - # TODO: Query master - cfg = ssconf.SimpleConfigReader() - filename = args[0] if not os.path.exists(filename): raise errors.OpPrereqError("No such filename '%s'" % filename) + cl = GetClient() + myname = utils.HostInfo().name + cluster_name = cl.QueryConfigValues(["cluster_name"])[0] + op = opcodes.OpQueryNodes(output_fields=["name"], names=opts.nodes) - results = [row[0] for row in SubmitOpCode(op) if row[0] != myname] + results = [row[0] for row in SubmitOpCode(op, cl=cl) if row[0] != myname] - # TODO: Potential inconsistency between local node and master - srun = ssh.SshRunner(cfg) + srun = ssh.SshRunner(cluster_name=cluster_name) for node in results: if not srun.CopyFileToNode(node, filename): print >> sys.stderr, ("Copy of file %s to node %s failed" % @@ -192,16 +192,16 @@ def RunClusterCommand(opts, args): nodes: list containing the name of target nodes; if empty, all nodes """ - # TODO: Query master - cfg = ssconf.SimpleConfigReader() + cl = GetClient() command = " ".join(args) op = opcodes.OpQueryNodes(output_fields=["name"], names=opts.nodes) - nodes = [row[0] for row in SubmitOpCode(op)] + nodes = [row[0] for row in SubmitOpCode(op, cl=cl)] + + cluster_name, master_node = cl.QueryConfigValues(["cluster_name", + "master_node"]) - # TODO: Potential inconsistency between local node and master - master_node = cfg.GetMasterNode() - srun = ssh.SshRunner(cfg) + srun = ssh.SshRunner(cluster_name=cluster_name) # Make sure master node is at list end if master_node in nodes: