From 87710b3c687847833855a149477730fff60337f7 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Wed, 4 Sep 2013 11:06:01 -0400 Subject: [PATCH] create a helper to warn against incompatible hostnames Signed-off-by: Alfredo Deza --- ceph_deploy/mon.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ceph_deploy/mon.py b/ceph_deploy/mon.py index e21fde0..4d1f725 100644 --- a/ceph_deploy/mon.py +++ b/ceph_deploy/mon.py @@ -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 -- 2.47.3