]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
fallback call to ceph for versions < dumpling
authorAlfredo Deza <alfredo@deza.pe>
Thu, 25 Jul 2013 20:31:26 +0000 (16:31 -0400)
committerSage Weil <sage@inktank.com>
Thu, 25 Jul 2013 21:33:47 +0000 (14:33 -0700)
Signed-off-by: Alfredo Deza <alfredo@deza.pe>
ceph_deploy/mds.py

index 0c6e3b912f19192808ac3ad01b7d7e39bd6910e3..ed7f8dc99c12b3a547ea9d9d4b8a316e148d53a0 100644 (file)
@@ -86,21 +86,53 @@ def create_mds(
         )
 
     keypath = os.path.join(path, 'keyring')
+    current_version_args = [
+        'ceph',
+        '--cluster', cluster,
+        '--name', 'client.bootstrap-mds',
+        '--keyring', bootstrap_keyring,
+        'auth', 'get-or-create', 'mds.{name}'.format(name=name),
+        'osd', 'allow rwx',
+        'mds', 'allow',
+        'mon', 'allow profile mds',
+        '-o',
+        os.path.join(keypath),
+    ]
+
+    previous_version_args = [
+        'ceph',
+        '--cluster', cluster,
+        '--name', 'client.bootstrap-mds',
+        '--keyring', bootstrap_keyring,
+        'auth', 'get-or-create', 'mds.{name}'.format(name=name),
+        'osd', 'allow *',
+        'mds', 'allow',
+        'mon', 'allow rwx',
+        '-o',
+        os.path.join(keypath),
+    ]
+
+    def run_command(args):
+        """
+        Attempt to run a command while capturing an error return code.  Raise
+        RuntimeError only if `EACCES` is present in the return code, otherwise
+        raise a regular exception.
+        """
+        try:
+            subprocess.check_call(
+                args=args,
+                stdout=subprocess.PIPE,
+                stderr=subprocess.PIPE,
+                )
+        except subprocess.CalledProcessError as err:
+            if err.errno == errno.EACCES:
+                raise RuntimeError(err.strerror)
+            raise Exception(err.strerror)
 
-    subprocess.check_call(
-        args=[
-            'ceph',
-            '--cluster', cluster,
-            '--name', 'client.bootstrap-mds',
-            '--keyring', bootstrap_keyring,
-            'auth', 'get-or-create', 'mds.{name}'.format(name=name),
-            'osd', 'allow rwx',
-            'mds', 'allow',
-            'mon', 'allow profile mds',
-            '-o',
-            os.path.join(keypath),
-            ],
-        )
+    try:
+        run_command(current_version_args)
+    except RuntimeError:
+        run_command(previous_version_args)
 
     with file(os.path.join(path, 'done'), 'wb') as f:
         pass