- echo -e $BOLD"Prepare A1PMS config"$EBOLD
-
- echo " Writing a1pms config for "$A1PMS_APP_NAME" to file: "$2
-
- if [ $# != 2 ] && [ $# != 4 ]; then
- ((RES_CONF_FAIL++))
- __print_err "need two or four args, SDNC|NOSDNC <output-file> [ <sim-group> <adapter-class> ]" $@
- 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 three args, SDNC|NOSDNC <output-file> HEADER|NOHEADER" $@
- 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\","
- config_json=$config_json"\n \"baseUrl\": \"$SDNC_SERVICE_PATH\","
- 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
- if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
- :
- else
- config_json=$config_json"\n \"streams_publishes\": {"
- config_json=$config_json"\n \"dmaap_publisher\": {"
- config_json=$config_json"\n \"type\": \"message-router\","
- config_json=$config_json"\n \"dmaap_info\": {"
- config_json=$config_json"\n \"topic_url\": \"$MR_SERVICE_PATH$MR_WRITE_URL\""
- 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\": \"message-router\","
- config_json=$config_json"\n \"dmaap_info\": {"
- config_json=$config_json"\n \"topic_url\": \"$MR_SERVICE_PATH$MR_READ_URL\""
- config_json=$config_json"\n }"
- config_json=$config_json"\n }"
- config_json=$config_json"\n },"
- fi
-
- config_json=$config_json"\n \"ric\": ["
-
- if [ $RUNMODE == "KUBE" ]; then
- result=$(kubectl $KUBECONF get pods -n $KUBE_A1SIM_NAMESPACE -o jsonpath='{.items[?(@.metadata.labels.autotest=="RICSIM")].metadata.name}')
- rics=""
- ric_cntr=0
- if [ $? -eq 0 ] && [ ! -z "$result" ]; then
- for im in $result; do
- if [[ $im != *"-0" ]]; then
- ric_subdomain=$(kubectl $KUBECONF get pod $im -n $KUBE_A1SIM_NAMESPACE -o jsonpath='{.spec.subdomain}')
- rics=$rics" "$im"."$ric_subdomain"."$KUBE_A1SIM_NAMESPACE
- let ric_cntr=ric_cntr+1
- fi
- done
- fi
- result=$(kubectl $KUBECONF get pods -n $KUBE_A1SIM_NAMESPACE -o jsonpath='{.items[?(@.metadata.labels.autotest=="RICMEDIATORSIM")].metadata.name}')
- oranrics=""
- if [ $? -eq 0 ] && [ ! -z "$result" ]; then
- for im in $result; do
- if [[ $im != *"-0" ]]; then
- ric_subdomain=$(kubectl $KUBECONF get pod $im -n $KUBE_A1SIM_NAMESPACE -o jsonpath='{.spec.subdomain}')
- rics=$rics" "$im"."$ric_subdomain"."$KUBE_A1SIM_NAMESPACE
- oranrics=$oranrics" "$im"."$ric_subdomain"."$KUBE_A1SIM_NAMESPACE
- let ric_cntr=ric_cntr+1
- fi
- done
- fi
- if [ $ric_cntr -eq 0 ]; then
- echo $YELLOW"Warning: No rics found for the configuration"$EYELLOW
- fi
- else
- rics=$(docker ps --filter "name=$RIC_SIM_PREFIX" --filter "network=$DOCKER_SIM_NWNAME" --filter "label=a1sim" --filter "status=running" --format {{.Names}})
- oranrics=$(docker ps --filter "name=$RIC_SIM_PREFIX" --filter "network=$DOCKER_SIM_NWNAME" --filter "label=orana1sim" --filter "status=running" --format {{.Names}})
-
- rics="$rics $oranrics"
-
- if [ $? -ne 0 ] || [ -z "$rics" ]; then
- echo -e $RED" FAIL - the names of the running RIC Simulator or ORAN RIC cannot be retrieved." $ERED
- ((RES_CONF_FAIL++))
- exit 1
- fi
- fi
- cntr=0
- for ric in $rics; do
- if [ $cntr -gt 0 ]; then
- config_json=$config_json"\n ,"
- fi
- config_json=$config_json"\n {"
- if [ $RUNMODE == "KUBE" ]; then
- ric_id=${ric%.*.*} #extract pod id from full hosthame
- ric_id=$(echo "$ric_id" | tr '-' '_')
- else
- ric_id=$(echo "$ric" | tr '-' '_') #ric var still needs underscore as it is different from the container name
- fi
- echo " Found a1 sim: "$ric
- config_json=$config_json"\n \"name\": \"$ric_id\","
-
- xricfound=0
- for xric in $oranrics; do
- if [ $xric == $ric ]; then
- xricfound=1
- fi
- done
- if [ $xricfound -eq 0 ]; then
- config_json=$config_json"\n \"baseUrl\": \"$RIC_SIM_HTTPX://$ric:$RIC_SIM_PORT\","
- else
- config_json=$config_json"\n \"baseUrl\": \"$RICMEDIATOR_SIM_HTTPX://$ric:$RICMEDIATOR_SIM_PORT\","
- fi
- if [ ! -z "$3" ]; then
- if [[ $ric == "$3"* ]]; then
- config_json=$config_json"\n \"customAdapterClass\": \"$4\","
- fi
- fi
- if [ $1 == "SDNC" ]; then
- config_json=$config_json"\n \"controller\": \"$SDNC_APP_NAME\","
- fi
- config_json=$config_json"\n \"managedElementIds\": ["
- config_json=$config_json"\n \"me1_$ric_id\","
- config_json=$config_json"\n \"me2_$ric_id\""
- config_json=$config_json"\n ]"
- config_json=$config_json"\n }"
- let cntr=cntr+1
- done
-
- config_json=$config_json"\n ]"
- config_json=$config_json"\n}"
-
- config_json="{\"config\":"$config_json"}"
-
- printf "$config_json">$2
-
- echo ""
+ echo -e $BOLD"Prepare A1PMS config"$EBOLD
+
+ echo " Writing a1pms config for "$A1PMS_APP_NAME" to file: "$2
+
+ if [ $# != 2 ] && [ $# != 4 ]; then
+ ((RES_CONF_FAIL++))
+ __print_err "need two or four args, SDNC|NOSDNC <output-file> [ <sim-group> <adapter-class> ]" $@
+ 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 three args, SDNC|NOSDNC <output-file> HEADER|NOHEADER" $@
+ 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\","
+ config_json=$config_json"\n \"baseUrl\": \"$SDNC_SERVICE_PATH\","
+ 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
+ if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
+ :
+ else
+ config_json=$config_json"\n \"streams_publishes\": {"
+ config_json=$config_json"\n \"dmaap_publisher\": {"
+ config_json=$config_json"\n \"type\": \"message-router\","
+ config_json=$config_json"\n \"dmaap_info\": {"
+ config_json=$config_json"\n \"topic_url\": \"$MR_SERVICE_PATH$MR_WRITE_URL\""
+ 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\": \"message-router\","
+ config_json=$config_json"\n \"dmaap_info\": {"
+ config_json=$config_json"\n \"topic_url\": \"$MR_SERVICE_PATH$MR_READ_URL\""
+ config_json=$config_json"\n }"
+ config_json=$config_json"\n }"
+ config_json=$config_json"\n },"
+ fi
+
+ config_json=$config_json"\n \"ric\": ["
+
+ if [ $RUNMODE == "KUBE" ]; then
+ result=$(kubectl $KUBECONF get pods -n $KUBE_A1SIM_NAMESPACE -o jsonpath='{.items[?(@.metadata.labels.autotest=="RICSIM")].metadata.name}')
+ rics=""
+ ric_cntr=0
+ if [ $? -eq 0 ] && [ ! -z "$result" ]; then
+ for im in $result; do
+ if [[ $im != *"-0" ]]; then
+ ric_subdomain=$(kubectl $KUBECONF get pod $im -n $KUBE_A1SIM_NAMESPACE -o jsonpath='{.spec.subdomain}')
+ rics=$rics" "$im"."$ric_subdomain"."$KUBE_A1SIM_NAMESPACE
+ let ric_cntr=ric_cntr+1
+ fi
+ done
+ fi
+ result=$(kubectl $KUBECONF get pods -n $KUBE_A1SIM_NAMESPACE -o jsonpath='{.items[?(@.metadata.labels.autotest=="RICMEDIATORSIM")].metadata.name}')
+ oranrics=""
+ if [ $? -eq 0 ] && [ ! -z "$result" ]; then
+ for im in $result; do
+ if [[ $im != *"-0" ]]; then
+ ric_subdomain=$(kubectl $KUBECONF get pod $im -n $KUBE_A1SIM_NAMESPACE -o jsonpath='{.spec.subdomain}')
+ rics=$rics" "$im"."$ric_subdomain"."$KUBE_A1SIM_NAMESPACE
+ oranrics=$oranrics" "$im"."$ric_subdomain"."$KUBE_A1SIM_NAMESPACE
+ let ric_cntr=ric_cntr+1
+ fi
+ done
+ fi
+ if [ $ric_cntr -eq 0 ]; then
+ echo $YELLOW"Warning: No rics found for the configuration"$EYELLOW
+ fi
+ else
+ rics=$(docker ps --filter "name=$RIC_SIM_PREFIX" --filter "network=$DOCKER_SIM_NWNAME" --filter "label=a1sim" --filter "status=running" --format {{.Names}})
+ oranrics=$(docker ps --filter "name=$RIC_SIM_PREFIX" --filter "network=$DOCKER_SIM_NWNAME" --filter "label=orana1sim" --filter "status=running" --format {{.Names}})
+
+ rics="$rics $oranrics"
+
+ if [ $? -ne 0 ] || [ -z "$rics" ]; then
+ echo -e $RED" FAIL - the names of the running RIC Simulator or ORAN RIC cannot be retrieved." $ERED
+ ((RES_CONF_FAIL++))
+ exit 1
+ fi
+ fi
+ cntr=0
+ for ric in $rics; do
+ if [ $cntr -gt 0 ]; then
+ config_json=$config_json"\n ,"
+ fi
+ config_json=$config_json"\n {"
+ if [ $RUNMODE == "KUBE" ]; then
+ ric_id=${ric%.*.*} #extract pod id from full hosthame
+ ric_id=$(echo "$ric_id" | tr '-' '_')
+ else
+ ric_id=$(echo "$ric" | tr '-' '_') #ric var still needs underscore as it is different from the container name
+ fi
+ echo " Found a1 sim: "$ric
+ config_json=$config_json"\n \"name\": \"$ric_id\","
+
+ xricfound=0
+ for xric in $oranrics; do
+ if [ $xric == $ric ]; then
+ xricfound=1
+ fi
+ done
+ if [ $xricfound -eq 0 ]; then
+ config_json=$config_json"\n \"baseUrl\": \"$RIC_SIM_HTTPX://$ric:$RIC_SIM_PORT\","
+ else
+ config_json=$config_json"\n \"baseUrl\": \"$RICMEDIATOR_SIM_HTTPX://$ric:$RICMEDIATOR_SIM_PORT\","
+ fi
+ if [ ! -z "$3" ]; then
+ if [[ $ric == "$3"* ]]; then
+ config_json=$config_json"\n \"customAdapterClass\": \"$4\","
+ fi
+ fi
+ if [ $1 == "SDNC" ]; then
+ config_json=$config_json"\n \"controller\": \"$SDNC_APP_NAME\","
+ fi
+ config_json=$config_json"\n \"managedElementIds\": ["
+ config_json=$config_json"\n \"me1_$ric_id\","
+ config_json=$config_json"\n \"me2_$ric_id\""
+ config_json=$config_json"\n ]"
+ config_json=$config_json"\n }"
+ let cntr=cntr+1
+ done
+
+ config_json=$config_json"\n ]"
+ config_json=$config_json"\n}"
+
+ config_json="{\"config\":"$config_json"}"
+
+ printf "$config_json" >$2
+
+ echo ""