]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: implement --sysconfdir as /etc/ceph
authorLoic Dachary <loic@dachary.org>
Fri, 3 Jan 2014 15:06:55 +0000 (16:06 +0100)
committerAlfredo Deza <alfredo@deza.pe>
Wed, 12 Feb 2014 21:17:12 +0000 (16:17 -0500)
Replace hardcoded /etc/ceph with the SYSCONFDIR global variable and
implement the --sysconfdir option to override the default value.

Signed-off-by: Loic Dachary <loic@dachary.org>
(cherry picked from commit a71025d33621257b6fd6632516cfed2849ff1637)

src/ceph-disk

index f2ee0ee6e8f968c149ddf0f950e4280018707ffe..496bdf84f7b2f1ff5c181f32234a124b8d8c4f5c 100755 (executable)
@@ -117,6 +117,8 @@ INIT_SYSTEMS = [
 
 STATEDIR = '/var/lib/ceph'
 
+SYSCONFDIR = '/etc/ceph'
+
 # Nuke the TERM variable to avoid confusing any subprocesses we call.
 # For example, libreadline will print weird control sequences for some
 # TERM values.
@@ -1719,9 +1721,9 @@ def find_cluster_by_uuid(_uuid):
     """
     _uuid = _uuid.lower()
     no_fsid = []
-    if not os.path.exists('/etc/ceph'):
+    if not os.path.exists(SYSCONFDIR):
         return None
-    for conf_file in os.listdir('/etc/ceph'):
+    for conf_file in os.listdir(SYSCONFDIR):
         if not conf_file.endswith('.conf'):
             continue
         cluster = conf_file[:-5]
@@ -1736,7 +1738,7 @@ def find_cluster_by_uuid(_uuid):
                 return cluster
     # be tolerant of /etc/ceph/ceph.conf without an fsid defined.
     if len(no_fsid) == 1 and no_fsid[0] == 'ceph':
-        LOG.warning('No fsid defined in /etc/ceph/ceph.conf; using anyway')
+        LOG.warning('No fsid defined in ' + SYSCONFDIR + '/ceph.conf; using anyway')
         return 'ceph'
     return None
 
@@ -1755,7 +1757,7 @@ def activate(
 
     cluster = find_cluster_by_uuid(ceph_fsid)
     if cluster is None:
-        raise Error('No cluster conf found in /etc/ceph with fsid %s' % ceph_fsid)
+        raise Error('No cluster conf found in ' + SYSCONFDIR + ' with fsid %s' % ceph_fsid)
     LOG.debug('Cluster name is %s', cluster)
 
     fsid = read_one_line(path, 'fsid')
@@ -2238,6 +2240,10 @@ def setup_statedir(dir):
     global SUPPRESS_PREFIX
     SUPPRESS_PREFIX = STATEDIR + '/tmp/suppress-activate.'
 
+def setup_sysconfdir(dir):
+    global SYSCONFDIR
+    SYSCONFDIR = dir
+
 def parse_args():
     parser = argparse.ArgumentParser(
         'ceph-disk',
@@ -2259,6 +2265,12 @@ def parse_args():
         default='/var/lib/ceph',
         help='directory in which ceph state is preserved (default /var/lib/ceph)',
         )
+    parser.add_argument(
+        '--sysconfdir',
+        metavar='PATH',
+        default='/etc/ceph',
+        help='directory in which ceph configuration files are found (default /etc/ceph)',
+        )
     parser.set_defaults(
         # we want to hold on to this, for later
         prog=parser.prog,
@@ -2479,6 +2491,8 @@ def main():
         os.environ['PATH'] = args.prepend_to_path + ":" + path
 
     setup_statedir(args.statedir)
+    setup_sysconfdir(args.sysconfdir)
+
     try:
         args.func(args)