]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
init-ceph: iterate/locate local sysvinit-tagged directories
authorSage Weil <sage@inktank.com>
Sat, 26 Jan 2013 06:53:23 +0000 (22:53 -0800)
committerSage Weil <sage@inktank.com>
Fri, 26 Apr 2013 20:40:00 +0000 (13:40 -0700)
Search /var/lib/ceph/$type/ceph-$id and start/stop those daemons if
present and tagged with the sysvinit file.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit c8f528a4070dd3aa0b25c435c6234032aee39b21)

src/ceph_common.sh
src/init-ceph.in

index 8e90290e853a3fe228cbb010d25744f0a3f950cb..5576018fa4fde86f113bcc580425dbce379dcfd7 100644 (file)
@@ -128,14 +128,49 @@ do_root_cmd() {
     fi
 }
 
+get_local_daemon_list() {
+    type=$1
+    if [ -d "/var/lib/ceph/$type" ]; then
+       for i in `find /var/lib/ceph/$type -mindepth 1 -maxdepth 1 -type d -printf '%f\n'`; do
+           if [ -e "/var/lib/ceph/$type/$i/sysvinit" ]; then
+               id=`echo $i | sed 's/.*-//'`
+               local="$local $type.$id"
+           fi
+       done
+    fi
+}
+
+get_local_name_list() {
+    orig=$1
+    local=""
+
+    if [ -z "$orig" ]; then
+       # enumerate local directories
+       get_local_daemon_list "mon"
+       get_local_daemon_list "osd"
+       get_local_daemon_list "mds"
+       return
+    fi
+
+    for f in $orig; do
+       type=`echo $f | cut -c 1-3`   # e.g. 'mon', if $item is 'mon1'
+       id=`echo $f | cut -c 4- | sed 's/\\.//'`
+       get_local_daemon_list $type
+
+       # FIXME
+    done
+}
+
 get_name_list() {
     orig=$1
 
+    # extract list of monitors, mdss, osds defined in startup.conf
+    allconf=`$CCONF -c $conf -l mon | egrep -v '^mon$' ; \
+       $CCONF -c $conf -l mds | egrep -v '^mds$' ; \
+       $CCONF -c $conf -l osd | egrep -v '^osd$'`
+
     if [ -z "$orig" ]; then
-        # extract list of monitors, mdss, osds defined in startup.conf
-       what=`$CCONF -c $conf -l mon | egrep -v '^mon$' ; \
-           $CCONF -c $conf -l mds | egrep -v '^mds$' ; \
-           $CCONF -c $conf -l osd | egrep -v '^osd$'`
+       what="$allconf $local"
        return
     fi
 
@@ -143,17 +178,16 @@ get_name_list() {
     for f in $orig; do
        type=`echo $f | cut -c 1-3`   # e.g. 'mon', if $item is 'mon1'
        id=`echo $f | cut -c 4- | sed 's/\\.//'`
-       all=`$CCONF -c $conf -l $type | egrep -v "^$type$" || true`
        case $f in
            mon | osd | mds)
-               what="$what $all"
+               what=`echo $allconf $local | grep ^$type || true`
                ;;
            *)
-               if echo " " $all " " | egrep -v -q "( $type$id | $type.$id )"; then
-                   echo "$0: $type.$id not found ($conf defines \"$all\")"
+               if echo " " "$allconf" "$local" " " | egrep -v -q "( $type$id | $type.$id )"; then
+                   echo "$0: $type.$id not found ($conf defines \"$all\", /var/lib/ceph defines \"$local\")"
                    exit 1
                fi
-               what="$what $f"
+               what="$f"
                ;;
        esac
     done
index 0295ec94508a77184beb695131d807978cb9cd5d..a989ef1e95a2cee7480a918063f192f3e7b73af4 100644 (file)
@@ -165,6 +165,7 @@ verify_conf
 command=$1
 [ -n "$*" ] && shift
 
+get_local_name_list "$@"
 get_name_list "$@"
 
 for name in $what; do