import os
import logging
+import re
from ganeti import utils
from ganeti import errors
from ganeti import constants
+from ganeti import netutils
+
+
+def FormatParamikoFingerprint(fingerprint):
+ """Format paramiko PKey fingerprint.
+
+ @type fingerprint: str
+ @param fingerprint: PKey fingerprint
+ @return: The string hex representation of the fingerprint
+
+ """
+ assert len(fingerprint) % 2 == 0
+ return ":".join(re.findall(r"..", fingerprint.lower()))
def GetUserFiles(user, mkdir=False):
@param quiet: whether to enable -q to ssh
@rtype: list
- @return: the list of options ready to use in L{utils.RunCmd}
+ @return: the list of options ready to use in L{utils.process.RunCmd}
"""
options = [
Args: see SshRunner.BuildCmd.
- @rtype: L{utils.RunResult}
- @return: the result as from L{utils.RunCmd()}
+ @rtype: L{utils.process.RunResult}
+ @return: the result as from L{utils.process.RunCmd()}
"""
return utils.RunCmd(self.BuildCmd(*args, **kwargs))
command = [constants.SCP, "-p"]
command.extend(self._BuildSshOptions(True, False, True, True))
command.append(filename)
+ if netutils.IP6Address.IsValid(node):
+ node = netutils.FormatAddress((node, None))
+
command.append("%s:%s" % (node, filename))
result = utils.RunCmd(command)