From: Loic Dachary Date: Mon, 30 Dec 2013 21:48:46 +0000 (+0100) Subject: ceph-disk: add --prepend-to-path to control execution X-Git-Tag: v0.77~54^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ad6b4b4b08b6ef7ae8086f2be3a9ef521adaa88c;p=ceph.git ceph-disk: add --prepend-to-path to control execution /usr/bin is hardcoded in front of some ceph programs which makes it impossible to control where they are located via the PATH. The hardcoded path cannot be removed altogether because it will most likely lead to unexpected and difficult to diagnose problems for existing installations where the PATH finds the program elsewhere. The --prepend-to-path flag is added and defaults to /usr/bin : it prepends to the PATH environment variable. The hardcoded path is removed and the PATH will be used: since /usr/bin is searched first, the legacy behavior will not change. Signed-off-by: Loic Dachary --- diff --git a/src/ceph-disk b/src/ceph-disk index 9c0e0062e8b..fab7572ef55 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -55,7 +55,6 @@ knew the GPT partition type. """ - CEPH_OSD_ONDISK_MAGIC = 'ceph osd volume v026' JOURNAL_UUID = '45b0969e-9b03-4f30-b4c6-b4b80ceff106' @@ -533,7 +532,7 @@ def allocate_osd_id( try: osd_id = _check_output( args=[ - '/usr/bin/ceph', + 'ceph', '--cluster', cluster, '--name', 'client.bootstrap-osd', '--keyring', keyring, @@ -585,7 +584,7 @@ def get_conf(cluster, variable): try: process = subprocess.Popen( args=[ - '/usr/bin/ceph-conf', + 'ceph-conf', '--cluster={cluster}'.format( cluster=cluster, ), @@ -1374,7 +1373,7 @@ def mkfs( monmap = os.path.join(path, 'activate.monmap') subprocess.check_call( args=[ - '/usr/bin/ceph', + 'ceph', '--cluster', cluster, '--name', 'client.bootstrap-osd', '--keyring', keyring, @@ -1384,7 +1383,7 @@ def mkfs( subprocess.check_call( args=[ - '/usr/bin/ceph-osd', + 'ceph-osd', '--cluster', cluster, '--mkfs', '--mkkey', @@ -1410,7 +1409,7 @@ def auth_key( # try dumpling+ cap scheme subprocess.check_call( args=[ - '/usr/bin/ceph', + 'ceph', '--cluster', cluster, '--name', 'client.bootstrap-osd', '--keyring', keyring, @@ -1425,7 +1424,7 @@ def auth_key( # try old cap scheme subprocess.check_call( args=[ - '/usr/bin/ceph', + 'ceph', '--cluster', cluster, '--name', 'client.bootstrap-osd', '--keyring', keyring, @@ -2190,6 +2189,12 @@ def parse_args(): action='store_true', default=None, help='be more verbose', ) + parser.add_argument( + '--prepend-to-path', + metavar='PATH', + default='/usr/bin', + help='prepend PATH to $PATH for backward compatibility (default /usr/bin)', + ) parser.set_defaults( # we want to hold on to this, for later prog=parser.prog, @@ -2405,6 +2410,10 @@ def main(): level=loglevel, ) + if args.prepend_to_path != '': + path = os.environ.get('PATH', '') + os.environ['PATH'] = args.prepend_to_path + ":" + path + try: args.func(args)