-# Function to perpare the consul configuration according to the current simulator configuration
-# args: SDNC|NOSDNC <output-file>
-# (Function for test scripts)
-prepare_consul_config() {
- echo -e $BOLD"Prepare Consul config"$EBOLD
-
- echo " Writing consul config for "$POLICY_AGENT_APP_NAME" to file: "$2
-
- if [ $# != 2 ]; then
- ((RES_CONF_FAIL++))
- __print_err "need two args, SDNC|NOSDNC <output-file>" $@
- exit 1
- fi
-
- if [ $1 == "SDNC" ]; then
- echo -e " Config$BOLD including SDNC$EBOLD configuration"
- elif [ $1 == "NOSDNC" ]; then
- echo -e " Config$BOLD excluding SDNC$EBOLD configuration"
- else
- ((RES_CONF_FAIL++))
- __print_err "need two args, SDNC|NOSDNC <output-file>" $@
- exit 1
- fi
-
- config_json="\n {"
- if [ $1 == "SDNC" ]; then
- config_json=$config_json"\n \"controller\": ["
- config_json=$config_json"\n {"
- config_json=$config_json"\n \"name\": \"$SDNC_APP_NAME\","
- if [ $AGENT_STAND_ALONE -eq 0 ]; then
- config_json=$config_json"\n \"baseUrl\": \"$SDNC_HTTPX://$SDNC_APP_NAME:$SDNC_PORT\","
- else
- config_json=$config_json"\n \"baseUrl\": \"$SDNC_HTTPX://localhost:$SDNC_LOCAL_PORT\","
- fi
- config_json=$config_json"\n \"userName\": \"$SDNC_USER\","
- config_json=$config_json"\n \"password\": \"$SDNC_PWD\""
- config_json=$config_json"\n }"
- config_json=$config_json"\n ],"
- fi
-
- config_json=$config_json"\n \"streams_publishes\": {"
- config_json=$config_json"\n \"dmaap_publisher\": {"
- config_json=$config_json"\n \"type\": \"$MR_APP_NAME\","
- config_json=$config_json"\n \"dmaap_info\": {"
- if [ $AGENT_STAND_ALONE -eq 0 ]; then
- config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://$MR_APP_NAME:$MR_PORT$MR_WRITE_URL\""
- else
- config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://localhost:$MR_LOCAL_PORT$MR_WRITE_URL\""
- fi
- config_json=$config_json"\n }"
- config_json=$config_json"\n }"
- config_json=$config_json"\n },"
- config_json=$config_json"\n \"streams_subscribes\": {"
- config_json=$config_json"\n \"dmaap_subscriber\": {"
- config_json=$config_json"\n \"type\": \"$MR_APP_NAME\","
- config_json=$config_json"\n \"dmaap_info\": {"
- if [ $AGENT_STAND_ALONE -eq 0 ]; then
- config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://$MR_APP_NAME:$MR_PORT$MR_READ_URL\""
- else
- config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://localhost:$MR_LOCAL_PORT$MR_READ_URL\""
- fi
- config_json=$config_json"\n }"
- config_json=$config_json"\n }"
- config_json=$config_json"\n },"
-
- config_json=$config_json"\n \"ric\": ["
-
- rics=$(docker ps | grep $RIC_SIM_PREFIX | awk '{print $NF}')
-
- if [ $? -ne 0 ] || [ -z "$rics" ]; then
- echo -e $RED" FAIL - the names of the running RIC Simulator cannot be retrieved." $ERED
- ((RES_CONF_FAIL++))
- return 1
- fi