Commit 51144e33 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Fix adding pristine nodes

If a node hasn't been part of the cluster before being added it'll not
have the cluster's SSH key. This patch makes sure to accept those by
not aliasing the machine name to the cluster name.

Reviewed-by: ultrotter
parent f56377a3
......@@ -285,7 +285,8 @@ def SetupNodeDaemon(node):
constants.SSL_CERT_FILE, gntpem,
constants.NODE_INITD_SCRIPT))
result = sshrunner.Run(node, 'root', mycommand, batch=False, ask_key=True)
result = sshrunner.Run(node, 'root', mycommand, batch=False, ask_key=True,
use_cluster_key=False)
if result.failed:
raise errors.OpExecError("Remote command on node %s, error: %s,"
" output: %s" %
......
......@@ -101,7 +101,7 @@ class SshRunner:
return "-oHostKeyAlias=%s" % self.sstore.GetClusterName()
def BuildCmd(self, hostname, user, command, batch=True, ask_key=False,
tty=False):
tty=False, use_cluster_key=True):
"""Build an ssh command to execute a command on a remote node.
Args:
......@@ -111,6 +111,7 @@ class SshRunner:
batch: if true, ssh will run in batch mode with no prompting
ask_key: if true, ssh will run with StrictHostKeyChecking=ask, so that
we can connect to an unknown host (not valid in batch mode)
use_cluster_key: Whether to expect and use the cluster-global SSH key
Returns:
The ssh call to run 'command' on the remote host.
......@@ -118,7 +119,8 @@ class SshRunner:
"""
argv = [constants.SSH, "-q"]
argv.extend(KNOWN_HOSTS_OPTS)
argv.append(self._GetHostKeyAliasOption())
if use_cluster_key:
argv.append(self._GetHostKeyAliasOption())
if batch:
# if we are in batch mode, we can't ask the key
if ask_key:
......@@ -131,7 +133,8 @@ class SshRunner:
argv.extend(["%s@%s" % (user, hostname), command])
return argv
def Run(self, hostname, user, command, batch=True, ask_key=False):
def Run(self, hostname, user, command, batch=True, ask_key=False,
use_cluster_key=True):
"""Runs a command on a remote node.
This method has the same return value as `utils.RunCmd()`, which it
......@@ -150,7 +153,8 @@ class SshRunner:
"""
return utils.RunCmd(self.BuildCmd(hostname, user, command, batch=batch,
ask_key=ask_key))
ask_key=ask_key,
use_cluster_key=use_cluster_key))
def CopyFileToNode(self, node, filename):
"""Copy a file to another node with scp.
......
......@@ -37,6 +37,7 @@ _LIST_DEF_FIELDS = [
"pinst_cnt", "sinst_cnt",
]
def AddNode(opts, args):
"""Add node cli-to-processor bridge.
......
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