From 8062638dfd5bcfc88619b3c41e7fb98ac58ce84b Mon Sep 17 00:00:00 2001
From: Manuel Franceschini <livewire@google.com>
Date: Wed, 25 Aug 2010 14:50:53 +0200
Subject: [PATCH] Fix scp command when target is an IPv6 address

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 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/ssh.py b/lib/ssh.py
index fdecab40a..eb0be65c0 100644
--- a/lib/ssh.py
+++ b/lib/ssh.py
@@ -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)
-- 
GitLab