From ed181edb6c9cfd6535a94f9366753369bde494c4 Mon Sep 17 00:00:00 2001 From: chenglch Date: Tue, 21 Nov 2017 15:51:23 +0800 Subject: [PATCH] Integrate congo console from goconserver with rcons Enhance the original implement of rcons to support goconserver. `rcons` will help the user choose from one of the console backend service based on the console server status of management node. Implement #4216 --- xCAT-client/bin/rcons | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/xCAT-client/bin/rcons b/xCAT-client/bin/rcons index c5b1b78df..63c9bbe63 100755 --- a/xCAT-client/bin/rcons +++ b/xCAT-client/bin/rcons @@ -62,6 +62,9 @@ done # confluent if this keyword is defined in the site table. This allows for confluent to # be installed on the xCAT management node and switch between conserver & confluent USE_CONFLUENT=0 +# If conluent is not enable, check the service status of goconserver. +# If goconserver is strated, use rcons through goconserver, otherwise through conserver. +USE_GOCONSERVER=0 CONSOLE_SERVICE_KEYWORD=`tabdump site | grep consoleservice | cut -d, -f1 | tr -d '"'` CONSOLE_SERVICE_VALUE=`tabdump site | grep consoleservice | cut -d, -f2 | tr -d '"'` @@ -71,6 +74,20 @@ if [ "$CONSOLE_SERVICE_KEYWORD" == "consoleservice" ]; then fi fi +if [ $USE_CONFLUENT != "1" ] && [ -f "/usr/bin/congo" ] && [ -f "/usr/bin/goconserver" ]; then + GOCONSERVER_RC=`service goconserver status >& /dev/null; echo $?` + if [[ ${GOCONSERVER_RC} == 0 ]]; then + USE_GOCONSERVER=1 + fi + if [[ ${USE_GOCONSERVER} == 1 ]]; then + CONSERVER_RC=`pidof conserver >> /dev/null; echo $?` + if [[ ${CONSERVER_RC} == 0 ]]; then + echo "Error: Both goconserver and conserver are running, please stop one of them, and retry..." + exit 1 + fi + fi +fi + if [ $USE_CONFLUENT == "1" ] && ([ -x "/opt/confluent/bin/confetty" ] || [ -x "/usr/bin/confetty" ] || [ -x "/usr/local/bin/confetty" ]); then # use confluent, make sure conserver is not also running CONSERVER_RC=`pidof conserver >> /dev/null; echo $?` @@ -78,6 +95,11 @@ if [ $USE_CONFLUENT == "1" ] && ([ -x "/opt/confluent/bin/confetty" ] || [ -x "/ echo "Error: consoleservice is set to 'confluent' but conserver is running. Stop conserver, run makeconfluentcfg, and retry..." exit 1 fi + GOCONSERVER_RC=`service goconserver status >& /dev/null; echo $?` + if [[ ${GOCONSERVER_RC} == 0 ]]; then + echo "Error: consoleservice is set to 'confluent' but goconserver is running. Stop goconserver, run makeconfluentcfg, and retry..." + exit 1 + fi CONFETTY="confetty" if [ -x "/opt/confluent/bin/confetty" ]; then CONFETTY="/opt/confluent/bin/confetty" @@ -103,6 +125,38 @@ if [ $USE_CONFLUENT == "1" ] && ([ -x "/opt/confluent/bin/confetty" ] || [ -x "/ CONSERVER="-s $CONSERVER" fi $CONFETTY $CONSCONTROLPATH $CONSERVER $1 +elif [ $USE_GOCONSERVER == "1" ]; then + # use goconserver + # make sure confluent is not also running, only if confluent is installed + if [[ -f "/etc/init.d/confluent" ]]; then + CONFLUENT_RC=`service confluent status >& /dev/null; echo $?` + if [[ ${CONFLUENT_RC} == 0 ]]; then + echo "Error: confluent is running. Stop confluent, run makegocons, and retry..." + exit 1 + fi + fi + if [ -z "$CONSERVER" ]; then + CONSERVER=`nodels $1 nodehm.conserver 2>/dev/null | awk -F: '{print $2}' | tr -d ' '` + fi + + if [ -z "$CONSERVER" ]; then + CONSERVER=$XCATHOST + fi + if [ -z "$CONSERVER" ]; then + CONSERVER=`hostname` + fi + CONGO_ENV="CONGO_SSL_KEY=$HOME/.xcat/client-cred.pem \ + CONGO_SSL_CERT=$HOME/.xcat/client-cred.pem \ + CONGO_SSL_CA_CERT=$HOME/.xcat/ca.pem \ + CONGO_PORT=12430 \ + CONGO_SERVER_HOST=$CONSERVER" + + if [ "$CONSERVER" == `hostname` ]; then + exec env $CONGO_ENV /usr/bin/congo console $1 + else + exec ssh -t $CONSERVER "$CONGO_ENV /usr/bin/congo console $1" + fi + elif [ -f "/usr/bin/console" ] || [ -f "/bin/console" ]; then # use conserver # make sure confluent is not also running, only if confluent is installed