From: Alfredo Deza Date: Thu, 25 Jul 2013 20:31:26 +0000 (-0400) Subject: fallback call to ceph for versions < dumpling X-Git-Tag: v1.2~23 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ceba0e25a374cd317f932d8faefc2ccf99243b8b;p=ceph-deploy.git fallback call to ceph for versions < dumpling Signed-off-by: Alfredo Deza --- diff --git a/ceph_deploy/mds.py b/ceph_deploy/mds.py index 0c6e3b9..ed7f8dc 100644 --- a/ceph_deploy/mds.py +++ b/ceph_deploy/mds.py @@ -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