blob: cc3a0f62f4adb9b1e466efb9e3592488240e5237 [file] [log] [blame]
Mandeep Khindad6ea9872017-06-24 11:49:37 -04001#!/bin/bash
Mandeep Khindadc2dc862017-09-08 05:20:30 +00002
3echo "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; }
10[[ -z "$OPENSTACK_API_KEY" ]] && { echo "Error: OPENSTACK_API_KEY must be set in onap-parameters.yaml"; exit 1; }
11[[ -z "$OPENSTACK_REGION" ]] && { echo "Error: OPENSTACK_REGION must be set in onap-parameters.yaml"; exit 1; }
12[[ -z "$OPENSTACK_KEYSTONE_URL" ]] && { echo "Error: OPENSTACK_KEYSTONE_URL must be set in onap-parameters.yaml"; exit 1; }
13[[ -z "$OPENSTACK_FLAVOUR_MEDIUM" ]] && { echo "Error: OPENSTACK_FLAVOUR_MEDIUM must be set in onap-parameters.yaml"; exit 1; }
14[[ -z "$OPENSTACK_SERVICE_TENANT_NAME" ]] && { echo "Error: OPENSTACK_SERVICE_TENANT_NAME must be set in onap-parameters.yaml"; exit 1; }
15[[ -z "$DMAAP_TOPIC" ]] && { echo "Error: DMAAP_TOPIC must be set in onap-parameters.yaml"; exit 1; }
16[[ -z "$DEMO_ARTIFACTS_VERSION" ]] && { echo "Error: DEMO_ARTIFACTS_VERSION must be set in onap-parameters.yaml"; exit 1; }
17[[ -z "$OPENSTACK_TENANT_NAME" ]] && { echo "Error: OPENSTACK_TENANT_NAME must be set in onap-parameters.yaml"; exit 1; }
18
Mike Elliottd17accd2017-08-14 16:21:40 -040019#make NAMESPACE directory
Mandeep Khindadc2dc862017-09-08 05:20:30 +000020echo "Creating $NAMESPACE directory if it doesn't exist"
Mike Elliottd17accd2017-08-14 16:21:40 -040021mkdir -p /config-init/$NAMESPACE/
Mandeep Khindad6ea9872017-06-24 11:49:37 -040022
Mike Elliottd17accd2017-08-14 16:21:40 -040023#unzip the configs in the NAMESPACEs directory ensuring no overwriting of files
Mandeep Khindadc2dc862017-09-08 05:20:30 +000024echo "Installing configuration files"
Mike Elliottd17accd2017-08-14 16:21:40 -040025cp -vnpr /opt/config/src/* /config-init/$NAMESPACE/
Mandeep Khindad6ea9872017-06-24 11:49:37 -040026
27#ensure db directories exist.
Mike Elliottd17accd2017-08-14 16:21:40 -040028mkdir -p /config-init/$NAMESPACE/appc/data/
29mkdir -p /config-init/$NAMESPACE/dcae/pgaas/pgdata/
30mkdir -p /config-init/$NAMESPACE/portal/mariadb/data/
Mandeep Khinda82c63d32017-08-21 16:04:37 -040031mkdir -p /config-init/$NAMESPACE/portal/logs/
Mike Elliottd17accd2017-08-14 16:21:40 -040032mkdir -p /config-init/$NAMESPACE/sdnc/data/
33mkdir -p /config-init/$NAMESPACE/vid/mariadb/data/
34mkdir -p /config-init/$NAMESPACE/sdc/sdc-cs/CS/
35mkdir -p /config-init/$NAMESPACE/sdc/sdc-es/ES/
36mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-ES/
37mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-CS/
38mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-KB/
39mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-BE/
40mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-FE/
41mkdir -p /config-init/$NAMESPACE/aai/opt/aai/logroot/
Mandeep Khinda9cd22112017-08-30 14:40:13 +000042mkdir -p /config-init/$NAMESPACE/aai/model-loader/logs/
43mkdir -p /config-init/$NAMESPACE/aai/haproxy/log/
Mandeep Khinda76092d62017-09-01 02:15:17 +000044mkdir -p /config-init/$NAMESPACE/aai/aai-traversal/logs/
45mkdir -p /config-init/$NAMESPACE/aai/aai-resources/logs/
Mandeep Khinda9cd22112017-08-30 14:40:13 +000046mkdir -p /config-init/$NAMESPACE/aai/sparky-be/logs/
47mkdir -p /config-init/$NAMESPACE/aai/elasticsearch/es-data/
Mandeep Khinda76092d62017-09-01 02:15:17 +000048mkdir -p /config-init/$NAMESPACE/aai/search-data-service/logs/
49mkdir -p /config-init/$NAMESPACE/aai/data-router/logs/
BorislavG66a9a5c2017-09-06 15:12:46 +030050mkdir -p /config-init/$NAMESPACE/mso/mariadb/data
Mandeep Khindad6ea9872017-06-24 11:49:37 -040051
Mandeep Khindadc2dc862017-09-08 05:20:30 +000052echo "Setting permissions to container writeable directories"
Mike Elliottd17accd2017-08-14 16:21:40 -040053chmod -R 777 /config-init/$NAMESPACE/sdc/logs/
Mandeep Khinda82c63d32017-08-21 16:04:37 -040054chmod -R 777 /config-init/$NAMESPACE/portal/logs/
Mike Elliottd17accd2017-08-14 16:21:40 -040055chmod -R 777 /config-init/$NAMESPACE/aai/aai-config/
56chmod -R 777 /config-init/$NAMESPACE/aai/aai-data/
57chmod -R 777 /config-init/$NAMESPACE/aai/opt/aai/logroot/
Mandeep Khinda9cd22112017-08-30 14:40:13 +000058chmod -R 777 /config-init/$NAMESPACE/aai/model-loader/logs/
59chmod -R 777 /config-init/$NAMESPACE/aai/haproxy/log/
60chmod -R 777 /config-init/$NAMESPACE/aai/aai-traversal/logs/
61chmod -R 777 /config-init/$NAMESPACE/aai/aai-resources/logs/
62chmod -R 777 /config-init/$NAMESPACE/aai/sparky-be/logs/
63chmod -R 777 /config-init/$NAMESPACE/aai/elasticsearch/es-data/
Mandeep Khinda76092d62017-09-01 02:15:17 +000064chmod -R 777 /config-init/$NAMESPACE/aai/search-data-service/logs/
65chmod -R 777 /config-init/$NAMESPACE/aai/data-router/logs/
BorislavG66a9a5c2017-09-06 15:12:46 +030066chmod -R 777 /config-init/$NAMESPACE/policy/mariadb/
Mandeep Khinda76092d62017-09-01 02:15:17 +000067
Mandeep Khindadc2dc862017-09-08 05:20:30 +000068echo "Substituting configuration parameters"
Mike Elliottd17accd2017-08-14 16:21:40 -040069
70# replace the default 'onap' namespace qualification of K8s hostnames within the config files
Mandeep Khinda9cd22112017-08-30 14:40:13 +000071find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/\.onap-/\.$NAMESPACE-/g" {} \;
Mandeep Khindadc2dc862017-09-08 05:20:30 +000072# set the ubuntu 14 image
73find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/UBUNTU_14_IMAGE_NAME_HERE/$OPENSTACK_UBUNTU_14_IMAGE/g" {} \;
74# set the openstack public network uuid
75find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_PUBLIC_NET_ID_HERE/$OPENSTACK_PUBLIC_NET_ID/g" {} \;
76
77find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_NETWORK_ID_WITH_ONAP_ROUTE_HERE/$OPENSTACK_OAM_NETWORK_ID/g" {} \;
78
79find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_SUBNET_ID_WITH_ONAP_ROUTE_HERE/$OPENSTACK_OAM_SUBNET_ID/g" {} \;
80
81find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s,NETWORK_CIDR_WITH_ONAP_ROUTE_HERE,$OPENSTACK_OAM_NETWORK_CIDR,g" {} \;
82
83find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_USERNAME_HERE/$OPENSTACK_USERNAME/g" {} \;
84
85find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_PASSWORD_HERE/$OPENSTACK_API_KEY/g" {} \;
86
87find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_REGION_HERE/$OPENSTACK_REGION/g" {} \;
88
89find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s,OPENSTACK_KEYSTONE_IP_HERE,$OPENSTACK_KEYSTONE_URL,g" {} \;
90
91find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_FLAVOUR_MEDIUM_HERE/$OPENSTACK_FLAVOUR_MEDIUM/g" {} \;
92
93find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/DMAAP_TOPIC_HERE/$DMAAP_TOPIC/g" {} \;
94
95find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_SERVICE_TENANT_NAME_HERE/$OPENSTACK_SERVICE_TENANT_NAME/g" {} \;
96
97find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/DEMO_ARTIFACTS_VERSION_HERE/$DEMO_ARTIFACTS_VERSION/g" {} \;
98
99# SDNC/Robot preload files manipulation
100OPENSTACK_OAM_NETWORK_CIDR_PREFIX=`cut -d. -f1-3 <<<"$OPENSTACK_OAM_NETWORK_CIDR"`
101find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_OAM_NETWORK_CIDR_PREFIX_HERE/$OPENSTACK_OAM_NETWORK_CIDR_PREFIX/g" {} \;
102
103# MSO post install steps to encrypt openstack password
104MSO_ENCRYPTION_KEY=$(cat /config-init/$NAMESPACE/mso/mso/encryption.key)
105OPENSTACK_API_ENCRYPTED_KEY=`echo -n "$OPENSTACK_API_KEY" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 25 -p`
106find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_ENCRYPTED_PASSWORD_HERE/$OPENSTACK_API_ENCRYPTED_KEY/g" {} \;
107
108find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_TENANT_NAME_HERE/$OPENSTACK_TENANT_NAME/g" {} \;
109
110echo "Done!"