]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
create a helper to warn against incompatible hostnames 60/head
authorAlfredo Deza <alfredo.deza@inktank.com>
Wed, 4 Sep 2013 15:06:01 +0000 (11:06 -0400)
committerAlfredo Deza <alfredo.deza@inktank.com>
Wed, 4 Sep 2013 15:06:01 +0000 (11:06 -0400)
Signed-off-by: Alfredo Deza <alfredo.deza@inktank.com>
ceph_deploy/mon.py

index e21fde06896d75d33630f05a272ed60fc5c14e39..4d1f725e035132a6f84141db3d71ae0c10828480 100644 (file)
@@ -54,6 +54,8 @@ def mon_create(args):
             distro = hosts.get(hostname)
             LOG.info('distro info: %s %s %s', distro.name, distro.release, distro.codename)
             rlogger = logging.getLogger(hostname)
+            # ensure remote hostname is good to go
+            hostname_is_compatible(distro.sudo_conn, rlogger, hostname)
             rlogger.debug('deploying mon to %s', hostname)
             distro.mon.create(distro, rlogger, args, monitor_keyring)
             distro.sudo_conn.close()
@@ -65,6 +67,23 @@ def mon_create(args):
         raise exc.GenericError('Failed to create %d monitors' % errors)
 
 
+def hostname_is_compatible(conn, logger, provided_hostname):
+    """
+    Make sure that the host that we are connecting to has the same value as the
+    `hostname` in the remote host, otherwise mons can fail not reaching quorum.
+    """
+    logger.debug('determining if provided host has same hostname in remote')
+    remote_hostname = conn.modules.socket.gethostname()
+    if remote_hostname == provided_hostname:
+        return
+    logger.warning('*'*80)
+    logger.warning('provided hostname must match remote hostname')
+    logger.warning('provided hostname: %s' % provided_hostname)
+    logger.warning('remote hostname: %s' % remote_hostname)
+    logger.warning('monitors may not reach quorum and create-keys will not complete')
+    logger.warning('*'*80)
+
+
 def destroy_mon(cluster, paths, is_running):
     import datetime
     import errno