Mandeep Khinda | 5291ba3 | 2017-09-20 16:57:09 +0000 | [diff] [blame^] | 1 | #!/bin/bash -x |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 2 | |
| 3 | echo "Validating onap-parameters.yaml has been populated" |
| 4 | [[ -z "$OPENSTACK_UBUNTU_14_IMAGE" ]] && { echo "Error: OPENSTACK_UBUNTU_14_IMAGE must be set in onap-parameters.yaml"; exit 1; } |
| 5 | [[ -z "$OPENSTACK_PUBLIC_NET_ID" ]] && { echo "Error: OPENSTACK_PUBLIC_NET_ID must be set in onap-parameters.yaml"; exit 1; } |
| 6 | [[ -z "$OPENSTACK_OAM_NETWORK_ID" ]] && { echo "Error: OPENSTACK_OAM_NETWORK_ID must be set in onap-parameters.yaml"; exit 1; } |
| 7 | [[ -z "$OPENSTACK_OAM_SUBNET_ID" ]] && { echo "Error: OPENSTACK_OAM_SUBNET_ID must be set in onap-parameters.yaml"; exit 1; } |
| 8 | [[ -z "$OPENSTACK_OAM_NETWORK_CIDR" ]] && { echo "Error: OPENSTACK_OAM_NETWORK_CIDR must be set in onap-parameters.yaml"; exit 1; } |
| 9 | [[ -z "$OPENSTACK_USERNAME" ]] && { echo "Error: OPENSTACK_USERNAME must be set in onap-parameters.yaml"; exit 1; } |
Mandeep Khinda | b53254b | 2017-09-20 16:39:30 +0000 | [diff] [blame] | 10 | [[ -z "$OPENSTACK_TENANT_ID" ]] && { echo "Error: OPENSTACK_TENANT_ID must be set in onap-parameters.yaml"; exit 1; } |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 11 | [[ -z "$OPENSTACK_API_KEY" ]] && { echo "Error: OPENSTACK_API_KEY must be set in onap-parameters.yaml"; exit 1; } |
| 12 | [[ -z "$OPENSTACK_REGION" ]] && { echo "Error: OPENSTACK_REGION must be set in onap-parameters.yaml"; exit 1; } |
| 13 | [[ -z "$OPENSTACK_KEYSTONE_URL" ]] && { echo "Error: OPENSTACK_KEYSTONE_URL must be set in onap-parameters.yaml"; exit 1; } |
| 14 | [[ -z "$OPENSTACK_FLAVOUR_MEDIUM" ]] && { echo "Error: OPENSTACK_FLAVOUR_MEDIUM must be set in onap-parameters.yaml"; exit 1; } |
| 15 | [[ -z "$OPENSTACK_SERVICE_TENANT_NAME" ]] && { echo "Error: OPENSTACK_SERVICE_TENANT_NAME must be set in onap-parameters.yaml"; exit 1; } |
| 16 | [[ -z "$DMAAP_TOPIC" ]] && { echo "Error: DMAAP_TOPIC must be set in onap-parameters.yaml"; exit 1; } |
| 17 | [[ -z "$DEMO_ARTIFACTS_VERSION" ]] && { echo "Error: DEMO_ARTIFACTS_VERSION must be set in onap-parameters.yaml"; exit 1; } |
| 18 | [[ -z "$OPENSTACK_TENANT_NAME" ]] && { echo "Error: OPENSTACK_TENANT_NAME must be set in onap-parameters.yaml"; exit 1; } |
| 19 | |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 20 | #make NAMESPACE directory |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 21 | echo "Creating $NAMESPACE directory if it doesn't exist" |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 22 | mkdir -p /config-init/$NAMESPACE/ |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 23 | |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 24 | #unzip the configs in the NAMESPACEs directory ensuring no overwriting of files |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 25 | echo "Installing configuration files" |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 26 | cp -vnpr /opt/config/src/* /config-init/$NAMESPACE/ |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 27 | |
| 28 | #ensure db directories exist. |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 29 | mkdir -p /config-init/$NAMESPACE/appc/data/ |
| 30 | mkdir -p /config-init/$NAMESPACE/dcae/pgaas/pgdata/ |
| 31 | mkdir -p /config-init/$NAMESPACE/portal/mariadb/data/ |
Mandeep Khinda | 82c63d3 | 2017-08-21 16:04:37 -0400 | [diff] [blame] | 32 | mkdir -p /config-init/$NAMESPACE/portal/logs/ |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 33 | mkdir -p /config-init/$NAMESPACE/sdnc/data/ |
| 34 | mkdir -p /config-init/$NAMESPACE/vid/mariadb/data/ |
| 35 | mkdir -p /config-init/$NAMESPACE/sdc/sdc-cs/CS/ |
| 36 | mkdir -p /config-init/$NAMESPACE/sdc/sdc-es/ES/ |
| 37 | mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-ES/ |
| 38 | mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-CS/ |
| 39 | mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-KB/ |
| 40 | mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-BE/ |
| 41 | mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-FE/ |
| 42 | mkdir -p /config-init/$NAMESPACE/aai/opt/aai/logroot/ |
Mandeep Khinda | 9cd2211 | 2017-08-30 14:40:13 +0000 | [diff] [blame] | 43 | mkdir -p /config-init/$NAMESPACE/aai/model-loader/logs/ |
| 44 | mkdir -p /config-init/$NAMESPACE/aai/haproxy/log/ |
Mandeep Khinda | 76092d6 | 2017-09-01 02:15:17 +0000 | [diff] [blame] | 45 | mkdir -p /config-init/$NAMESPACE/aai/aai-traversal/logs/ |
| 46 | mkdir -p /config-init/$NAMESPACE/aai/aai-resources/logs/ |
Mandeep Khinda | 9cd2211 | 2017-08-30 14:40:13 +0000 | [diff] [blame] | 47 | mkdir -p /config-init/$NAMESPACE/aai/sparky-be/logs/ |
| 48 | mkdir -p /config-init/$NAMESPACE/aai/elasticsearch/es-data/ |
Mandeep Khinda | 76092d6 | 2017-09-01 02:15:17 +0000 | [diff] [blame] | 49 | mkdir -p /config-init/$NAMESPACE/aai/search-data-service/logs/ |
| 50 | mkdir -p /config-init/$NAMESPACE/aai/data-router/logs/ |
BorislavG | 66a9a5c | 2017-09-06 15:12:46 +0300 | [diff] [blame] | 51 | mkdir -p /config-init/$NAMESPACE/mso/mariadb/data |
Itay Hassid | e2da86d | 2017-08-24 12:54:42 +0000 | [diff] [blame] | 52 | mkdir -p /config-init/$NAMESPACE/log/elasticsearch/data |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 53 | |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 54 | echo "Setting permissions to container writeable directories" |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 55 | chmod -R 777 /config-init/$NAMESPACE/sdc/logs/ |
Mandeep Khinda | 82c63d3 | 2017-08-21 16:04:37 -0400 | [diff] [blame] | 56 | chmod -R 777 /config-init/$NAMESPACE/portal/logs/ |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 57 | chmod -R 777 /config-init/$NAMESPACE/aai/aai-config/ |
| 58 | chmod -R 777 /config-init/$NAMESPACE/aai/aai-data/ |
| 59 | chmod -R 777 /config-init/$NAMESPACE/aai/opt/aai/logroot/ |
Mandeep Khinda | 9cd2211 | 2017-08-30 14:40:13 +0000 | [diff] [blame] | 60 | chmod -R 777 /config-init/$NAMESPACE/aai/model-loader/logs/ |
| 61 | chmod -R 777 /config-init/$NAMESPACE/aai/haproxy/log/ |
| 62 | chmod -R 777 /config-init/$NAMESPACE/aai/aai-traversal/logs/ |
| 63 | chmod -R 777 /config-init/$NAMESPACE/aai/aai-resources/logs/ |
| 64 | chmod -R 777 /config-init/$NAMESPACE/aai/sparky-be/logs/ |
| 65 | chmod -R 777 /config-init/$NAMESPACE/aai/elasticsearch/es-data/ |
Mandeep Khinda | 76092d6 | 2017-09-01 02:15:17 +0000 | [diff] [blame] | 66 | chmod -R 777 /config-init/$NAMESPACE/aai/search-data-service/logs/ |
| 67 | chmod -R 777 /config-init/$NAMESPACE/aai/data-router/logs/ |
BorislavG | 66a9a5c | 2017-09-06 15:12:46 +0300 | [diff] [blame] | 68 | chmod -R 777 /config-init/$NAMESPACE/policy/mariadb/ |
Itay Hassid | e2da86d | 2017-08-24 12:54:42 +0000 | [diff] [blame] | 69 | chmod -R 777 /config-init/$NAMESPACE/log/elasticsearch |
Mandeep Khinda | 76092d6 | 2017-09-01 02:15:17 +0000 | [diff] [blame] | 70 | |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 71 | echo "Substituting configuration parameters" |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 72 | |
| 73 | # replace the default 'onap' namespace qualification of K8s hostnames within the config files |
Mandeep Khinda | 9cd2211 | 2017-08-30 14:40:13 +0000 | [diff] [blame] | 74 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/\.onap-/\.$NAMESPACE-/g" {} \; |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 75 | # set the ubuntu 14 image |
| 76 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/UBUNTU_14_IMAGE_NAME_HERE/$OPENSTACK_UBUNTU_14_IMAGE/g" {} \; |
| 77 | # set the openstack public network uuid |
| 78 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_PUBLIC_NET_ID_HERE/$OPENSTACK_PUBLIC_NET_ID/g" {} \; |
| 79 | |
| 80 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_NETWORK_ID_WITH_ONAP_ROUTE_HERE/$OPENSTACK_OAM_NETWORK_ID/g" {} \; |
| 81 | |
| 82 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_SUBNET_ID_WITH_ONAP_ROUTE_HERE/$OPENSTACK_OAM_SUBNET_ID/g" {} \; |
| 83 | |
| 84 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s,NETWORK_CIDR_WITH_ONAP_ROUTE_HERE,$OPENSTACK_OAM_NETWORK_CIDR,g" {} \; |
| 85 | |
| 86 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_USERNAME_HERE/$OPENSTACK_USERNAME/g" {} \; |
| 87 | |
Mandeep Khinda | b53254b | 2017-09-20 16:39:30 +0000 | [diff] [blame] | 88 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_TENANT_ID_HERE/$OPENSTACK_TENANT_ID/g" {} \; |
| 89 | |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 90 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_PASSWORD_HERE/$OPENSTACK_API_KEY/g" {} \; |
| 91 | |
| 92 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_REGION_HERE/$OPENSTACK_REGION/g" {} \; |
| 93 | |
| 94 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s,OPENSTACK_KEYSTONE_IP_HERE,$OPENSTACK_KEYSTONE_URL,g" {} \; |
| 95 | |
| 96 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_FLAVOUR_MEDIUM_HERE/$OPENSTACK_FLAVOUR_MEDIUM/g" {} \; |
| 97 | |
| 98 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/DMAAP_TOPIC_HERE/$DMAAP_TOPIC/g" {} \; |
| 99 | |
| 100 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_SERVICE_TENANT_NAME_HERE/$OPENSTACK_SERVICE_TENANT_NAME/g" {} \; |
| 101 | |
| 102 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/DEMO_ARTIFACTS_VERSION_HERE/$DEMO_ARTIFACTS_VERSION/g" {} \; |
| 103 | |
| 104 | # SDNC/Robot preload files manipulation |
| 105 | OPENSTACK_OAM_NETWORK_CIDR_PREFIX=`cut -d. -f1-3 <<<"$OPENSTACK_OAM_NETWORK_CIDR"` |
| 106 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_OAM_NETWORK_CIDR_PREFIX_HERE/$OPENSTACK_OAM_NETWORK_CIDR_PREFIX/g" {} \; |
| 107 | |
| 108 | # MSO post install steps to encrypt openstack password |
| 109 | MSO_ENCRYPTION_KEY=$(cat /config-init/$NAMESPACE/mso/mso/encryption.key) |
| 110 | OPENSTACK_API_ENCRYPTED_KEY=`echo -n "$OPENSTACK_API_KEY" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 25 -p` |
| 111 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_ENCRYPTED_PASSWORD_HERE/$OPENSTACK_API_ENCRYPTED_KEY/g" {} \; |
| 112 | |
| 113 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_TENANT_NAME_HERE/$OPENSTACK_TENANT_NAME/g" {} \; |
| 114 | |
Itay Hassid | e2da86d | 2017-08-24 12:54:42 +0000 | [diff] [blame] | 115 | echo "Done!" |