2 #############################################################################
4 # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 #############################################################################
20 # prepare a curl command
21 # parameters: URL METHOD CURLOPTIONS EXTRA_HEADERS_AS_A_STRING AUTH_AS_USER:PASS DATA
22 assemble_curl_command()
26 local CURLOPTIONS="$3"
27 local EXTRA_HEADERS="$4"
31 if [ ! -z "$METHOD" ]; then
32 CMD="curl $CURLOPTIONS $METHOD"
34 CMD="curl $CURLOPTIONS -X GET"
36 if [ ! -z "$EXTRA_HEADERS" ]; then
37 CMD="$CMD $EXTRA_HEADERS"
39 if [ ! -z "$AUTH" ]; then
42 if [ ! -z "$DATA" ]; then
50 # Make a rest API call
51 # parameters: URL METHOD expected_response_code EXTRA_HEADERS_AS_A_STRING AUTH_AS_USER:PASS DATA
52 call_api_for_response_code()
54 local CURLOPTIONS='-kIso /dev/null -w "%{http_code}"'
56 $(assemble_curl_command "$1" "$2" "$CURLOPTIONS" "$4" "$5" "$6")
60 call_api_for_response_body()
62 local CURLOPTIONS='-ksb'
64 $(assemble_curl_command "$1" "$2" "$CURLOPTIONS" "$4" "$5" "$6")
68 call_api_for_response_header()
70 local CURLOPTIONS='-ks -o /dev/null -D -'
72 $(assemble_curl_command "$1" "$2" "$CURLOPTIONS" "$4" "$5" "$6")
76 call_api_for_verbose()
78 local CURLOPTIONS='-kIv'
80 $(assemble_curl_command "$1" "$2" "$CURLOPTIONS" "$4" "$5" "$6")
83 #local TFILE=$(mktemp /tmp/curlcmd.XXXXXXXXX)
90 # Wait till a web service API return specified response code
91 # parameters: URL METHOD EXPECTED_RESP_CODE EXTRA_HEADERS_AS_A_STRING AUTH_AS_USER:PASS DATA
96 ACTUALRESP=$(call_api_for_response_code "$1" "$2" "$3" "$4" "$5" "$6")
97 while [ "$ACTUALRESP" != "$RESP" ]; do
98 echo "RESP CODE $ACTUALRESP, not as expected RESP CODE $RESP @ $(date)."
100 ACTUALRESP=$(call_api_for_response_code "$1" "$2" "$3" "$4" "$5" "$6")
102 echo "RESP CODE $ACTUALRESP, matches with expected RESP CODE $RESP."
105 # Wait till a TCP port is open
106 # parameters: HOST PORT
111 while ! nc -z -w 1 "$DEST" "$PORT"; do
122 # wait till A&AI up and ready
124 AAIHOST=$(cat /opt/config/aai1_ip_addr.txt)
125 local AAIURL="https://$AAIHOST:8443/aai/v11/examples/cloud-regions"
126 local AAIMETHOD='-X GET'
128 local AAIHEADERS='-H "X-FromAppId: AAI-Temp-Tool" -H "X-TransactionId: AAI-Temp-Tool" -H "Real-Time: true" -H "Content-Type: application/json" -H "Accept: application/json"'
129 local AAIAUTH='-u AAI:AAI'
131 echo "===> Waiting for A&AI to get ready for getting $AAIRESP from $AAIURL @ $(date)"
132 wait_for_api "$AAIURL" "$AAIMETHOD" "$AAIRESP" "$AAIHEADERS" "$AAIAUTH" "$AAIDATA"
133 echo "===> A&AI ready @ $(date)"
138 wait_for_multicloud_ready()
140 # wait till MultiCloud up and ready
142 MCHOST=$(cat /opt/config/openo_ip_addr.txt)
143 local MCURL="http://$MCHOST:9005/api/multicloud-titanium_cloud/v0/swagger.json"
144 local MCMETHOD='-X GET'
146 local MCHEADERS='-H "Real-Time: true" -H "Content-Type: application/json" -H "Accept: application/json"'
149 echo "===> Waiting for MultiCloud to get ready for getting $MCRESP from $MCURL @ $(date)"
150 wait_for_api "$MCURL" "$MCMETHOD" "$MCRESP" "$MCHEADERS" "$MCAUTH" "$MCDATA"
151 echo "===> MultiCloud ready @ $(date)"
154 register_multicloud_pod25dns_with_aai()
156 # Register MultiCloud with A&AI
157 local CLOUD_OWNER='pod25dns'
158 local CLOUD_VERSION='titanium_cloud'
161 local CLOUD_IDENTITY_URL
162 local DNSAAS_SERVICE_URL
163 local DNSAAS_USERNAME='demo'
164 local DNSAAS_PASSWORD='onapdemo'
166 CLOUD_REGION="$(cat /opt/config/dnsaas_region.txt)"
167 CLOUD_ENV="$(cat /opt/config/cloud_env.txt)"
168 MCIP="$(cat /opt/config/openo_ip_addr.txt)"
169 CLOUD_IDENTITY_URL="http://${MCIP}/api/multicloud-titanium_cloud/v0/${CLOUD_OWNER}_${CLOUD_REGION}/identity/v2.0"
172 DNSAAS_SERVICE_URL="$(cat /opt/config/dnsaas_keystone_url.txt)"
173 # a tenant of the same name must be set up on the Deisgnate providing OpenStack
174 DNSAAS_TENANT_NAME="$(cat /opt/config/dnsaas_tenant_name.txt)"
175 cat >"/tmp/${CLOUD_OWNER}_${CLOUD_REGION}.json" <<EOL
177 "cloud-owner" : "$CLOUD_OWNER",
178 "cloud-region-id" : "$CLOUD_REGION",
179 "cloud-region-version" : "$CLOUD_VERSION",
180 "cloud-type" : "$CLOUD_ENV",
181 "cloud-zone" : "cloud zone",
182 "complex-name" : "complex name2",
183 "identity-url": "$CLOUD_IDENTITY_URL",
184 "owner-defined-type" : "owner-defined-type",
185 "sriov-automation" : false,
186 "esr-system-info-list" : {
187 "esr-system-info" : [
189 "esr-system-info-id": "532ac032-e996-41f2-84ed-9c7a1766eb30",
190 "cloud-domain": "Default",
191 "default-tenant" : "$DNSAAS_TENANT_NAME",
192 "user-name" : "$DNSAAS_USERNAME",
193 "password" : "$DNSAAS_PASSWORD",
194 "service-url" : "$DNSAAS_SERVICE_URL",
195 "ssl-cacert": "example-ssl-cacert-val-75021",
196 "ssl-insecure": true,
197 "system-name": "example-system-name-val-29071",
198 "system-type": "VIM",
199 "ip-address": "example-ip-address-val-44432",
200 "port": "example-port-val-93235",
201 "type": "example-type-val-85255",
202 "protocal": "example-protocal-val-52954",
203 "vendor": "example-vendor-val-94515",
204 "version": "example-version-val-71880"
214 local REGMETHOD='-X PUT'
215 local REGHEADERS='-H "X-FromAppId: AAI-Temp-Tool" -H "X-TransactionId: AAI-Temp-Tool" -H "Real-Time: true" -H "Content-Type: application/json" -H "Accept: application/json"'
217 local REGAUTH='-u AAI:AAI'
220 REGHOST="$(cat /opt/config/aai1_ip_addr.txt)"
221 REGURL="https://$REGHOST:8443/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/$CLOUD_OWNER/$CLOUD_REGION"
222 REGDATA="-T /tmp/${CLOUD_OWNER}_${CLOUD_REGION}.json"
223 echo "Register MultiCloud with A&AI owner $CLOUD_OWNER"
224 RESP=$(call_api_for_response_code "$REGURL" "$REGMETHOD" "$REGRESP" "$REGHEADERS" "$REGAUTH" "$REGDATA")
225 echo "RESP CODE: $RESP"
229 register_multicloud_pod25_with_aai()
231 # Register MultiCloud with A&AI
232 local CLOUD_OWNER='pod25'
233 local CLOUD_VERSION='titanium_cloud'
235 local DNSAAS_CLOUD_REGION
238 local CLOUD_IDENTITY_URL
244 CLOUD_REGION="$(cat /opt/config/openstack_region.txt)"
245 DNSAAS_CLOUD_REGION="$(cat /opt/config/dnsaas_region.txt)"
246 CLOUD_ENV="$(cat /opt/config/cloud_env.txt)"
247 MCIP="$(cat /opt/config/openo_ip_addr.txt)"
248 CLOUD_IDENTITY_URL="http://${MCIP}/api/multicloud-titanium_cloud/v0/${CLOUD_OWNER}_${CLOUD_REGION}/identity/v2.0"
249 KEYSTONE_URL="$(cat /opt/config/openstack_keystone_url.txt)"
250 if [[ "$KEYSTONE_URL" == */v3 ]]; then
252 elif [[ "$KEYSTONE_URL" == */v2.0 ]]; then
255 KEYSTONE_URL="${KEYSTONE_URL}/v3"
258 USERNAME="$(cat /opt/config/openstack_user.txt)"
259 PASSWORD="$(cat /opt/config/openstack_password.txt)"
260 TENANT_NAME="$(cat /opt/config/tenant_name.txt)"
261 cat >"/tmp/${CLOUD_OWNER}_${CLOUD_REGION}.json" <<EOL
263 "cloud-owner" : "$CLOUD_OWNER",
264 "cloud-region-id" : "$CLOUD_REGION",
265 "cloud-region-version" : "$CLOUD_VERSION",
266 "cloud-type" : "$CLOUD_ENV",
267 "cloud-zone" : "cloud zone",
268 "complex-name" : "complex name",
269 "identity-url": "$CLOUD_IDENTITY_URL",
270 "owner-defined-type" : "owner-defined-type",
271 "sriov-automation" : false,
272 "cloud-extra-info" : "{\"epa-caps\":{\"huge_page\":\"true\",\"cpu_pinning\":\"true\",\"cpu_thread_policy\":\"true\",\"numa_aware\":\"true\",\"sriov\":\"true\",\"dpdk_vswitch\":\"true\",\"rdt\":\"false\",\"numa_locality_pci\":\"true\"},\"dns-delegate\":{\"cloud-owner\":\"pod25dns\",\"cloud-region-id\":\"${DNSAAS_CLOUD_REGION}\"}}",
273 "esr-system-info-list" : {
274 "esr-system-info" : [
276 "esr-system-info-id": "432ac032-e996-41f2-84ed-9c7a1766eb29",
277 "cloud-domain": "Default",
278 "default-tenant" : "$TENANT_NAME",
279 "user-name" : "$USERNAME",
280 "password" : "$PASSWORD",
281 "service-url" : "$KEYSTONE_URL",
282 "ssl-cacert": "example-ssl-cacert-val-75021",
283 "ssl-insecure": true,
284 "system-name": "example-system-name-val-29070",
285 "system-type": "VIM",
286 "ip-address": "example-ip-address-val-44431",
287 "port": "example-port-val-93234",
288 "type": "example-type-val-85254",
289 "protocal": "example-protocal-val-52954",
290 "vendor": "example-vendor-val-94515",
291 "version": "example-version-val-71880"
300 local REGMETHOD='-X PUT'
301 local REGHEADERS='-H "X-FromAppId: AAI-Temp-Tool" -H "X-TransactionId: AAI-Temp-Tool" -H "Real-Time: true" -H "Content-Type: application/json" -H "Accept: application/json"'
303 local REGAUTH='-u AAI:AAI'
306 REGHOST="$(cat /opt/config/aai1_ip_addr.txt)"
307 REGURL="https://$REGHOST:8443/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/$CLOUD_OWNER/$CLOUD_REGION"
308 REGDATA="-T /tmp/${CLOUD_OWNER}_${CLOUD_REGION}.json"
309 echo "Register MultiCloud with A&AI owner $CLOUD_OWNER"
310 RESP=$(call_api_for_response_code "$REGURL" "$REGMETHOD" "$REGRESP" "$REGHEADERS" "$REGAUTH" "$REGDATA")
311 echo "RESP CODE: $RESP"
316 verify_multicloud_registration()
318 local CLOUD_OWNER='pod25'
320 local CLOUD_VERSION='titanium_cloud'
324 local REGMETHOD='-X GET'
325 local REGHEADERS='-H "X-FromAppId: AAI-Temp-Tool" -H "X-TransactionId: AAI-Temp-Tool" -H "Real-Time: true" -H "Content-Type: application/json" -H "Accept: application/json"'
327 local REGAUTH='-u AAI:AAI'
331 CLOUD_REGION="$(cat /opt/config/openstack_region.txt)"
332 CLOUD_ENV="$(cat /opt/config/cloud_env.txt)"
333 REGHOST="$(cat /opt/config/aai1_ip_addr.txt)"
335 REGURL="https://$REGHOST:8443/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/${CLOUD_OWNER}/${CLOUD_REGION}?depth=all"
336 # Verify MultiCloud with A&AI
337 RESPCODE=$(call_api_for_response_code "$REGURL" "$REGMETHOD" "$REGRESP" "$REGHEADERS" "$REGAUTH" "$REGDATA")
338 echo "Register MultiCloud with A&AI owner $CLOUD_OWNER verify response code: $RESPCODE"
340 CLOUD_OWNER='pod25dns'
341 REGURL="https://$REGHOST:8443/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/${CLOUD_OWNER}/${CLOUD_REGION}?depth=all"
342 RESPCODE=$(call_api_for_response_code "$REGURL" "$REGMETHOD" "$REGRESP" "$REGHEADERS" "$REGAUTH" "$REGDATA")
343 echo "Register MultiCloud with A&AI owner $CLOUD_OWNER verify response code: $RESPCODE"
347 register_dns_zone_proxied_designate()
349 local CLOUD_OWNER='pod25'
351 local CLOUD_VERSION='titanium_cloud'
353 local DNSAAS_TENANT_NAME
356 local MCMETHOD='-X POST'
358 local MCHEADERS='-H "Content-Type: application/json" -H "Accept: application/json"'
362 ## export endpoint prefix
363 local MULTICLOUD_PLUGIN_ENDPOINT
365 CLOUD_REGION="$(cat /opt/config/openstack_region.txt)"
366 CLOUD_ENV="$(cat /opt/config/cloud_env.txt)"
367 if [ -z "$1" ]; then DCAE_ZONE="$(cat /opt/config/dcae_zone.txt)"; else DCAE_ZONE="$1"; fi
368 DNSAAS_TENANT_NAME="$(cat /opt/config/dnsaas_tenant_name.txt)"
369 MCHOST=$(cat /opt/config/openo_ip_addr.txt)
370 MCURL="http://$MCHOST:9005/api/multicloud-titanium_cloud/v0/swagger.json"
372 MCDATA='-d "{\"auth\":{\"tenantName\": \"'${DNSAAS_TENANT_NAME}'\"}}"'
373 MULTICLOUD_PLUGIN_ENDPOINT=http://${MCHOST}/api/multicloud-titanium_cloud/v0/${CLOUD_OWNER}_${CLOUD_REGION}
376 # because all VM's use 10.0.100.1 as their first DNS server, the designate DNS server as seocnd, we need to use a
377 # domain outside of the first DNS server's domain
380 DCAE_DOMAIN="$(cat /opt/config/dcae_domain.txt)"
381 ZONENAME="${DCAE_ZONE}.${DCAE_DOMAIN}."
383 echo "===> Register DNS zone $ZONENAME under $DNSAAS_TENANT_NAME"
389 MCURL="${MULTICLOUD_PLUGIN_ENDPOINT}/identity/v3/auth/tokens"
390 echo "=====> Getting token from $MCURL"
391 #TOKEN=$(call_api_for_response_header "$MCURL" "$MCMETHOD" "$MCRESP" "$MCHEADERS" "$MCAUTH" "$MCDATA" | grep 'X-Subject-Token' | sed "s/^.*: //")
392 TOKEN=$(curl -v -s -H "Content-Type: application/json" -X POST -d "{\"auth\":{\"tenantName\": \"${DNSAAS_TENANT_NAME}\"}}" "${MCURL}" 2>&1 | grep X-Subject-Token | sed "s/^.*: //")
393 echo "Received Keystone token $TOKEN from $MCURL"
394 if [ -z "$TOKEN" ]; then
395 echo "Faile to acquire token for creating DNS zone. Exit"
400 PROJECTID=$(curl -v -s -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X GET "${MULTICLOUD_PLUGIN_ENDPOINT}/dns-delegate/v2/zones?name=${ZONENAME}" |grep 'project_id' |sed 's/^.*"project_id":"\([a-zA-Z0-9-]*\)",.*$/\1/')
401 if [ ! -z "$PROJECTID" ]; then
402 ### query the zone with zone id
403 echo "!!!!!!> zone $ZONENAME already registered by project $PROJECTID"
406 echo "=====> No zone of same name $ZONENAME found, creating new zone "
407 curl -sv -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X POST -d "{ \"name\": \"$ZONENAME\", \"email\": \"lji@research.att.com\"}" "${MULTICLOUD_PLUGIN_ENDPOINT}/dns-delegate/v2/zones"
411 echo "=====> Zone listing"
412 curl -sv -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X GET "${MULTICLOUD_PLUGIN_ENDPOINT}/dns-delegate/v2/zones" | python -m json.tool
414 ### query the zone with zone name
415 #echo "=====> Querying zone $ZONENAME"
416 #curl -s -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X GET "${MULTICLOUD_PLUGIN_ENDPOINT}/dns-delegate/v2/zones?name=${ZONENAME}"
420 ZONEID=$(curl -v -sb -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X GET "${MULTICLOUD_PLUGIN_ENDPOINT}/dns-delegate/v2/zones?name=${ZONENAME}" |grep 'id' |sed 's/^.*"id":"\([a-zA-Z0-9-]*\)",.*$/\1/')
421 echo "=====> After creation, zone $ZONENAME ID is $ZONEID"
423 ### query the zone with zone id
424 #echo "=====> Querying zone $ZONENAME by ID $ZONEID"
425 #curl -sv -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X GET "${MULTICLOUD_PLUGIN_ENDPOINT}/dns-delegate/v2/zones/${ZONEID}"
429 register_dns_zone_designate()
431 local HEADER_CONTENT_TYPE_JSON="Content-Type: application/json"
432 local HEADER_ACCEPT_JSON="Accept: application/json"
443 local ZONE_PROJECT_ID
445 if [ -z "$1" ]; then DCAE_ZONE="$(cat /opt/config/dcae_zone.txt)"; else DCAE_ZONE="$1"; fi
446 DCAE_DOMAIN="$(cat /opt/config/dcae_domain.txt)"
447 ZONE_NAME="${DCAE_ZONE}.${DCAE_DOMAIN}."
449 TENANT_NAME="$(cat /opt/config/tenant_name.txt)"
450 TENANT_ID="$(cat /opt/config/tenant_id.txt)"
452 KEYSTONE_URL="$(cat /opt/config/openstack_keystone_url.txt)"
453 if [[ "$KEYSTONE_URL" == */v3 ]]; then
455 elif [[ "$KEYSTONE_URL" == */v2.0 ]]; then
458 KEYSTONE_URL="${KEYSTONE_URL}/v2.0"
462 USERNAME="$(cat /opt/config/openstack_user.txt)"
463 PASSWORD="$(cat /opt/config/openstack_password.txt)"
466 API_ENDPOINT="${KEYSTONE_URL}/tokens"
467 API_DATA="{\"auth\": {\"project\": \"${TENANT_NAME}\", \"tenantId\": \"${TENANT_ID}\", \"passwordCredentials\": {\"username\": \"${USERNAME}\", \"password\": \"${PASSWORD}\"}}}"
469 echo "===> Getting token from ${API_ENDPOINT}"
470 RESP=$(curl -s -v -H "${HEADER_CONTENT_TYPE_JSON}" -d "${API_DATA}" "${API_ENDPOINT}")
472 TOKEN="$(echo ${RESP} | jq -r .access.token.id)"
473 if [ -z "$TOKEN" ]; then
474 echo "Faile to acquire token for creating DNS zone. Exit"
477 HEADER_TOKEN="X-Auth-Token: ${TOKEN}"
480 DESIGNATE_URL=$(echo ${RESP} | jq -r '.access.serviceCatalog[] | select(.name=="designate") | .endpoints[0].publicURL')
481 if [ -z ${DESIGNATE_URL} ]; then
482 echo "Fail to find Designate API endpoint. Exit"
487 API_ENDPOINT="${DESIGNATE_URL}/v2/zones"
488 echo "===> Register DNS zone $ZONE_NAME at Designate API endpoint ${API_ENDPOINT}"
490 RESP=$(curl -v -s -H "$HEADER_TOKEN" "$API_ENDPOINT")
491 ZONE_ID=$(echo $RESP |jq -r --arg ZONE_NAME "$ZONE_NAME" '.zones[] |select(.name==$ZONE_NAME) |.id')
492 if [ -z "$ZONE_ID" ]; then
493 echo "======> Zone ${ZONE_NAME} does not exist. Create"
494 API_DATA="{\"name\": \"${ZONE_NAME}\", \"email\": \"dcae@onap.org\", \"type\": \"PRIMARY\", \"ttl\": 7200, \"description\": \"DCAE DNS zoen created for ONAP deployment $DCAE_ZONE\"}"
495 RESP=$(curl -s -v -X POST -H "$HEADER_ACCEPT_JSON" -H "$HEADER_CONTENT_TYPE_JSON" -H "$HEADER_TOKEN" -d "$API_DATA" "$API_ENDPOINT")
496 ZONE_ID=$(echo $RESP | jq .id)
498 if [ -z "$ZONE_ID" ]; then
499 echo "Fail to create DNS zone ${ZONE_NAME}. Exit"
503 echo "======> Zone ${ZONE_NAME} already exists."
504 API_ENDPOINT="${DESIGNATE_URL}/v2/zones/${ZONE_ID}"
505 RESP=$(curl -s -v -H "$HEADER_ACCEPT_JSON" -H "$HEADER_TOKEN" "$API_ENDPOINT")
506 ZONE_PROJECT_ID=$(echo $RESP | jq -r .project_id)
507 if [ "$ZONE_PROJECT_ID" != "noauth-project" ] && [ "$ZONE_PROJECT_ID" != "$TENANT_ID" ]; then
508 echo "======> Zone ${ZONE_NAME} owned by other projects, may have problem creating records"
510 echo "======> Zone ${ZONE_NAME} okay to create new records"
517 local CLOUD_OWNER='pod25'
519 local CLOUD_VERSION='titanium_cloud'
522 local DNSAAS_TENANT_NAME
525 local MCMETHOD='-X GET'
527 local MCHEADERS='-H "Real-Time: true" -H "Content-Type: application/json" -H "Accept: application/json"'
530 local MULTICLOUD_PLUGIN_ENDPOINT
532 CLOUD_REGION="$(cat /opt/config/openstack_region.txt)"
533 CLOUD_ENV="$(cat /opt/config/cloud_env.txt)"
534 DCAE_ZONE="$(cat /opt/config/dcae_zone.txt)"
535 DNSAAS_TENANT_NAME="$(cat /opt/config/dnsaas_tenant_name.txt)"
536 MCHOST=$(cat /opt/config/openo_ip_addr.txt)
537 MCURL="http://$MCHOST:9005/api/multicloud-titanium_cloud/v0/swagger.json"
541 DCAE_DOMAIN="$(cat /opt/config/dcae_domain.txt)"
542 ZONENAME="${DCAE_ZONE}.${DCAE_DOMAIN}."
544 MCDATA='"{\"auth\":{\"tenantName\": \"'${DNSAAS_TENANT_NAME}'\"}}"'
545 MULTICLOUD_PLUGIN_ENDPOINT=http://${MCHOST}/api/multicloud-titanium_cloud/v0/${CLOUD_OWNER}_${CLOUD_REGION}
549 TOKEN=$(curl -v -s -H "Content-Type: application/json" -X POST -d "{\"auth\":{\"tenantName\": \"${DNSAAS_TENANT_NAME}\"}}" "${MULTICLOUD_PLUGIN_ENDPOINT}/identity/v3/auth/tokens" 2>&1 | grep X-Subject-Token | sed "s/^.*: //")
552 ZONEID=$(curl -v -s -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X GET "${MULTICLOUD_PLUGIN_ENDPOINT}/dns-delegate/v2/zones?name=${ZONENAME}" |sed 's/^.*"id":"\([a-zA-Z0-9-]*\)",.*$/\1/')
554 curl -s -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X DELETE "${MULTICLOUD_PLUGIN_ENDPOINT}/dns-delegate/v2/zones/${ZONEID}"
559 local CLOUD_OWNER='pod25'
561 local CLOUD_VERSION='titanium_cloud'
564 local DNSAAS_TENANT_NAME
567 local MCMETHOD='-X GET'
569 local MCHEADERS='-H "Real-Time: true" -H "Content-Type: application/json" -H "Accept: application/json"'
572 local MULTICLOUD_PLUGIN_ENDPOINT
574 CLOUD_REGION="$(cat /opt/config/openstack_region.txt)"
575 CLOUD_ENV="$(cat /opt/config/cloud_env.txt)"
576 DCAE_ZONE="$(cat /opt/config/dcae_zone.txt)"
577 DNSAAS_TENANT_NAME="$(cat /opt/config/dnsaas_tenant_name.txt)"
578 MCHOST=$(cat /opt/config/openo_ip_addr.txt)
579 MCURL="http://$MCHOST:9005/api/multicloud-titanium_cloud/v0/swagger.json"
581 MCDATA='"{\"auth\":{\"tenantName\": \"'${DNSAAS_TENANT_NAME}'\"}}"'
582 MULTICLOUD_PLUGIN_ENDPOINT=http://${MCHOST}/api/multicloud-titanium_cloud/v0/${CLOUD_OWNER}_${CLOUD_REGION}
586 TOKEN=$(curl -v -s -H "Content-Type: application/json" -X POST -d "{\"auth\":{\"tenantName\": \"${DNSAAS_TENANT_NAME}\"}}" "${MULTICLOUD_PLUGIN_ENDPOINT}/identity/v3/auth/tokens" 2>&1 | grep X-Subject-Token | sed "s/^.*: //")
590 DCAE_DOMAIN="$(cat /opt/config/dcae_domain.txt)"
591 ZONENAME="${DCAE_ZONE}.${DCAE_DOMAIN}."
593 ZONEID=$(curl -v -s -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X GET "${MULTICLOUD_PLUGIN_ENDPOINT}/dns-delegate/v2/zones?name=${ZONENAME}" |sed 's/^.*"id":"\([a-zA-Z0-9-]*\)",.*$/\1/')
595 curl -v -s -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X GET "${MULTICLOUD_PLUGIN_ENDPOINT}/dns-delegate/v2/zones/${ZONEID}/recordsets"
602 NEXUS_USER=$(cat /opt/config/nexus_username.txt)
603 NEXUS_PASSWORD=$(cat /opt/config/nexus_password.txt)
604 NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt)
605 DOCKER_VERSION=$(cat /opt/config/docker_version.txt)
606 # use rand_str as zone
607 ZONE=$(cat /opt/config/rand_str.txt)
608 MYFLOATIP=$(cat /opt/config/dcae_float_ip.txt)
609 MYLOCALIP=$(cat /opt/config/dcae_ip_addr.txt)
611 # start docker image pulling while we are waiting for A&AI to come online
612 docker login -u "$NEXUS_USER" -p "$NEXUS_PASSWORD" "$NEXUS_DOCKER_REPO"
613 docker pull "$NEXUS_DOCKER_REPO/onap/org.onap.dcaegen2.deployments.bootstrap:$DOCKER_VERSION" && docker pull nginx &
615 #########################################
616 # Wait for then register with A&AI
617 ########################################
619 DNSAAS_PROXYED=$(tr '[:upper:]' '[:lower:]' < /opt/config/dnsaas_config_enabled.txt)
620 if [ "$DNSAAS_PROXYED" == 'true' ]; then
621 echo "Using proxyed DNSaaS service, performing additional registration and configuration"
624 register_multicloud_pod25_with_aai
625 register_multicloud_pod25dns_with_aai
627 verify_multicloud_registration
629 wait_for_multicloud_ready
630 register_dns_zone_proxied_designate "$ZONE"
631 echo "Registration and configuration for proxying DNSaaS completed."
633 echo "Using Designate DNSaaS service, performing additional registration and configuration"
634 register_dns_zone_designate "$ZONE"
641 #########################################
642 # Start DCAE Bootstrap container
643 #########################################
645 chmod 777 /opt/app/config
646 rm -f /opt/config/runtime.ip.consul
647 rm -f /opt/config/runtime.ip.cm
650 #docker login -u "$NEXUS_USER" -p "$NEXUS_PASSWORD" "$NEXUS_DOCKER_REPO"
651 #docker pull "$NEXUS_DOCKER_REPO/onap/org.onap.dcaegen2.deployments.bootstrap:$DOCKER_VERSION"
652 docker run -d --name boot -v /opt/app/config:/opt/app/installer/config -e "LOCATION=$ZONE" "$NEXUS_DOCKER_REPO/onap/org.onap.dcaegen2.deployments.bootstrap:$DOCKER_VERSION"
655 # waiting for bootstrap to complete then starting nginx for proxying healthcheck calls
656 echo "Waiting for Consul to become accessible"
657 while [ ! -f /opt/app/config/runtime.ip.consul ]; do echo "."; sleep 30; done
661 # start proxy for consul's health check
662 CONSULIP=$(head -1 /opt/app/config/runtime.ip.consul | sed 's/[[:space:]]//g')
663 echo "Consul is available at $CONSULIP"
665 cat >./nginx.conf <<EOL
668 server_name dcae.simpledemo.onap.org;
669 location /healthcheck {
670 proxy_pass http://${CONSULIP}:8500/v1/health/state/passing;
674 docker run --name dcae-proxy -p 8080:80 -v "$(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf" -d nginx
675 echo "Healthcheck API available at http://${MYFLOATIP}:8080/healthcheck"
676 echo " or http://${MYLOCALIP}:8080/healthcheck"