]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
vstart.sh: extract create_mgr_restful_secret() out
authorKefu Chai <kchai@redhat.com>
Thu, 3 Jun 2021 10:38:08 +0000 (18:38 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 3 Jun 2021 11:43:10 +0000 (19:43 +0800)
for better readability, and so it's easier to make this step optional if
developer is not interested in using the restful mgr module.

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

index b2831ee080f04961bb52b2b6c50a4bba0c6fad49..cff08910ad518fad3bea29c0be603aea32eb6ffb 100755 (executable)
@@ -970,6 +970,22 @@ EOF
     fi
 }
 
+create_mgr_restful_secret() {
+    while ! ceph_adm -h | grep -c -q ^restful ; do
+        debug echo 'waiting for mgr restful module to start'
+        sleep 1
+    done
+    local secret_file
+    if ceph_adm restful create-self-signed-cert > /dev/null; then
+        secret_file=`mktemp`
+        ceph_adm restful create-key admin -o $secret_file
+        RESTFUL_SECRET=`cat $secret_file`
+        rm $secret_file
+    else
+        debug echo MGR Restful is not working, perhaps the package is not installed?
+    fi
+}
+
 start_mgr() {
     local mgr=0
     local ssl=${DASHBOARD_SSL:-1}
@@ -1040,19 +1056,7 @@ EOF
                 fi
             fi
         fi
-
-        while ! ceph_adm -h | grep -c -q ^restful ; do
-            debug echo 'waiting for mgr restful module to start'
-            sleep 1
-        done
-        if ceph_adm restful create-self-signed-cert; then
-            SF=`mktemp`
-            ceph_adm restful create-key admin -o $SF
-            RESTFUL_SECRET=`cat $SF`
-            rm $SF
-        else
-            debug echo MGR Restful is not working, perhaps the package is not installed?
-        fi
+        create_mgr_restful_secret
     fi
 
     if [ "$cephadm" -eq 1 ]; then