]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: add --prepend-to-path to control execution
authorLoic Dachary <loic@dachary.org>
Mon, 30 Dec 2013 21:48:46 +0000 (22:48 +0100)
committerAlfredo Deza <alfredo@deza.pe>
Wed, 12 Feb 2014 21:17:11 +0000 (16:17 -0500)
/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 <loic@dachary.org>
(cherry picked from commit ad6b4b4b08b6ef7ae8086f2be3a9ef521adaa88c)

src/ceph-disk

index 900464163a76400cfbdaa984cc214970fa773f31..d1c6401eb2c31deeceda67bcd359725b59613345 100755 (executable)
@@ -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)