From: Sage Weil Date: Sat, 28 Feb 2009 00:17:40 +0000 (-0800) Subject: ceph-daemons: generate list of items to stop/start in ceph_common.sh X-Git-Tag: v0.7~103 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d73e0211420d859d34f824468e49f248dd73ea78;p=ceph.git ceph-daemons: generate list of items to stop/start in ceph_common.sh nothing -> everything mon -> all monitors (mon*) mds0 -> just mds0 --- diff --git a/src/ceph-daemons b/src/ceph-daemons index c2d0fdd72c18..93a288838672 100755 --- a/src/ceph-daemons +++ b/src/ceph-daemons @@ -13,14 +13,6 @@ else ETCDIR=/etc/ceph fi -CCONF="$BINDIR/cconf" -conf=$ETCDIR"/startup.conf" -cluster_conf=$ETCDIR"/cluster.conf" -ARGS="-f" - -# get hostname, minus any domain -hostname=`hostname | cut -d . -f 1` - . $LIBDIR/ceph_common.sh usage_exit() { @@ -100,14 +92,8 @@ done command=$1 shift -what="$@" -if [[ $what = "" ]]; 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$'` -fi +get_name_list "$@" for name in $what; do type=`echo $name | cut -c 1-3` # e.g. 'mon', if $item is 'mon1' @@ -119,7 +105,7 @@ for name in $what; do ssh="" cmd="" if [[ $host != "" ]]; then - #echo host for $name is $host, i am $hostname + echo host for $name is $host, i am $hostname if [[ $host != $hostname ]]; then # skip, unless we're starting remote daemons too if [[ $allhosts -eq 0 ]]; then @@ -164,7 +150,7 @@ for name in $what; do [[ $crun -eq 1 ]] && wrap="$BINDIR/crun" get_conf_bool valgrind "$dovalgrind" "valgrind" $sections - [[ $valgrind -eq 1]] && wrap="$wrap valgrind" + [[ $valgrind -eq 1 ]] && wrap="$wrap valgrind" [[ $wrap != "" ]] && runmode="-f &" diff --git a/src/ceph_common.sh b/src/ceph_common.sh index 473fc781b528..0639d5249d3d 100644 --- a/src/ceph_common.sh +++ b/src/ceph_common.sh @@ -1,4 +1,38 @@ +CCONF="$BINDIR/cconf" + +conf=$ETCDIR"/startup.conf" +cluster_conf=$ETCDIR"/cluster.conf" + +hostname=`hostname | cut -d . -f 1` + + +get_name_list() { + orig=$1 + + if [[ $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$'` + return + fi + + what="" + for f in "$orig"; do + case $f in + mon | osd | mds) + bit=`$CCONF -c $conf -l $f | egrep -v "^$f$"` + what="$what $bit" + ;; + *) + what="$what $f" + ;; + esac + done +} + + get_val() { [ "$2" != "" ] && export $1=$2 || export $1=`$CCONF -c $conf "$3" "$4" "$5"` } diff --git a/src/mkcephfs b/src/mkcephfs index 9018fe5f1001..47787a40c11c 100755 --- a/src/mkcephfs +++ b/src/mkcephfs @@ -12,9 +12,6 @@ else ETCDIR=/etc/ceph fi -CCONF="$BINDIR/cconf" -conf=$ETCDIR"/cluster.conf" - . $LIBDIR/ceph_common.sh usage_exit() { @@ -55,18 +52,7 @@ esac shift done -what=$* - -if [[ $what = "" ]]; 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$'` -fi - -# get hostname, minus any domain -hostname=`hostname | cut -d . -f 1` - +get_name_list "$@" # create the monmap if we're doing mon0 if [[ $what =~ "mon0" ]]; then