Ievgeniia Zadorozhna | 3a6f9e2 | 2023-05-12 18:31:28 +0300 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | FLAVOR='cvp.high' |
| 4 | IMAGE='cvp.ubuntu.2004' |
| 5 | EXT_NET='public' |
| 6 | DNS_SERVERS='[]' # example of the custom value: DNS_SERVERS='["192.168.129.5", "192.168.129.254"]' |
| 7 | APP_DOCKER_IMAGE='mirantis.azurecr.io/openstack/openstack-refapp:0.1.2' # you can replace with some local copy for offline cloud |
| 8 | |
| 9 | REFAPP_PATH=/opt/density/openstack-refapp/ |
| 10 | |
| 11 | # Check the private CVP key, convert to the public one |
| 12 | cvp_private_key=/opt/cmp-check/cvp_testkey |
| 13 | if [ -e ${cvp_private_key} ]; then |
| 14 | ssh-keygen -y -f ${cvp_private_key} > ${REFAPP_PATH}/cvp_testkey.pub |
| 15 | else |
| 16 | echo "The key file at ${cvp_private_key} does not exist. Please run \"cd /opt/cmp-check && bash /opt/cmp-check/prepare.sh -w $(pwd) && cd ${REFAPP_PATH}\" to create a key and other test resources." |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
| 20 | TOP_FILE=${REFAPP_PATH}/heat-templates/top.yaml |
| 21 | |
| 22 | # Replace the default public key with the CVP one |
| 23 | cvp_key=$(cat ${REFAPP_PATH}/cvp_testkey.pub) |
| 24 | escaped_cvp_key=$(echo "$cvp_key" | sed -e 's/[\/&]/\\&/g') |
| 25 | sed -i "/^ *cluster_public_key:/,/default:/ s/default:.*/default: '$escaped_cvp_key'/" $TOP_FILE |
| 26 | |
| 27 | # Replace the flavor |
| 28 | sed -i "/^ *database_flavor:/,/default:/ s/default:.*/default: '$FLAVOR'/" $TOP_FILE |
| 29 | |
| 30 | # Replace the image |
| 31 | sed -i "/^ *database_image:/,/default:/ s/default:.*/default: '$IMAGE'/" $TOP_FILE |
| 32 | |
| 33 | # Replace the external net |
| 34 | sed -i "/^ *public_network_id:/,/default:/ s/default:.*/default: '$EXT_NET'/" $TOP_FILE |
| 35 | |
| 36 | # Replace the DNS servers list |
| 37 | sed -i "/^ *dns_nameservers:/,/default:/ s/default:.*/default: $DNS_SERVERS/" $TOP_FILE |
| 38 | |
| 39 | # Replace the docker image for RefApp application if the cloud has no Internet access |
| 40 | ESC_APP_DOCKER_IMAGE=$(sed 's/[\/&]/\\&/g' <<< "$APP_DOCKER_IMAGE") |
| 41 | sed -i "/^\s*app_docker_image:/,/default:/ s/default:.*/default: '$ESC_APP_DOCKER_IMAGE'/" $TOP_FILE |