]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
create a mon keyring if not found when deploying a mon 248/head
authorAlfredo Deza <alfredo.deza@inktank.com>
Thu, 9 Oct 2014 14:20:26 +0000 (10:20 -0400)
committerAlfredo Deza <alfredo.deza@inktank.com>
Thu, 9 Oct 2014 14:20:26 +0000 (10:20 -0400)
Signed-off-by: Alfredo Deza <alfredo.deza@inktank.com>
ceph_deploy/mon.py

index 67066f366ca3663616de66632d1e111252773e79..548e81490b18da5f003446672aa7ec975bbcc458 100644 (file)
@@ -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',