]> 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)
committerLoic Dachary <loic@dachary.org>
Fri, 3 Jan 2014 15:30:40 +0000 (16:30 +0100)
/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>
src/ceph-disk

index 9c0e0062e8b4ddf443977bd1f701f385dc799698..fab7572ef55b0bff76f66ba857167821fcf944e2 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,
                     ),
@@ -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)