blob: e212971a874373c40321ea53b51b187454fff20f [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
Dusan Rozmanf776f3d2017-09-18 13:07:56 -040052mkdir -p /config-init/$NAMESPACE/clamp/mariadb/data
Itay Hasside2da86d2017-08-24 12:54:42 +000053mkdir -p /config-init/$NAMESPACE/log/elasticsearch/data
gfrabonibe779fa2017-09-19 13:25:30 -040054mkdir -p /config-init/$NAMESPACE/consul/consul-agent-config/bin
55mkdir -p /config-init/$NAMESPACE/consul/consul-agent-config/scripts
56mkdir -p /config-init/$NAMESPACE/consul/consul-server-config
Mandeep Khindad6ea9872017-06-24 11:49:37 -040057
Mandeep Khindadc2dc862017-09-08 05:20:30 +000058echo "Setting permissions to container writeable directories"
Mike Elliottd17accd2017-08-14 16:21:40 -040059chmod -R 777 /config-init/$NAMESPACE/sdc/logs/
Mandeep Khinda82c63d32017-08-21 16:04:37 -040060chmod -R 777 /config-init/$NAMESPACE/portal/logs/
Mike Elliottd17accd2017-08-14 16:21:40 -040061chmod -R 777 /config-init/$NAMESPACE/aai/aai-config/
62chmod -R 777 /config-init/$NAMESPACE/aai/aai-data/
63chmod -R 777 /config-init/$NAMESPACE/aai/opt/aai/logroot/
Mandeep Khinda9cd22112017-08-30 14:40:13 +000064chmod -R 777 /config-init/$NAMESPACE/aai/model-loader/logs/
65chmod -R 777 /config-init/$NAMESPACE/aai/haproxy/log/
66chmod -R 777 /config-init/$NAMESPACE/aai/aai-traversal/logs/
67chmod -R 777 /config-init/$NAMESPACE/aai/aai-resources/logs/
68chmod -R 777 /config-init/$NAMESPACE/aai/sparky-be/logs/
69chmod -R 777 /config-init/$NAMESPACE/aai/elasticsearch/es-data/
Mandeep Khinda76092d62017-09-01 02:15:17 +000070chmod -R 777 /config-init/$NAMESPACE/aai/search-data-service/logs/
71chmod -R 777 /config-init/$NAMESPACE/aai/data-router/logs/
BorislavG66a9a5c2017-09-06 15:12:46 +030072chmod -R 777 /config-init/$NAMESPACE/policy/mariadb/
Itay Hasside2da86d2017-08-24 12:54:42 +000073chmod -R 777 /config-init/$NAMESPACE/log/elasticsearch
yurynd0707be2017-09-27 14:54:18 +030074chown -R root:root /config-init/$NAMESPACE/log
Mandeep Khinda76092d62017-09-01 02:15:17 +000075
Mandeep Khindadc2dc862017-09-08 05:20:30 +000076echo "Substituting configuration parameters"
Mike Elliottd17accd2017-08-14 16:21:40 -040077
78# replace the default 'onap' namespace qualification of K8s hostnames within the config files
Mandeep Khinda9cd22112017-08-30 14:40:13 +000079find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/\.onap-/\.$NAMESPACE-/g" {} \;
gfrabonibe779fa2017-09-19 13:25:30 -040080find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/kubectl -n onap/kubectl -n $NAMESPACE/g" {} \;
Mandeep Khindadc2dc862017-09-08 05:20:30 +000081# set the ubuntu 14 image
82find /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
84find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_PUBLIC_NET_ID_HERE/$OPENSTACK_PUBLIC_NET_ID/g" {} \;
85
86find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_NETWORK_ID_WITH_ONAP_ROUTE_HERE/$OPENSTACK_OAM_NETWORK_ID/g" {} \;
87
88find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_SUBNET_ID_WITH_ONAP_ROUTE_HERE/$OPENSTACK_OAM_SUBNET_ID/g" {} \;
89
90find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s,NETWORK_CIDR_WITH_ONAP_ROUTE_HERE,$OPENSTACK_OAM_NETWORK_CIDR,g" {} \;
91
92find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_USERNAME_HERE/$OPENSTACK_USERNAME/g" {} \;
93
Mandeep Khindab53254b2017-09-20 16:39:30 +000094find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_TENANT_ID_HERE/$OPENSTACK_TENANT_ID/g" {} \;
95
Mandeep Khindadc2dc862017-09-08 05:20:30 +000096find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_PASSWORD_HERE/$OPENSTACK_API_KEY/g" {} \;
97
98find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_REGION_HERE/$OPENSTACK_REGION/g" {} \;
99
100find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s,OPENSTACK_KEYSTONE_IP_HERE,$OPENSTACK_KEYSTONE_URL,g" {} \;
101
102find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_FLAVOUR_MEDIUM_HERE/$OPENSTACK_FLAVOUR_MEDIUM/g" {} \;
103
104find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/DMAAP_TOPIC_HERE/$DMAAP_TOPIC/g" {} \;
105
106find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_SERVICE_TENANT_NAME_HERE/$OPENSTACK_SERVICE_TENANT_NAME/g" {} \;
107
108find /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
111OPENSTACK_OAM_NETWORK_CIDR_PREFIX=`cut -d. -f1-3 <<<"$OPENSTACK_OAM_NETWORK_CIDR"`
112find /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
115MSO_ENCRYPTION_KEY=$(cat /config-init/$NAMESPACE/mso/mso/encryption.key)
116OPENSTACK_API_ENCRYPTED_KEY=`echo -n "$OPENSTACK_API_KEY" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 25 -p`
117find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_ENCRYPTED_PASSWORD_HERE/$OPENSTACK_API_ENCRYPTED_KEY/g" {} \;
118
119find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_TENANT_NAME_HERE/$OPENSTACK_TENANT_NAME/g" {} \;
120
Itay Hasside2da86d2017-08-24 12:54:42 +0000121echo "Done!"