Send both ubuntu versions to Robot VM
[demo.git] / boot / 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 export OPENO_IP=$(cat /opt/config/openo_ip.txt)
12
13 # Deployments in OpenStack require a keystone file
14 if [ -e /opt/config/keystone.txt ]
15 then
16         KEYSTONE_URL=$(cat /opt/config/keystone.txt)
17         OPENSTACK_REGION=$(cat /opt/config/openstack_region.txt)
18         DCP_CLLI="DEFAULT_KEYSTONE"
19         AUTH_TYPE="USERNAME_PASSWORD"
20         read -d '' CLOUD_SITES <<-EOF
21         "cloud_sites": [{
22                  "aic_version": "2.5",
23                  "id": "$OPENSTACK_REGION",
24                  "identity_service_id": "$DCP_CLLI",
25                  "lcp_clli": "$OPENSTACK_REGION",
26                  "region_id": "$OPENSTACK_REGION"
27         }],
28 EOF
29 else
30         KEYSTONE_URL="https://identity.api.rackspacecloud.com/v2.0"
31         DCP_CLLI="RAX_KEYSTONE"
32         AUTH_TYPE="RACKSPACE_APIKEY"
33         read -d '' CLOUD_SITES <<-EOF
34         "cloud_sites": [
35                {
36                  "id": "Dallas",
37                  "aic_version": "2.5",
38                  "lcp_clli": "DFW",
39                  "region_id": "DFW",
40                  "identity_service_id": "$DCP_CLLI"
41                },
42
43                {
44                  "id": "Northern Virginia",
45                  "aic_version": "2.5",
46                  "lcp_clli": "IAD",
47                  "region_id": "IAD",
48                  "identity_service_id": "$DCP_CLLI"
49                },
50
51                {
52                  "id": "Chicago",
53                  "aic_version": "2.5",
54                  "lcp_clli": "ORD",
55                  "region_id": "ORD",
56                  "identity_service_id": "$DCP_CLLI"
57                }
58          ],
59 EOF
60 fi
61
62 # Update the SO configuration file.
63 read -d '' MSO_CONFIG_UPDATES <<-EOF
64 {
65 "default_attributes":
66   {
67     "asdc-connections":
68       {
69             "asdc-controller1":
70             {
71                 "environmentName": "$DMAAP_TOPIC"
72             }
73       },
74       "mso-po-adapter-config": 
75           {
76                 $CLOUD_SITES
77             "identity_services": 
78                 [
79                     {"dcp_clli": "$DCP_CLLI", 
80                     "identity_url": "$KEYSTONE_URL/v2.0",
81                      "mso_id": "$OPENSTACK_USERNAME", 
82                      "mso_pass": "$OPENSTACK_APIKEY", 
83                      "admin_tenant": "service", 
84                      "member_role": "admin", 
85                      "tenant_metadata": "true",
86                      "identity_server_type": "KEYSTONE", 
87                      "identity_authentication_type": "$AUTH_TYPE"
88                         
89                     }
90                 ]
91           }
92   }
93 }
94 EOF
95 export MSO_CONFIG_UPDATES
96
97 # Deploy the environment
98 cd /opt/test_lab
99 git pull
100 chmod +x deploy.sh
101 #This script takes in input 2 nexus repos (the first one for the SO image, the second one for mariadb)
102 ./deploy.sh $NEXUS_DOCKER_REPO $NEXUS_USERNAME $NEXUS_PASSWD $NEXUS_DOCKER_REPO $NEXUS_USERNAME $NEXUS_PASSWD