From: Alfredo Deza Date: Thu, 9 Oct 2014 14:20:26 +0000 (-0400) Subject: create a mon keyring if not found when deploying a mon X-Git-Tag: v1.5.18~4^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F248%2Fhead;p=ceph-deploy.git create a mon keyring if not found when deploying a mon Signed-off-by: Alfredo Deza --- diff --git a/ceph_deploy/mon.py b/ceph_deploy/mon.py index 67066f3..548e814 100644 --- a/ceph_deploy/mon.py +++ b/ceph_deploy/mon.py @@ -8,8 +8,9 @@ import time from ceph_deploy import conf, exc, admin from ceph_deploy.cliutil import priority -from ceph_deploy.util import paths, net +from ceph_deploy.util import paths, net, files from ceph_deploy.lib import remoto +from ceph_deploy.new import new_mon_keyring from ceph_deploy import hosts from ceph_deploy.misc import mon_hosts from ceph_deploy.connection import get_connection @@ -243,12 +244,13 @@ def mon_create(args): if args.keyrings: monitor_keyring = concatenate_keyrings(args) else: + keyring_path = '{cluster}.mon.keyring'.format(cluster=args.cluster) try: - with file('{cluster}.mon.keyring'.format(cluster=args.cluster), - 'rb') as f: - monitor_keyring = f.read() + monitor_keyring = files.read_file(keyring_path) except IOError: - raise RuntimeError('mon keyring not found; run \'new\' to create a new cluster') + LOG.warning('keyring (%s) not found, creating a new one' % keyring_path) + new_mon_keyring(args) + monitor_keyring = files.read_file(keyring_path) LOG.debug( 'Deploying mon, cluster %s hosts %s',