]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
mds: simplify, fix err.errno problem
authorSage Weil <sage@inktank.com>
Fri, 26 Jul 2013 17:57:11 +0000 (10:57 -0700)
committerSage Weil <sage@inktank.com>
Fri, 26 Jul 2013 17:57:38 +0000 (10:57 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
ceph_deploy/mds.py

index ed7f8dc99c12b3a547ea9d9d4b8a316e148d53a0..e0abaa1a1c5aa8dcd69b11ab32cb807f7fabf479 100644 (file)
@@ -86,53 +86,37 @@ 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)
 
     try:
-        run_command(current_version_args)
-    except RuntimeError:
-        run_command(previous_version_args)
+        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),
+                ])
+    except subprocess.CalledProcessError as err:
+        if err.returncode != errno.EACCES:
+            raise
+        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 *',
+                'mds', 'allow',
+                'mon', 'allow rwx',
+                '-o',
+                os.path.join(keypath),
+                ])
 
     with file(os.path.join(path, 'done'), 'wb') as f:
         pass