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 |
Dusan Rozman | f776f3d | 2017-09-18 13:07:56 -0400 | [diff] [blame] | 52 | mkdir -p /config-init/$NAMESPACE/clamp/mariadb/data |
Itay Hassid | e2da86d | 2017-08-24 12:54:42 +0000 | [diff] [blame] | 53 | mkdir -p /config-init/$NAMESPACE/log/elasticsearch/data |
gfraboni | be779fa | 2017-09-19 13:25:30 -0400 | [diff] [blame] | 54 | mkdir -p /config-init/$NAMESPACE/consul/consul-agent-config/bin |
| 55 | mkdir -p /config-init/$NAMESPACE/consul/consul-agent-config/scripts |
| 56 | mkdir -p /config-init/$NAMESPACE/consul/consul-server-config |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 57 | |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 58 | echo "Setting permissions to container writeable directories" |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 59 | chmod -R 777 /config-init/$NAMESPACE/sdc/logs/ |
Mandeep Khinda | 82c63d3 | 2017-08-21 16:04:37 -0400 | [diff] [blame] | 60 | chmod -R 777 /config-init/$NAMESPACE/portal/logs/ |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 61 | chmod -R 777 /config-init/$NAMESPACE/aai/aai-config/ |
| 62 | chmod -R 777 /config-init/$NAMESPACE/aai/aai-data/ |
| 63 | chmod -R 777 /config-init/$NAMESPACE/aai/opt/aai/logroot/ |
Mandeep Khinda | 9cd2211 | 2017-08-30 14:40:13 +0000 | [diff] [blame] | 64 | chmod -R 777 /config-init/$NAMESPACE/aai/model-loader/logs/ |
| 65 | chmod -R 777 /config-init/$NAMESPACE/aai/haproxy/log/ |
| 66 | chmod -R 777 /config-init/$NAMESPACE/aai/aai-traversal/logs/ |
| 67 | chmod -R 777 /config-init/$NAMESPACE/aai/aai-resources/logs/ |
| 68 | chmod -R 777 /config-init/$NAMESPACE/aai/sparky-be/logs/ |
| 69 | chmod -R 777 /config-init/$NAMESPACE/aai/elasticsearch/es-data/ |
Mandeep Khinda | 76092d6 | 2017-09-01 02:15:17 +0000 | [diff] [blame] | 70 | chmod -R 777 /config-init/$NAMESPACE/aai/search-data-service/logs/ |
| 71 | chmod -R 777 /config-init/$NAMESPACE/aai/data-router/logs/ |
BorislavG | 66a9a5c | 2017-09-06 15:12:46 +0300 | [diff] [blame] | 72 | chmod -R 777 /config-init/$NAMESPACE/policy/mariadb/ |
Itay Hassid | e2da86d | 2017-08-24 12:54:42 +0000 | [diff] [blame] | 73 | chmod -R 777 /config-init/$NAMESPACE/log/elasticsearch |
yuryn | d0707be | 2017-09-27 14:54:18 +0300 | [diff] [blame] | 74 | chown -R root:root /config-init/$NAMESPACE/log |
Mandeep Khinda | 76092d6 | 2017-09-01 02:15:17 +0000 | [diff] [blame] | 75 | |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 76 | echo "Substituting configuration parameters" |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 77 | |
| 78 | # 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] | 79 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/\.onap-/\.$NAMESPACE-/g" {} \; |
gfraboni | be779fa | 2017-09-19 13:25:30 -0400 | [diff] [blame] | 80 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/kubectl -n onap/kubectl -n $NAMESPACE/g" {} \; |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 81 | # set the ubuntu 14 image |
| 82 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/UBUNTU_14_IMAGE_NAME_HERE/$OPENSTACK_UBUNTU_14_IMAGE/g" {} \; |
| 83 | # set the openstack public network uuid |
| 84 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_PUBLIC_NET_ID_HERE/$OPENSTACK_PUBLIC_NET_ID/g" {} \; |
| 85 | |
| 86 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_NETWORK_ID_WITH_ONAP_ROUTE_HERE/$OPENSTACK_OAM_NETWORK_ID/g" {} \; |
| 87 | |
| 88 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_SUBNET_ID_WITH_ONAP_ROUTE_HERE/$OPENSTACK_OAM_SUBNET_ID/g" {} \; |
| 89 | |
| 90 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s,NETWORK_CIDR_WITH_ONAP_ROUTE_HERE,$OPENSTACK_OAM_NETWORK_CIDR,g" {} \; |
| 91 | |
| 92 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_USERNAME_HERE/$OPENSTACK_USERNAME/g" {} \; |
| 93 | |
Mandeep Khinda | b53254b | 2017-09-20 16:39:30 +0000 | [diff] [blame] | 94 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_TENANT_ID_HERE/$OPENSTACK_TENANT_ID/g" {} \; |
| 95 | |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 96 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_PASSWORD_HERE/$OPENSTACK_API_KEY/g" {} \; |
| 97 | |
| 98 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_REGION_HERE/$OPENSTACK_REGION/g" {} \; |
| 99 | |
| 100 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s,OPENSTACK_KEYSTONE_IP_HERE,$OPENSTACK_KEYSTONE_URL,g" {} \; |
| 101 | |
| 102 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_FLAVOUR_MEDIUM_HERE/$OPENSTACK_FLAVOUR_MEDIUM/g" {} \; |
| 103 | |
| 104 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/DMAAP_TOPIC_HERE/$DMAAP_TOPIC/g" {} \; |
| 105 | |
| 106 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_SERVICE_TENANT_NAME_HERE/$OPENSTACK_SERVICE_TENANT_NAME/g" {} \; |
| 107 | |
| 108 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/DEMO_ARTIFACTS_VERSION_HERE/$DEMO_ARTIFACTS_VERSION/g" {} \; |
| 109 | |
| 110 | # SDNC/Robot preload files manipulation |
| 111 | OPENSTACK_OAM_NETWORK_CIDR_PREFIX=`cut -d. -f1-3 <<<"$OPENSTACK_OAM_NETWORK_CIDR"` |
| 112 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_OAM_NETWORK_CIDR_PREFIX_HERE/$OPENSTACK_OAM_NETWORK_CIDR_PREFIX/g" {} \; |
| 113 | |
| 114 | # MSO post install steps to encrypt openstack password |
| 115 | MSO_ENCRYPTION_KEY=$(cat /config-init/$NAMESPACE/mso/mso/encryption.key) |
BorislavG | 317f2d5 | 2017-11-22 14:02:09 +0200 | [diff] [blame^] | 116 | OPENSTACK_API_ENCRYPTED_KEY=`echo -n "$OPENSTACK_API_KEY" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 256 -p` |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 117 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_ENCRYPTED_PASSWORD_HERE/$OPENSTACK_API_ENCRYPTED_KEY/g" {} \; |
| 118 | |
| 119 | find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_TENANT_NAME_HERE/$OPENSTACK_TENANT_NAME/g" {} \; |
| 120 | |
Itay Hassid | e2da86d | 2017-08-24 12:54:42 +0000 | [diff] [blame] | 121 | echo "Done!" |