feff9ba0451447f9950d8af0a5490a6c54eee61b
[demo.git] / boot / mso_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 export MSO_DOCKER_IMAGE_VERSION=$(cat /opt/config/docker_version.txt)
8
9 # Deployments in OpenStack require a keystone file
10 if [ -e /opt/config/keystone.txt ]
11 then
12         KEYSTONE_URL=$(cat /opt/config/keystone.txt)
13         DCP_CLLI="DEFAULT_KEYSTONE"
14         OPENSTACK_USERNAME="admin"
15         OPENSTACK_APIKEY="encryptedPassword"
16         AUTH_TYPE="USERNAME_PASSWORD"
17 else
18         KEYSTONE_URL="https://identity.api.rackspacecloud.com/v2.0"
19         DCP_CLLI="RAX_KEYSTONE"
20         OPENSTACK_USERNAME=$(cat /opt/config/openstack_username.txt)
21         OPENSTACK_APIKEY=$(cat /opt/config/api_key.txt)
22         AUTH_TYPE="RACKSPACE_APIKEY"
23 fi
24
25 # Update the MSO configuration file.
26 read -d '' MSO_CONFIG_UPDATES <<-EOF
27 {
28 "default_attributes":
29   {
30     "asdc-connections":
31       {
32             "asdc-controller1":
33             {
34                 "environmentName": "$DMAAP_TOPIC"
35             }
36       },
37       "mso-po-adapter-config": 
38           {
39             "identity_services": 
40                 [
41                     {"dcp_clli": "$DCP_CLLI", 
42                      "identity_url": "$KEYSTONE_URL",
43                      "mso_id": "$OPENSTACK_USERNAME", 
44                      "mso_pass": "$OPENSTACK_APIKEY", 
45                      "admin_tenant": "service", 
46                      "member_role": "admin", 
47                      "tenant_metadata": "true",
48                      "identity_server_type": "KEYSTONE", 
49                      "identity_authentication_type": "$AUTH_TYPE"
50                         
51                     }
52                 ]
53           }
54   }
55 }
56 EOF
57 export MSO_CONFIG_UPDATES
58
59
60 # Deploy the environment
61 cd /opt/test_lab
62 git pull
63 chmod +x deploy.sh
64 #This script takes in input 2 nexus repos (the first one for the MSO image, the second one for mariadb)
65 ./deploy.sh $NEXUS_DOCKER_REPO $NEXUS_USERNAME $NEXUS_PASSWD $NEXUS_DOCKER_REPO $NEXUS_USERNAME $NEXUS_PASSWD