Update vCPE doc in regard of customer service
[integration.git] / deployment / aks / post-install / bootstrap.sh
1 #!/bin/bash
2 # Copyright 2019 AT&T Intellectual Property. All rights reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #         http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
17
18 set -x 
19
20 if [ ! -d $BUILD_DIR ]; then
21   mkdir -p $BUILD_DIR
22 fi
23
24 # TODO 
25 # Get these from values.yaml
26 export AAI_DNS_NAME=aai.onap
27 export AAI_PORT=8443
28 export AAI_USER=AAI
29 export AAI_PASS=AAI
30 export AAI_PROTOCOL=https
31 export VID_DNS_NAME=vid.onap
32 export VID_PORT=8443
33 export VID_PROTOCOL=https
34 export SDC_DNS_NAME=sdc-fe.onap
35 export SDC_PORT=9443
36 export SDC_PROTOCOL=https
37
38 DATA_FILE=$BUILD_DIR"/get_tenant_id.json"
39
40 cat > $DATA_FILE <<EOF
41 { "auth": {
42     "identity": {
43       "methods": ["password"],
44       "password": {
45         "user": {
46           "name": "$OPENSTACK_USER",
47           "domain": { "id": "default" },
48           "password": "$OPENSTACK_PASS"
49         }
50       }
51     },
52     "scope": {
53       "project": {
54         "name": "$OPENSTACK_TENANT",
55         "domain": { "id": "default" }
56       }
57     }
58   }
59 }
60 EOF
61
62 http_code=""
63 COUNTER=0
64
65 until [ "$http_code" = "201" ] || [ $COUNTER -gt 360 ]; do
66 http_code=`curl -sL -w "%{http_code}" -o /dev/null -H "Content-Type: application/json" -d @"$DATA_FILE" "http://$OPENSTACK_IP/identity/v3/auth/tokens"`
67 echo ""
68 echo "http_code $http_code"
69 COUNTER=$((COUNTER +1))
70 sleep 10
71 done
72
73 TENANT_ID=`curl -s -H "Content-Type: application/json" -d @"$DATA_FILE" "http://$OPENSTACK_IP/identity/v3/auth/tokens" | jq --raw-output '.token.project.id'`
74
75 if [ $? -ne 0 ]; then
76   echo "Failure getting tenant ID from openstack, exiting..."
77   exit 1
78 fi
79
80 export TENANT_ID=$TENANT_ID
81
82 URI="aai/util/echo?action=long"
83 http_code=""
84 COUNTER=0
85
86 until [ "$http_code" = "200" ] || [ $COUNTER -gt 180 ]; do
87 echo "performing aai healthcheck..."
88 http_code=`curl -sL -w "%{http_code}" -o /dev/null -I --insecure -u $AAI_USER:$AAI_PASS -X GET "$AAI_PROTOCOL://$AAI_DNS_NAME:$AAI_PORT/$URI" \
89   -H 'X-TransactionId: 9999' \
90   -H 'X-FromAppId: jimmy-postman' \
91   -H 'Real-Time: true' \
92   -H 'Cache-Control: no-cache'`
93 COUNTER=$((COUNTER +1))
94 sleep 10
95 done
96
97 if [ "$http_code" != "200" ]; then
98   echo "AAI Healthcheck unsuccessful :("
99   echo "Something went wrong during the ONAP installation."
100   exit 1
101 fi
102
103 echo "Creating CLLI $CLLI..."
104 $DIR/create_clli.sh
105
106 echo "Creating Cloud Region $CLOUD_REGION..."
107 $DIR/create_cloud_region.sh
108
109 echo "Creating Cloud Region Relationship..."
110 $DIR/create_cloud_region_relationship.sh
111
112 echo "Creating Cloud Customer $CUSTOMER..."
113 $DIR/create_customer.sh
114
115 echo "Creating Cloud Service Type $SERVICE_TYPE..."
116 $DIR/create_service_type.sh
117
118 echo "Creating Subscription..."
119 $DIR/create_subscription.sh
120
121 echo "Creating Subscription Relationship..."
122 $DIR/create_cloud_region_subscriber_relationship.sh
123
124 echo "Creating Availability Zone $AZ..."
125 $DIR/create_az.sh
126
127
128 URI="vid/healthCheck"
129 http_code=""
130 COUNTER=0
131
132 until [ "$http_code" = "200" ] || [ $COUNTER -gt 180 ]; do
133 echo "performing vid healthcheck..."
134 http_code=`curl -sL -w "%{http_code}" -o /dev/null --insecure -I -X GET "$VID_PROTOCOL://$VID_DNS_NAME:$VID_PORT/$URI"`
135 COUNTER=$((COUNTER +1))
136 sleep 10
137 done
138
139 if [ "$http_code" != "200" ]; then
140   echo "VID Healthcheck unsuccessful :("
141   echo "Something went wrong during the ONAP installation."
142   exit 1
143 fi
144
145 echo "Creating Owning Entity $OE..."
146 $DIR/create_owning_entity.sh
147
148 echo "Creating Platform $PLATFORM..."
149 $DIR/create_platform.sh
150
151 echo "Creating Project $PROJECT..."
152 $DIR/create_project.sh
153
154 echo "Creating LOB $LOB..."
155 $DIR/create_lob.sh
156
157 echo "Creating Cloud Site..."
158 $DIR/create_cloud_site.sh
159
160 URI="sdc1/rest/healthCheck"
161 http_code=""
162 COUNTER=0
163
164 until [ "$http_code" = "200" ] || [ $COUNTER -gt 180 ]; do
165 echo "performing sdc healthcheck..."
166 http_code=`curl -k -sL -w "%{http_code}" -o /dev/null -I -X GET "$SDC_PROTOCOL://$SDC_DNS_NAME:$SDC_PORT/$URI"`
167 COUNTER=$((COUNTER +1))
168 sleep 10
169 done
170
171 if [ "$http_code" != "200" ]; then
172   echo "SDC Healthcheck unsuccessful :("
173   echo "Something went wrong during the ONAP installation."
174   exit 1
175 fi
176