Refactor ONAP HEAT template config, part 3
[demo.git] / heat / ONAP / cloud-config / so_vm_init.sh
1 #!/bin/bash
2
3 NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt)
4 NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt)
5 NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt)
6 DMAAP_TOPIC=$(cat /opt/config/dmaap_topic.txt)
7 OPENSTACK_USERNAME=$(cat /opt/config/openstack_username.txt)
8 OPENSTACK_APIKEY=$(cat /opt/config/api_key.txt)
9 export MSO_DOCKER_IMAGE_VERSION=$(cat /opt/config/docker_version.txt)
10 export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
11
12 # Deployments in OpenStack require a keystone file
13 if [ -e /opt/config/keystone.txt ]
14 then
15         KEYSTONE_URL=$(cat /opt/config/keystone.txt)
16         OPENSTACK_REGION=$(cat /opt/config/openstack_region.txt)
17         DCP_CLLI="DEFAULT_KEYSTONE"
18         AUTH_TYPE="USERNAME_PASSWORD"
19         read -d '' CLOUD_SITES <<-EOF
20         "cloud_sites": [{
21                  "aic_version": "2.5",
22                  "id": "$OPENSTACK_REGION",
23                  "identity_service_id": "$DCP_CLLI",
24                  "lcp_clli": "$OPENSTACK_REGION",
25                  "region_id": "$OPENSTACK_REGION"
26         }],
27 EOF
28 else
29         KEYSTONE_URL="https://identity.api.rackspacecloud.com/v2.0"
30         DCP_CLLI="RAX_KEYSTONE"
31         AUTH_TYPE="RACKSPACE_APIKEY"
32         read -d '' CLOUD_SITES <<-EOF
33         "cloud_sites": [
34                {
35                  "id": "Dallas",
36                  "aic_version": "2.5",
37                  "lcp_clli": "DFW",
38                  "region_id": "DFW",
39                  "identity_service_id": "$DCP_CLLI"
40                },
41
42                {
43                  "id": "Northern Virginia",
44                  "aic_version": "2.5",
45                  "lcp_clli": "IAD",
46                  "region_id": "IAD",
47                  "identity_service_id": "$DCP_CLLI"
48                },
49
50                {
51                  "id": "Chicago",
52                  "aic_version": "2.5",
53                  "lcp_clli": "ORD",
54                  "region_id": "ORD",
55                  "identity_service_id": "$DCP_CLLI"
56                }
57          ],
58 EOF
59 fi
60
61 # Update the SO configuration file.
62 read -d '' MSO_CONFIG_UPDATES <<-EOF
63 {
64 "default_attributes":
65   {
66     "asdc-connections":
67       {
68             "asdc-controller1":
69             {
70                 "environmentName": "$DMAAP_TOPIC"
71             }
72       },
73       "mso-po-adapter-config": 
74           {
75                 $CLOUD_SITES
76             "identity_services": 
77                 [
78                     {"dcp_clli": "$DCP_CLLI", 
79                     "identity_url": "$KEYSTONE_URL/v2.0",
80                      "mso_id": "$OPENSTACK_USERNAME", 
81                      "mso_pass": "$OPENSTACK_APIKEY", 
82                      "admin_tenant": "service", 
83                      "member_role": "admin", 
84                      "tenant_metadata": "true",
85                      "identity_server_type": "KEYSTONE", 
86                      "identity_authentication_type": "$AUTH_TYPE"
87                         
88                     }
89                 ]
90         },
91         "mso-bpmn-urn-config": {
92                 "msoDefaultCloudOwnerId": "CloudOwner"
93         }
94   }
95 }
96 EOF
97 export MSO_CONFIG_UPDATES
98
99 # Deploy the environment
100 cd /opt/test_lab
101 git pull
102 chmod +x deploy.sh
103 #This script takes in input 2 nexus repos (the first one for the SO image, the second one for mariadb)
104 ./deploy.sh $NEXUS_DOCKER_REPO $NEXUS_USERNAME $NEXUS_PASSWD $NEXUS_DOCKER_REPO $NEXUS_USERNAME $NEXUS_PASSWD