Commit 1ff08570 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Use new cluster alias in known_hosts file

Reviewed-by: ultrotter
parent b047857b
......@@ -96,7 +96,7 @@ class LogicalUnit(object):
"""
if not self.__ssh:
self.__ssh = ssh.SshRunner()
self.__ssh = ssh.SshRunner(self.sstore)
return self.__ssh
ssh = property(fget=__GetSSH)
......
......@@ -30,6 +30,7 @@ from ganeti import logger
from ganeti import utils
from ganeti import errors
from ganeti import constants
from ganeti import ssconf
KNOWN_HOSTS_OPTS = [
......@@ -90,6 +91,15 @@ class SshRunner:
"""Wrapper for SSH commands.
"""
def __init__(self, sstore=None):
if sstore is None:
self.sstore = ssconf.SimpleStore()
else:
self.sstore = sstore
def _GetHostKeyAliasOption(self):
return "-oHostKeyAlias=%s" % self.sstore.GetClusterName()
def BuildCmd(self, hostname, user, command, batch=True, ask_key=False,
tty=False):
"""Build an ssh command to execute a command on a remote node.
......@@ -108,6 +118,7 @@ class SshRunner:
"""
argv = ["ssh", "-q"]
argv.extend(KNOWN_HOSTS_OPTS)
argv.append(self._GetHostKeyAliasOption())
if batch:
# if we are in batch mode, we can't ask the key
if ask_key:
......@@ -163,6 +174,7 @@ class SshRunner:
command = ["scp", "-q", "-p"]
command.extend(KNOWN_HOSTS_OPTS)
command.extend(BATCH_MODE_OPTS)
command.append(self._GetHostKeyAliasOption())
command.append(filename)
command.append("%s:%s" % (node, filename))
......
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