]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
vstart: use default CEPH_NUM_* if fails to read them
authorKefu Chai <kchai@redhat.com>
Fri, 25 Mar 2016 05:18:26 +0000 (13:18 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 22 Apr 2016 16:47:17 +0000 (00:47 +0800)
add a section named "client.vstart.sh" for storing the
num_{osd,mon,mds,rgw} settings. and read them using
ceph-conf if the "-k" option is passed in. if we fail to do so, fall
back to the default settings.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/vstart.sh

index c81a793245a299ba8c395ad0c987261ef32ce487..cca89da2d46383e406a9771d7cbc2175a824ff15 100755 (executable)
@@ -99,6 +99,8 @@ cache=""
 memstore=0
 bluestore=0
 
+VSTART_SEC="client.vstart.sh"
+
 MON_ADDR=""
 
 conf_fn="$CEPH_CONF_PATH/ceph.conf"
@@ -262,10 +264,14 @@ shift
 done
 
 if [ "$overwrite_conf" -eq 0 ]; then
-  CEPH_NUM_MON=`awk -F= '/CEPH_NUM_MON/{print $2}' $conf_fn`
-  CEPH_NUM_OSD=`awk -F= '/CEPH_NUM_OSD/{print $2}' $conf_fn`
-  CEPH_NUM_MDS=`awk -F= '/CEPH_NUM_MDS/{print $2}' $conf_fn`
-  CEPH_NUM_RGW=`awk -F= '/CEPH_NUM_RGW/{print $2}' $conf_fn`
+    MON=`$CEPH_BIN/ceph-conf -c $conf_fn --name $VSTART_SEC num_mon 2>/dev/null` && \
+        CEPH_NUM_MON="$MON"
+    OSD=`$CEPH_BIN/ceph-conf -c $conf_fn --name $VSTART_SEC num_osd 2>/dev/null` && \
+        CEPH_NUM_OSD="$OSD"
+    MDS=`$CEPH_BIN/ceph-conf -c $conf_fn --name $VSTART_SEC num_mds 2>/dev/null` && \
+        CEPH_NUM_MDS="$MDS"
+    RGW=`$CEPH_BIN/ceph-conf -c $conf_fn --name $VSTART_SEC num_rgw 2>/dev/null` && \
+        CEPH_NUM_RGW="$RGW"
 fi
 
 if [ "$start_all" -eq 1 ]; then
@@ -429,10 +435,12 @@ if [ "$start_mon" -eq 1 ]; then
                if [ $overwrite_conf -eq 1 ]; then
                        cat <<EOF > $conf_fn
 ; generated by vstart.sh on `date`
-; CEPH_NUM_MON=$CEPH_NUM_MON
-; CEPH_NUM_OSD=$CEPH_NUM_OSD
-; CEPH_NUM_MDS=$CEPH_NUM_MDS
-; CEPH_NUM_RGW=$CEPH_NUM_RGW
+[$VSTART_SEC]
+        num mon = $CEPH_NUM_MON
+        num osd = $CEPH_NUM_OSD
+        num mds = $CEPH_NUM_MDS
+        num rgw = $CEPH_NUM_RGW
+
 [global]
         fsid = $(uuidgen)
         osd pg bits = 3