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 | |
yuryn | ebdbbd2 | 2017-11-28 01:17:36 +0200 | [diff] [blame] | 3 | concat_array() { |
| 4 | local arr=("$@") |
| 5 | local str='' |
| 6 | for i in ${!arr[@]}; do |
| 7 | if (( $i > 0 )); then |
| 8 | str="${str};" |
| 9 | fi |
| 10 | str="${str}${arr[$i]}" |
| 11 | done |
| 12 | echo "$str" |
| 13 | } |
| 14 | |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 15 | echo "Validating onap-parameters.yaml has been populated" |
| 16 | [[ -z "$OPENSTACK_UBUNTU_14_IMAGE" ]] && { echo "Error: OPENSTACK_UBUNTU_14_IMAGE must be set in onap-parameters.yaml"; exit 1; } |
| 17 | [[ -z "$OPENSTACK_PUBLIC_NET_ID" ]] && { echo "Error: OPENSTACK_PUBLIC_NET_ID must be set in onap-parameters.yaml"; exit 1; } |
| 18 | [[ -z "$OPENSTACK_OAM_NETWORK_ID" ]] && { echo "Error: OPENSTACK_OAM_NETWORK_ID must be set in onap-parameters.yaml"; exit 1; } |
| 19 | [[ -z "$OPENSTACK_OAM_SUBNET_ID" ]] && { echo "Error: OPENSTACK_OAM_SUBNET_ID must be set in onap-parameters.yaml"; exit 1; } |
| 20 | [[ -z "$OPENSTACK_OAM_NETWORK_CIDR" ]] && { echo "Error: OPENSTACK_OAM_NETWORK_CIDR must be set in onap-parameters.yaml"; exit 1; } |
| 21 | [[ -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] | 22 | [[ -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] | 23 | [[ -z "$OPENSTACK_API_KEY" ]] && { echo "Error: OPENSTACK_API_KEY must be set in onap-parameters.yaml"; exit 1; } |
| 24 | [[ -z "$OPENSTACK_REGION" ]] && { echo "Error: OPENSTACK_REGION must be set in onap-parameters.yaml"; exit 1; } |
| 25 | [[ -z "$OPENSTACK_KEYSTONE_URL" ]] && { echo "Error: OPENSTACK_KEYSTONE_URL must be set in onap-parameters.yaml"; exit 1; } |
| 26 | [[ -z "$OPENSTACK_FLAVOUR_MEDIUM" ]] && { echo "Error: OPENSTACK_FLAVOUR_MEDIUM must be set in onap-parameters.yaml"; exit 1; } |
| 27 | [[ -z "$OPENSTACK_SERVICE_TENANT_NAME" ]] && { echo "Error: OPENSTACK_SERVICE_TENANT_NAME must be set in onap-parameters.yaml"; exit 1; } |
| 28 | [[ -z "$DMAAP_TOPIC" ]] && { echo "Error: DMAAP_TOPIC must be set in onap-parameters.yaml"; exit 1; } |
| 29 | [[ -z "$DEMO_ARTIFACTS_VERSION" ]] && { echo "Error: DEMO_ARTIFACTS_VERSION must be set in onap-parameters.yaml"; exit 1; } |
| 30 | [[ -z "$OPENSTACK_TENANT_NAME" ]] && { echo "Error: OPENSTACK_TENANT_NAME must be set in onap-parameters.yaml"; exit 1; } |
| 31 | |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 32 | #make NAMESPACE directory |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 33 | echo "Creating $NAMESPACE directory if it doesn't exist" |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 34 | mkdir -p /config-init/$NAMESPACE/ |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 35 | |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 36 | #unzip the configs in the NAMESPACEs directory ensuring no overwriting of files |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 37 | echo "Installing configuration files" |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 38 | cp -vnpr /opt/config/src/* /config-init/$NAMESPACE/ |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 39 | |
| 40 | #ensure db directories exist. |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 41 | mkdir -p /config-init/$NAMESPACE/appc/data/ |
| 42 | mkdir -p /config-init/$NAMESPACE/dcae/pgaas/pgdata/ |
| 43 | mkdir -p /config-init/$NAMESPACE/portal/mariadb/data/ |
Mandeep Khinda | 82c63d3 | 2017-08-21 16:04:37 -0400 | [diff] [blame] | 44 | mkdir -p /config-init/$NAMESPACE/portal/logs/ |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 45 | mkdir -p /config-init/$NAMESPACE/sdnc/data/ |
| 46 | mkdir -p /config-init/$NAMESPACE/vid/mariadb/data/ |
| 47 | mkdir -p /config-init/$NAMESPACE/sdc/sdc-cs/CS/ |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 48 | mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-ES/ |
| 49 | mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-CS/ |
| 50 | mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-KB/ |
| 51 | mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-BE/ |
| 52 | mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-FE/ |
| 53 | mkdir -p /config-init/$NAMESPACE/aai/opt/aai/logroot/ |
Mandeep Khinda | 9cd2211 | 2017-08-30 14:40:13 +0000 | [diff] [blame] | 54 | mkdir -p /config-init/$NAMESPACE/aai/model-loader/logs/ |
Mandeep Khinda | 76092d6 | 2017-09-01 02:15:17 +0000 | [diff] [blame] | 55 | mkdir -p /config-init/$NAMESPACE/aai/aai-traversal/logs/ |
| 56 | mkdir -p /config-init/$NAMESPACE/aai/aai-resources/logs/ |
Mandeep Khinda | 9cd2211 | 2017-08-30 14:40:13 +0000 | [diff] [blame] | 57 | mkdir -p /config-init/$NAMESPACE/aai/sparky-be/logs/ |
| 58 | mkdir -p /config-init/$NAMESPACE/aai/elasticsearch/es-data/ |
Mandeep Khinda | 76092d6 | 2017-09-01 02:15:17 +0000 | [diff] [blame] | 59 | mkdir -p /config-init/$NAMESPACE/aai/search-data-service/logs/ |
| 60 | mkdir -p /config-init/$NAMESPACE/aai/data-router/logs/ |
BorislavG | 66a9a5c | 2017-09-06 15:12:46 +0300 | [diff] [blame] | 61 | mkdir -p /config-init/$NAMESPACE/mso/mariadb/data |
Dusan Rozman | f776f3d | 2017-09-18 13:07:56 -0400 | [diff] [blame] | 62 | mkdir -p /config-init/$NAMESPACE/clamp/mariadb/data |
Itay Hassid | e2da86d | 2017-08-24 12:54:42 +0000 | [diff] [blame] | 63 | mkdir -p /config-init/$NAMESPACE/log/elasticsearch/data |
gfraboni | be779fa | 2017-09-19 13:25:30 -0400 | [diff] [blame] | 64 | mkdir -p /config-init/$NAMESPACE/consul/consul-agent-config/bin |
| 65 | mkdir -p /config-init/$NAMESPACE/consul/consul-agent-config/scripts |
| 66 | mkdir -p /config-init/$NAMESPACE/consul/consul-server-config |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 67 | |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 68 | echo "Setting permissions to container writeable directories" |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 69 | chmod -R 777 /config-init/$NAMESPACE/sdc/logs/ |
Mandeep Khinda | 82c63d3 | 2017-08-21 16:04:37 -0400 | [diff] [blame] | 70 | chmod -R 777 /config-init/$NAMESPACE/portal/logs/ |
Mike Elliott | d17accd | 2017-08-14 16:21:40 -0400 | [diff] [blame] | 71 | chmod -R 777 /config-init/$NAMESPACE/aai/aai-config/ |
| 72 | chmod -R 777 /config-init/$NAMESPACE/aai/aai-data/ |
| 73 | chmod -R 777 /config-init/$NAMESPACE/aai/opt/aai/logroot/ |
Mandeep Khinda | 9cd2211 | 2017-08-30 14:40:13 +0000 | [diff] [blame] | 74 | chmod -R 777 /config-init/$NAMESPACE/aai/model-loader/logs/ |
| 75 | chmod -R 777 /config-init/$NAMESPACE/aai/haproxy/log/ |
| 76 | chmod -R 777 /config-init/$NAMESPACE/aai/aai-traversal/logs/ |
| 77 | chmod -R 777 /config-init/$NAMESPACE/aai/aai-resources/logs/ |
| 78 | chmod -R 777 /config-init/$NAMESPACE/aai/sparky-be/logs/ |
| 79 | chmod -R 777 /config-init/$NAMESPACE/aai/elasticsearch/es-data/ |
Mandeep Khinda | 76092d6 | 2017-09-01 02:15:17 +0000 | [diff] [blame] | 80 | chmod -R 777 /config-init/$NAMESPACE/aai/search-data-service/logs/ |
| 81 | chmod -R 777 /config-init/$NAMESPACE/aai/data-router/logs/ |
Itay Hassid | e2da86d | 2017-08-24 12:54:42 +0000 | [diff] [blame] | 82 | chmod -R 777 /config-init/$NAMESPACE/log/elasticsearch |
yuryn | d0707be | 2017-09-27 14:54:18 +0300 | [diff] [blame] | 83 | chown -R root:root /config-init/$NAMESPACE/log |
Mandeep Khinda | 76092d6 | 2017-09-01 02:15:17 +0000 | [diff] [blame] | 84 | |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 85 | # SDNC/Robot preload files manipulation |
| 86 | OPENSTACK_OAM_NETWORK_CIDR_PREFIX=`cut -d. -f1-3 <<<"$OPENSTACK_OAM_NETWORK_CIDR"` |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 87 | # MSO post install steps to encrypt openstack password |
| 88 | MSO_ENCRYPTION_KEY=$(cat /config-init/$NAMESPACE/mso/mso/encryption.key) |
BorislavG | 317f2d5 | 2017-11-22 14:02:09 +0200 | [diff] [blame] | 89 | 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] | 90 | |
yuryn | ebdbbd2 | 2017-11-28 01:17:36 +0200 | [diff] [blame] | 91 | echo "Substituting configuration parameters" |
| 92 | |
| 93 | # replace the default 'onap' namespace qualification of K8s hostnames within the config files |
| 94 | SED_NS_PATHS="/config-init/$NAMESPACE/" |
| 95 | SED_NS_STRINGS=( |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 96 | "s/\.namespace-placeholder/\.${NAMESPACE}/g" |
| 97 | "s/kubectl -n namespace-placeholder/kubectl -n ${NAMESPACE}/g" |
yuryn | ebdbbd2 | 2017-11-28 01:17:36 +0200 | [diff] [blame] | 98 | ) |
| 99 | SED_NS_STRING=$(concat_array "${SED_NS_STRINGS[@]}") |
| 100 | find $SED_NS_PATHS -type f -exec sed -i -e "${SED_NS_STRING}" {} \; |
| 101 | |
| 102 | # set variable parameters |
| 103 | # ATTENTION: the list of the paths must be verified if more parameters are added! |
| 104 | SED_CONFIG_PATHS="/config-init/$NAMESPACE/robot/ /config-init/$NAMESPACE/mso/" |
| 105 | SED_CONFIG_STRINGS=( \ |
| 106 | "s/UBUNTU_14_IMAGE_NAME_HERE/${OPENSTACK_UBUNTU_14_IMAGE}/g" \ |
| 107 | "s/OPENSTACK_PUBLIC_NET_ID_HERE/${OPENSTACK_PUBLIC_NET_ID}/g" \ |
| 108 | "s/OPENSTACK_NETWORK_ID_WITH_ONAP_ROUTE_HERE/${OPENSTACK_OAM_NETWORK_ID}/g" \ |
| 109 | "s/OPENSTACK_SUBNET_ID_WITH_ONAP_ROUTE_HERE/${OPENSTACK_OAM_SUBNET_ID}/g" \ |
| 110 | "s,NETWORK_CIDR_WITH_ONAP_ROUTE_HERE,${OPENSTACK_OAM_NETWORK_CIDR},g" \ |
| 111 | "s/OPENSTACK_USERNAME_HERE/${OPENSTACK_USERNAME}/g" \ |
| 112 | "s/OPENSTACK_TENANT_ID_HERE/${OPENSTACK_TENANT_ID}/g" \ |
| 113 | "s/OPENSTACK_PASSWORD_HERE/${OPENSTACK_API_KEY}/g" \ |
| 114 | "s/OPENSTACK_REGION_HERE/${OPENSTACK_REGION}/g" \ |
| 115 | "s,OPENSTACK_KEYSTONE_IP_HERE,${OPENSTACK_KEYSTONE_URL},g" \ |
| 116 | "s/OPENSTACK_FLAVOUR_MEDIUM_HERE/${OPENSTACK_FLAVOUR_MEDIUM}/g" \ |
| 117 | "s/DMAAP_TOPIC_HERE/${DMAAP_TOPIC}/g" \ |
| 118 | "s/OPENSTACK_SERVICE_TENANT_NAME_HERE/${OPENSTACK_SERVICE_TENANT_NAME}/g" \ |
| 119 | "s/DEMO_ARTIFACTS_VERSION_HERE/${DEMO_ARTIFACTS_VERSION}/g" \ |
| 120 | "s/OPENSTACK_OAM_NETWORK_CIDR_PREFIX_HERE/${OPENSTACK_OAM_NETWORK_CIDR_PREFIX}/g" \ |
| 121 | "s/OPENSTACK_ENCRYPTED_PASSWORD_HERE/${OPENSTACK_API_ENCRYPTED_KEY}/g" \ |
| 122 | "s/OPENSTACK_TENANT_NAME_HERE/${OPENSTACK_TENANT_NAME}/g" \ |
| 123 | ) |
| 124 | SED_CONFIG_STRING=$(concat_array "${SED_CONFIG_STRINGS[@]}") |
| 125 | find $SED_CONFIG_PATHS -type f -exec sed -i -e "${SED_CONFIG_STRING}" {} \; |
Mandeep Khinda | dc2dc86 | 2017-09-08 05:20:30 +0000 | [diff] [blame] | 126 | |
Itay Hassid | e2da86d | 2017-08-24 12:54:42 +0000 | [diff] [blame] | 127 | echo "Done!" |