Fix scp command when target is an IPv6 address
authorManuel Franceschini <livewire@google.com>
Wed, 25 Aug 2010 12:50:53 +0000 (14:50 +0200)
committerManuel Franceschini <livewire@google.com>
Wed, 25 Aug 2010 13:18:54 +0000 (15:18 +0200)
Due to the syntax used for the target in scp <target>:<path>, it is
necessary when the target is an IPv6 address to enclose it in square
brackets.

Signed-off-by: Manuel Franceschini <livewire@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/ssh.py

index fdecab4..eb0be65 100644 (file)
@@ -31,6 +31,7 @@ import re
 from ganeti import utils
 from ganeti import errors
 from ganeti import constants
+from ganeti import netutils
 
 
 def FormatParamikoFingerprint(fingerprint):
@@ -220,6 +221,9 @@ class SshRunner:
     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)