blob: 9217d2cd68d6d561d443c3ec3fd7ef3328fc3714 [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
Mandeep Khindad6ea9872017-06-24 11:49:37 -040054
Mandeep Khindadc2dc862017-09-08 05:20:30 +000055echo "Setting permissions to container writeable directories"
Mike Elliottd17accd2017-08-14 16:21:40 -040056chmod -R 777 /config-init/$NAMESPACE/sdc/logs/
Mandeep Khinda82c63d32017-08-21 16:04:37 -040057chmod -R 777 /config-init/$NAMESPACE/portal/logs/
Mike Elliottd17accd2017-08-14 16:21:40 -040058chmod -R 777 /config-init/$NAMESPACE/aai/aai-config/
59chmod -R 777 /config-init/$NAMESPACE/aai/aai-data/
60chmod -R 777 /config-init/$NAMESPACE/aai/opt/aai/logroot/
Mandeep Khinda9cd22112017-08-30 14:40:13 +000061chmod -R 777 /config-init/$NAMESPACE/aai/model-loader/logs/
62chmod -R 777 /config-init/$NAMESPACE/aai/haproxy/log/
63chmod -R 777 /config-init/$NAMESPACE/aai/aai-traversal/logs/
64chmod -R 777 /config-init/$NAMESPACE/aai/aai-resources/logs/
65chmod -R 777 /config-init/$NAMESPACE/aai/sparky-be/logs/
66chmod -R 777 /config-init/$NAMESPACE/aai/elasticsearch/es-data/
Mandeep Khinda76092d62017-09-01 02:15:17 +000067chmod -R 777 /config-init/$NAMESPACE/aai/search-data-service/logs/
68chmod -R 777 /config-init/$NAMESPACE/aai/data-router/logs/
BorislavG66a9a5c2017-09-06 15:12:46 +030069chmod -R 777 /config-init/$NAMESPACE/policy/mariadb/
Itay Hasside2da86d2017-08-24 12:54:42 +000070chmod -R 777 /config-init/$NAMESPACE/log/elasticsearch
Mandeep Khinda76092d62017-09-01 02:15:17 +000071
Mandeep Khindadc2dc862017-09-08 05:20:30 +000072echo "Substituting configuration parameters"
Mike Elliottd17accd2017-08-14 16:21:40 -040073
74# replace the default 'onap' namespace qualification of K8s hostnames within the config files
Mandeep Khinda9cd22112017-08-30 14:40:13 +000075find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/\.onap-/\.$NAMESPACE-/g" {} \;
Mandeep Khindadc2dc862017-09-08 05:20:30 +000076# set the ubuntu 14 image
77find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/UBUNTU_14_IMAGE_NAME_HERE/$OPENSTACK_UBUNTU_14_IMAGE/g" {} \;
78# set the openstack public network uuid
79find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_PUBLIC_NET_ID_HERE/$OPENSTACK_PUBLIC_NET_ID/g" {} \;
80
81find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_NETWORK_ID_WITH_ONAP_ROUTE_HERE/$OPENSTACK_OAM_NETWORK_ID/g" {} \;
82
83find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_SUBNET_ID_WITH_ONAP_ROUTE_HERE/$OPENSTACK_OAM_SUBNET_ID/g" {} \;
84
85find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s,NETWORK_CIDR_WITH_ONAP_ROUTE_HERE,$OPENSTACK_OAM_NETWORK_CIDR,g" {} \;
86
87find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_USERNAME_HERE/$OPENSTACK_USERNAME/g" {} \;
88
Mandeep Khindab53254b2017-09-20 16:39:30 +000089find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_TENANT_ID_HERE/$OPENSTACK_TENANT_ID/g" {} \;
90
Mandeep Khindadc2dc862017-09-08 05:20:30 +000091find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_PASSWORD_HERE/$OPENSTACK_API_KEY/g" {} \;
92
93find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_REGION_HERE/$OPENSTACK_REGION/g" {} \;
94
95find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s,OPENSTACK_KEYSTONE_IP_HERE,$OPENSTACK_KEYSTONE_URL,g" {} \;
96
97find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_FLAVOUR_MEDIUM_HERE/$OPENSTACK_FLAVOUR_MEDIUM/g" {} \;
98
99find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/DMAAP_TOPIC_HERE/$DMAAP_TOPIC/g" {} \;
100
101find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_SERVICE_TENANT_NAME_HERE/$OPENSTACK_SERVICE_TENANT_NAME/g" {} \;
102
103find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/DEMO_ARTIFACTS_VERSION_HERE/$DEMO_ARTIFACTS_VERSION/g" {} \;
104
105# SDNC/Robot preload files manipulation
106OPENSTACK_OAM_NETWORK_CIDR_PREFIX=`cut -d. -f1-3 <<<"$OPENSTACK_OAM_NETWORK_CIDR"`
107find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_OAM_NETWORK_CIDR_PREFIX_HERE/$OPENSTACK_OAM_NETWORK_CIDR_PREFIX/g" {} \;
108
109# MSO post install steps to encrypt openstack password
110MSO_ENCRYPTION_KEY=$(cat /config-init/$NAMESPACE/mso/mso/encryption.key)
111OPENSTACK_API_ENCRYPTED_KEY=`echo -n "$OPENSTACK_API_KEY" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 25 -p`
112find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_ENCRYPTED_PASSWORD_HERE/$OPENSTACK_API_ENCRYPTED_KEY/g" {} \;
113
114find /config-init/$NAMESPACE/ -type f -exec sed -i -e "s/OPENSTACK_TENANT_NAME_HERE/$OPENSTACK_TENANT_NAME/g" {} \;
115
Itay Hasside2da86d2017-08-24 12:54:42 +0000116echo "Done!"