From 06bbea187293ac52aefbcf4e98c162bb3286341d Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Mon, 30 Dec 2013 22:48:46 +0100 Subject: [PATCH] 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 (cherry picked from commit ad6b4b4b08b6ef7ae8086f2be3a9ef521adaa88c) --- src/ceph-disk | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/ceph-disk b/src/ceph-disk index 900464163a764..d1c6401eb2c31 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, ), @@ -1377,7 +1376,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, @@ -1387,7 +1386,7 @@ def mkfs( subprocess.check_call( args=[ - '/usr/bin/ceph-osd', + 'ceph-osd', '--cluster', cluster, '--mkfs', '--mkkey', @@ -1413,7 +1412,7 @@ def auth_key( # try dumpling+ cap scheme subprocess.check_call( args=[ - '/usr/bin/ceph', + 'ceph', '--cluster', cluster, '--name', 'client.bootstrap-osd', '--keyring', keyring, @@ -1428,7 +1427,7 @@ def auth_key( # try old cap scheme subprocess.check_call( args=[ - '/usr/bin/ceph', + 'ceph', '--cluster', cluster, '--name', 'client.bootstrap-osd', '--keyring', keyring, @@ -2193,6 +2192,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, @@ -2408,6 +2413,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) -- 2.39.5