+## Access to RAPP Catalogue
+# Host name may be changed if app started by kube
+# Direct access from script
+RC_HTTPX="http"
+RC_HOST_NAME=$LOCALHOST_NAME
+RC_PATH=$RC_HTTPX"://"$RC_HOST_NAME":"$RAPP_CAT_EXTERNAL_PORT
+# RC_ADAPTER used for switch between REST and DMAAP (only REST supported currently)
+RC_ADAPTER_TYPE="REST"
+RC_ADAPTER=$RC_PATH
+
+
+###########################
+### RAPP Catalogue
+###########################
+
+# Set http as the protocol to use for all communication to the RAPP Catalogue
+# args: -
+# (Function for test scripts)
+use_rapp_catalogue_http() {
+ echo -e $BOLD"RAPP Catalogue protocol setting"$EBOLD
+ echo -e " Using $BOLD http $EBOLD towards the RAPP Catalogue"
+ RC_HTTPX="http"
+ RC_PATH=$RC_HTTPX"://"$RC_HOST_NAME":"$RAPP_CAT_EXTERNAL_PORT
+ RC_ADAPTER_TYPE="REST"
+ RC_ADAPTER=$RC_PATH
+ echo ""
+}
+
+# Set https as the protocol to use for all communication to the RAPP Catalogue
+# args: -
+# (Function for test scripts)
+use_rapp_catalogue_https() {
+ echo -e $BOLD"RAPP Catalogue protocol setting"$EBOLD
+ echo -e " Using $BOLD https $EBOLD towards the RAPP Catalogue"
+ RC_HTTPX="https"
+ RC_PATH=$RC_HTTPX"://"$RC_HOST_NAME":"$RAPP_CAT_EXTERNAL_SECURE_PORT
+ RC_ADAPTER_TYPE="REST"
+ RC_ADAPTER=$RC_PATH
+ echo ""
+}
+
+# Start the RAPP Catalogue container
+# args: -
+# (Function for test scripts)
+start_rapp_catalogue() {
+
+ echo -e $BOLD"Starting $RAPP_CAT_DISPLAY_NAME"$EBOLD
+
+ if [ $RUNMODE == "KUBE" ]; then
+
+ # Check if app shall be fully managed by the test script
+ __check_included_image "RC"
+ retcode_i=$?
+
+ # Check if app shall only be used by the testscipt
+ __check_prestarted_image "RC"
+ retcode_p=$?
+
+ if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then
+ echo -e $RED"The $RAPP_CAT_APP_NAME app is not included as managed nor prestarted in this test script"$ERED
+ echo -e $RED"The $RAPP_CAT_APP_NAME will not be started"$ERED
+ exit
+ fi
+ if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then
+ echo -e $RED"The $RAPP_CAT_APP_NAME app is included both as managed and prestarted in this test script"$ERED
+ echo -e $RED"The $RAPP_CAT_APP_NAME will not be started"$ERED
+ exit
+ fi
+
+ if [ $retcode_p -eq 0 ]; then
+ echo -e " Using existing $RAPP_CAT_APP_NAME deployment and service"
+ echo " Setting $RAPP_CAT_APP_NAME replicas=1"
+ __kube_scale deployment $RAPP_CAT_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
+ fi
+
+ if [ $retcode_i -eq 0 ]; then
+
+ echo -e " Creating $RAPP_CAT_APP_NAME app and expose service"
+
+ #Check if nonrtric namespace exists, if not create it
+ __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE
+
+ export RAPP_CAT_APP_NAME
+ export KUBE_NONRTRIC_NAMESPACE
+ export RAPP_CAT_IMAGE
+ export RAPP_CAT_INTERNAL_PORT
+ export RAPP_CAT_INTERNAL_SECURE_PORT
+ export RAPP_CAT_EXTERNAL_PORT
+ export RAPP_CAT_EXTERNAL_SECURE_PORT
+
+ #Create service
+ input_yaml=$SIM_GROUP"/"$RAPP_CAT_COMPOSE_DIR"/"svc.yaml
+ output_yaml=$PWD/tmp/rac_svc.yaml
+ __kube_create_instance service $RAPP_CAT_APP_NAME $input_yaml $output_yaml
+
+ #Create app
+ input_yaml=$SIM_GROUP"/"$RAPP_CAT_COMPOSE_DIR"/"app.yaml
+ output_yaml=$PWD/tmp/rac_app.yaml
+ __kube_create_instance app $RAPP_CAT_APP_NAME $input_yaml $output_yaml
+ fi
+
+ echo " Retrieving host and ports for service..."
+ RC_HOST_NAME=$(__kube_get_service_host $RAPP_CAT_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
+
+ RAPP_CAT_EXTERNAL_PORT=$(__kube_get_service_port $RAPP_CAT_APP_NAME $KUBE_NONRTRIC_NAMESPACE "http")
+ RAPP_CAT_EXTERNAL_SECURE_PORT=$(__kube_get_service_port $RAPP_CAT_APP_NAME $KUBE_NONRTRIC_NAMESPACE "https")
+
+ echo " Host IP, http port, https port: $RC_HOST_NAME $RAPP_CAT_EXTERNAL_PORT $RAPP_CAT_EXTERNAL_SECURE_PORT"
+ if [ $RC_HTTPX == "http" ]; then
+ RC_PATH=$RC_HTTPX"://"$RC_HOST_NAME":"$RAPP_CAT_EXTERNAL_PORT
+ else
+ RC_PATH=$RC_HTTPX"://"$RC_HOST_NAME":"$RAPP_CAT_EXTERNAL_SECURE_PORT
+ fi
+
+ __check_service_start $RAPP_CAT_APP_NAME $RC_PATH$RAPP_CAT_ALIVE_URL
+
+ # Update the curl adapter if set to rest, no change if type dmaap
+ if [ $RC_ADAPTER_TYPE == "REST" ]; then
+ RC_ADAPTER=$RC_PATH
+ fi
+ else
+ __check_included_image 'RC'
+ if [ $? -eq 1 ]; then
+ echo -e $RED"The RAPP Catalogue app is not included as managed in this test script"$ERED
+ echo -e $RED"The RAPP Catalogue will not be started"$ERED
+ exit
+ fi
+
+ export RAPP_CAT_APP_NAME
+ export RAPP_CAT_INTERNAL_PORT
+ export RAPP_CAT_EXTERNAL_PORT
+ export RAPP_CAT_INTERNAL_SECURE_PORT
+ export RAPP_CAT_EXTERNAL_SECURE_PORT
+ export DOCKER_SIM_NWNAME
+
+ __start_container $RAPP_CAT_COMPOSE_DIR NODOCKERARGS 1 $RAPP_CAT_APP_NAME
+
+ __check_service_start $RAPP_CAT_APP_NAME $RC_PATH$RAPP_CAT_ALIVE_URL
+ fi
+ echo ""
+}