blob: 9c4c7cd3c5c3df4c2e999d3313df2249bcd8ecac [file] [log] [blame]
Mandeep Khinda5291ba32017-09-20 16:57:09 +00001#!/bin/bash -x
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; }
Mandeep Khindab53254b2017-09-20 16:39:30 +000010[[ -z "$OPENSTACK_TENANT_ID" ]] && { echo "Error: OPENSTACK_TENANT_ID must be set in onap-parameters.yaml"; exit 1; }
Mandeep Khindadc2dc862017-09-08 05:20:30 +000011[[ -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 Elliottd17accd2017-08-14 16:21:40 -040020#make NAMESPACE directory
Mandeep Khindadc2dc862017-09-08 05:20:30 +000021echo "Creating $NAMESPACE directory if it doesn't exist"
Mike Elliottd17accd2017-08-14 16:21:40 -040022mkdir -p /config-init/$NAMESPACE/
Mandeep Khindad6ea9872017-06-24 11:49:37 -040023
Mike Elliottd17accd2017-08-14 16:21:40 -040024#unzip the configs in the NAMESPACEs directory ensuring no overwriting of files
Mandeep Khindadc2dc862017-09-08 05:20:30 +000025echo "Installing configuration files"
Mike Elliottd17accd2017-08-14 16:21:40 -040026cp -vnpr /opt/config/src/* /config-init/$NAMESPACE/
Mandeep Khindad6ea9872017-06-24 11:49:37 -040027
28#ensure db directories exist.
Mike Elliottd17accd2017-08-14 16:21:40 -040029mkdir -p /config-init/$NAMESPACE/appc/data/
30mkdir -p /config-init/$NAMESPACE/dcae/pgaas/pgdata/
31mkdir -p /config-init/$NAMESPACE/portal/mariadb/data/
Mandeep Khinda82c63d32017-08-21 16:04:37 -040032mkdir -p /config-init/$NAMESPACE/portal/logs/
Mike Elliottd17accd2017-08-14 16:21:40 -040033mkdir -p /config-init/$NAMESPACE/sdnc/data/
34mkdir -p /config-init/$NAMESPACE/vid/mariadb/data/
35mkdir -p /config-init/$NAMESPACE/sdc/sdc-cs/CS/
36mkdir -p /config-init/$NAMESPACE/sdc/sdc-es/ES/
37mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-ES/
38mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-CS/
39mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-KB/
40mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-BE/
41mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-FE/
42mkdir -p /config-init/$NAMESPACE/aai/opt/aai/logroot/
Mandeep Khinda9cd22112017-08-30 14:40:13 +000043mkdir -p /config-init/$NAMESPACE/aai/model-loader/logs/
44mkdir -p /config-init/$NAMESPACE/aai/haproxy/log/
Mandeep Khinda76092d62017-09-01 02:15:17 +000045mkdir -p /config-init/$NAMESPACE/aai/aai-traversal/logs/
46mkdir -p /config-init/$NAMESPACE/aai/aai-resources/logs/
Mandeep Khinda9cd22112017-08-30 14:40:13 +000047mkdir -p /config-init/$NAMESPACE/aai/sparky-be/logs/
48mkdir -p /config-init/$NAMESPACE/aai/elasticsearch/es-data/
Mandeep Khinda76092d62017-09-01 02:15:17 +000049mkdir -p /config-init/$NAMESPACE/aai/search-data-service/logs/
50mkdir -p /config-init/$NAMESPACE/aai/data-router/logs/
BorislavG66a9a5c2017-09-06 15:12:46 +030051mkdir -p /config-init/$NAMESPACE/mso/mariadb/data
Itay Hasside2da86d2017-08-24 12:54:42 +000052mkdir -p /config-init/$NAMESPACE/log/elasticsearch/data
Mandeep Khindad6ea9872017-06-24 11:49:37 -040053
Mandeep Khindadc2dc862017-09-08 05:20:30 +000054echo "Setting permissions to container writeable directories"
Mike Elliottd17accd2017-08-14 16:21:40 -040055chmod -R 777 /config-init/$NAMESPACE/sdc/logs/
Mandeep Khinda82c63d32017-08-21 16:04:37 -040056chmod -R 777 /config-init/$NAMESPACE/portal/logs/
Mike Elliottd17accd2017-08-14 16:21:40 -040057chmod -R 777 /config-init/$NAMESPACE/aai/aai-config/
58chmod -R 777 /config-init/$NAMESPACE/aai/aai-data/
59chmod -R 777 /config-init/$NAMESPACE/aai/opt/aai/logroot/
Mandeep Khinda9cd22112017-08-30 14:40:13 +000060chmod -R 777 /config-init/$NAMESPACE/aai/model-loader/logs/
61chmod -R 777 /config-init/$NAMESPACE/aai/haproxy/log/
62chmod -R 777 /config-init/$NAMESPACE/aai/aai-traversal/logs/
63chmod -R 777 /config-init/$NAMESPACE/aai/aai-resources/logs/
64chmod -R 777 /config-init/$NAMESPACE/aai/sparky-be/logs/
65chmod -R 777 /config-init/$NAMESPACE/aai/elasticsearch/es-data/
Mandeep Khinda76092d62017-09-01 02:15:17 +000066chmod -R 777 /config-init/$NAMESPACE/aai/search-data-service/logs/
67chmod -R 777 /config-init/$NAMESPACE/aai/data-router/logs/
BorislavG66a9a5c2017-09-06 15:12:46 +030068chmod -R 777 /config-init/$NAMESPACE/policy/mariadb/
Itay Hasside2da86d2017-08-24 12:54:42 +000069chmod -R 777 /config-init/$NAMESPACE/log/elasticsearch
Mandeep Khinda76092d62017-09-01 02:15:17 +000070
Mandeep Khindadc2dc862017-09-08 05:20:30 +000071echo "Substituting configuration parameters"
Mike Elliottd17accd2017-08-14 16:21:40 -040072
73# replace the default 'onap' namespace qualification of K8s hostnames within the config files
Mandeep Khinda9cd22112017-08-30 14:40:13 +000074find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/\.onap-/\.$NAMESPACE-/g" {} \;
Mandeep Khindadc2dc862017-09-08 05:20:30 +000075# set the ubuntu 14 image
76find /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
78find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_PUBLIC_NET_ID_HERE/$OPENSTACK_PUBLIC_NET_ID/g" {} \;
79
80find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_NETWORK_ID_WITH_ONAP_ROUTE_HERE/$OPENSTACK_OAM_NETWORK_ID/g" {} \;
81
82find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_SUBNET_ID_WITH_ONAP_ROUTE_HERE/$OPENSTACK_OAM_SUBNET_ID/g" {} \;
83
84find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s,NETWORK_CIDR_WITH_ONAP_ROUTE_HERE,$OPENSTACK_OAM_NETWORK_CIDR,g" {} \;
85
86find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_USERNAME_HERE/$OPENSTACK_USERNAME/g" {} \;
87
Mandeep Khindab53254b2017-09-20 16:39:30 +000088find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_TENANT_ID_HERE/$OPENSTACK_TENANT_ID/g" {} \;
89
Mandeep Khindadc2dc862017-09-08 05:20:30 +000090find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_PASSWORD_HERE/$OPENSTACK_API_KEY/g" {} \;
91
92find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_REGION_HERE/$OPENSTACK_REGION/g" {} \;
93
94find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s,OPENSTACK_KEYSTONE_IP_HERE,$OPENSTACK_KEYSTONE_URL,g" {} \;
95
96find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_FLAVOUR_MEDIUM_HERE/$OPENSTACK_FLAVOUR_MEDIUM/g" {} \;
97
98find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/DMAAP_TOPIC_HERE/$DMAAP_TOPIC/g" {} \;
99
100find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_SERVICE_TENANT_NAME_HERE/$OPENSTACK_SERVICE_TENANT_NAME/g" {} \;
101
102find /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
105OPENSTACK_OAM_NETWORK_CIDR_PREFIX=`cut -d. -f1-3 <<<"$OPENSTACK_OAM_NETWORK_CIDR"`
106find /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
109MSO_ENCRYPTION_KEY=$(cat /config-init/$NAMESPACE/mso/mso/encryption.key)
110OPENSTACK_API_ENCRYPTED_KEY=`echo -n "$OPENSTACK_API_KEY" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 25 -p`
111find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_ENCRYPTED_PASSWORD_HERE/$OPENSTACK_API_ENCRYPTED_KEY/g" {} \;
112
113find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_TENANT_NAME_HERE/$OPENSTACK_TENANT_NAME/g" {} \;
114
Itay Hasside2da86d2017-08-24 12:54:42 +0000115echo "Done!"