aboutsummaryrefslogtreecommitdiffstats
path: root/plans/so/integration-etsi-testing/config/populate-aai-simulator.sh
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2019-08-07 16:03:14 +0000
committerWaqas Ikram <waqas.ikram@est.tech>2019-08-07 16:03:32 +0000
commita5aeeda6be9c0f777f52ea834cf32c87052e3e0c (patch)
treec115a6a53248abafe34adcb1391e4bfa2b0eacf3 /plans/so/integration-etsi-testing/config/populate-aai-simulator.sh
parent76a500eff0629b105fd276194c5dd093e0f60d9d (diff)
Populate AAI Simulator Docker Job
Change-Id: I91f8e5c7b21930974f0a7264c9735c4b0375026a Issue-ID: SO-2182 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'plans/so/integration-etsi-testing/config/populate-aai-simulator.sh')
-rwxr-xr-xplans/so/integration-etsi-testing/config/populate-aai-simulator.sh99
1 files changed, 99 insertions, 0 deletions
diff --git a/plans/so/integration-etsi-testing/config/populate-aai-simulator.sh b/plans/so/integration-etsi-testing/config/populate-aai-simulator.sh
new file mode 100755
index 00000000..1a00f710
--- /dev/null
+++ b/plans/so/integration-etsi-testing/config/populate-aai-simulator.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+#
+# ============LICENSE_START=======================================================
+# Copyright (C) 2019 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#
+
+# @author Gareth Roper (gareth.roper@est.tech)
+# @auther Waqas Ikram (waqas.ikram@est.tech)
+
+SCRIPT_NAME=$(basename $0)
+SCRIPT_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+WAIT_FOR_SCRIPT=$SCRIPT_HOME/wait-for.sh
+
+current_timestamp()
+{
+ date +"%Y-%m-%d %H:%M:%S"
+}
+
+populate_aai_simulator()
+{
+ $WAIT_FOR_SCRIPT -t "$TIMEOUT_IN_SECONDS" -h "$AAI_SIMULATOR_HOST" -p "$AAI_SIMULATOR_PORT"
+
+ if [ $? -eq 0 ]
+ then
+ echo "$SCRIPT_NAME $(current_timestamp): AAI Simulator is Running."
+ else
+ echo "$SCRIPT_NAME $(current_timestamp): AAI Simulator could not be found. Exiting..."
+ exit 1
+ fi
+
+ BASE_URL="https://$AAI_SIMULATOR_HOST:$AAI_SIMULATOR_PORT/aai/v15"
+ BASIC_AUTHORIZATION_HEADER="Authorization: Basic YWFpOmFhaS5vbmFwLm9yZzpkZW1vMTIzNDU2IQ=="
+ APPICATION_JSON="application/json"
+ ACCEPT_HEADER="Accept: $APPICATION_JSON"
+ CONTENT_TYPE_HEADER="Content-Type: $APPICATION_JSON"
+ CURL_COMMAND="curl -k -H $BASIC_AUTHORIZATION_HEADER -H $ACCEPT_HEADER -H $CONTENT_TYPE_HEADER"
+
+ AAI_SIMULATOR_DATA_DIR=$SCRIPT_HOME/aai-simulator-populate-data
+ CUSTOMER_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/customer.json
+ PROJECT_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/project.json
+ OWNING_ENTITY_JSON_FILE=$AAI_SIMULATOR_DATA_DIR/owning-entity.json
+ STATUS_CODE_ACCEPTED="202"
+
+ echo "$SCRIPT_NAME $(current_timestamp): checking health of AAI Simulator"
+ response=$(curl -k $BASE_URL/healthcheck)
+
+ if [[ "$response" -ne "healthy" ]] ; then
+ echo "$SCRIPT_NAME $(current_timestamp) ERROR: AAI Simulator health check failed. Response: $response"
+ exit 1
+ fi
+
+ echo "$SCRIPT_NAME $(current_timestamp): AAI Simulator is healthy"
+
+ echo "$SCRIPT_NAME $(current_timestamp): Populating AAI Simulator"
+
+ echo "$SCRIPT_NAME $(current_timestamp): Adding Cloud-Customer Data"
+ status_code=$(curl -k --write-out %{http_code} --silent --output /dev/null -H "$BASIC_AUTHORIZATION_HEADER" -H "$ACCEPT_HEADER" -H "$CONTENT_TYPE_HEADER" $BASE_URL/business/customers/customer/DemoCustomer -X PUT -d @"$CUSTOMER_JSON_FILE")
+
+ if [[ "$status_code" -ne "$STATUS_CODE_ACCEPTED" ]] ; then
+ echo "$SCRIPT_NAME $(current_timestamp) ERROR: Unable to put customer data in AAI Simulator. Status code received: $status_code"
+ exit 1
+ fi
+
+ echo "$SCRIPT_NAME $(current_timestamp): Adding Project"
+ status_code=$(curl -k --write-out %{http_code} --silent --output /dev/null -H "$BASIC_AUTHORIZATION_HEADER" -H "$ACCEPT_HEADER" -H "$CONTENT_TYPE_HEADER" $BASE_URL/business/projects/project/etsiCsitProject -X PUT -d @"$PROJECT_JSON_FILE")
+
+ if [[ "$status_code" -ne "$STATUS_CODE_ACCEPTED" ]] ; then
+ echo "$SCRIPT_NAME $(current_timestamp) ERROR: Unable to put project data in AAI Simulator. Status code received: $status_code"
+ exit 1
+ fi
+
+ echo "$SCRIPT_NAME $(current_timestamp): Adding Owning-Entity"
+ status_code=$(curl -k --write-out %{http_code} --silent --output /dev/null -H "$BASIC_AUTHORIZATION_HEADER" -H "$ACCEPT_HEADER" -H "$CONTENT_TYPE_HEADER" $BASE_URL/business/owning-entities/owning-entity/oe_1 -X PUT -d @$"$OWNING_ENTITY_JSON_FILE")
+
+ if [[ "$status_code" -ne "$STATUS_CODE_ACCEPTED" ]] ; then
+ echo "$SCRIPT_NAME $(current_timestamp) ERROR: Unable to put owning entity data in AAI Simulator. Status code received: $status_code"
+ exit 1
+ fi
+
+ echo "$SCRIPT_NAME $(current_timestamp): AAI Simulator Populated Successfully"
+}
+
+# main body
+populate_aai_simulator