library/roles/smartgears/smartgears/templates/get-scopes.j2: Fix the case when we are upgrading but we cannot get the state from the IS. In that case, we request new tokens to the IS.

This commit is contained in:
Andrea Dell'Amico 2017-05-11 17:45:23 +02:00
parent cc10698ecb
commit f4bbb267ab
1 changed files with 13 additions and 4 deletions

View File

@ -65,14 +65,11 @@ HTTP_PORT={{ item.http_port }}
{% endif %}
{% endif %}
if [ $USE_SAVED_STATE -ne 0 ] ; then
logger "$LOG_PREFIX First installation or moving avay to a configuration that needs to be present on all the VREs. Using our scopes list and not the state memorized one"
function get_scopes_from_auth() {
for jar in $( ls -1 /home/gcube/tomcat/lib/ ) ; do
export CLASSPATH="/home/gcube/SmartGears/lib/${jar}:$CLASSPATH"
done
cd $LOCAL_LIB
java TokenGenerator {{ smartgears_hostname }} $TOKEN $HTTP_PORT $SCOPES_FILE $SCOPES_LIST >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
@ -81,6 +78,11 @@ if [ $USE_SAVED_STATE -ne 0 ] ; then
logger "$LOG_PREFIX Unable to obtain the scope tokens, aborting"
exit 1
fi
}
if [ $USE_SAVED_STATE -ne 0 ] ; then
logger "$LOG_PREFIX First installation or moving avay to a configuration that needs to be present on all the VREs. Using our scopes list and not the state memorized one"
get_scopes_from_auth
else
logger "$LOG_PREFIX We are going to use the scopes memorized into the state"
SCOPES_FILE=$SMARTGEARS_SAVED_STATE_PATH
@ -90,6 +92,13 @@ fi
cd $SMARTGEARS_SCRIPTS_DIR
. $GHN_ENV_FILE
./clean-container-state -s $SMARTGEARS_SAVED_STATE_F
RETVAL=$?
if [ $RETVAL -ne 0 ] ; then
# We were not able to get the running state from the IS. We get new ones
logger "$LOG_PREFIX We were not able to get the running state from the IS. We get new ones from the authorization service"
SCOPES_FILE={{ smartgears_user_home }}/.containerxml/2-container.xml
get_scopes_from_auth
fi
# Now that we have the tokens, we can assemble the container.xml file