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