From 34fc0aefd9e25a8463adee4b1038badc83f9cd1f Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 9 Oct 2014 10:20:26 -0400 Subject: [PATCH] create a mon keyring if not found when deploying a mon Signed-off-by: Alfredo Deza --- ceph_deploy/mon.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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', -- 2.47.3