Skip to contentSkip to conversation

Write correct 'mon_host' with IPv6 addresses

PATCH New Wido den Hollander 1 participant 1 message May 8, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Write correct 'mon_host' with IPv6 addresses

When the IP-address from a monitor is a IPv6 address, encapsulate it with [ and ]

Fixes #8309
---
 ceph_deploy/new.py |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
ceph_deploy/new.py +7 -1
index 3680821..fc4c5f4 100644
@@ -5,6 +5,7 @@ import uuid
 import struct
 import time
 import base64
+import socket
 
 from ceph_deploy.cliutil import priority
 from ceph_deploy import conf, hosts, exc
@@ -90,7 +91,12 @@ def new(args):
         ip = net.get_nonlocal_ip(host)
         LOG.debug('Monitor %s at %s', name, ip)
         mon_initial_members.append(name)
-        mon_host.append(ip)
+        try:
+            socket.inet_pton(socket.AF_INET6, ip)
+            mon_host.append("[" + ip + "]")
+        except socket.error:
+            mon_host.append(ip)
+
         if args.ssh_copykey:
             ssh_copy_keys(host, args.username)
 
Signature · 1 line
1.7.9.5