stark, steven | 6754bc1 | 2019-09-19 15:43:00 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # Copyright 2019 AT&T Intellectual Property. All rights reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
| 17 | |
| 18 | BUILD_DIR=$1 |
| 19 | OPENSTACK_CLI_POD=$2 |
| 20 | OPENSTACK_RC=$3 |
| 21 | DOCKER_REPOSITORY=$4 |
| 22 | NFS_IP_ADDR=$5 |
| 23 | K8S_01_VM_IP=$6 |
| 24 | KUBECONFIG=$7 |
| 25 | |
| 26 | . $OPENSTACK_RC |
| 27 | |
| 28 | export KUBECONFIG=$KUBECONFIG |
| 29 | |
| 30 | git clone https://gerrit.onap.org/r/integration "$BUILD_DIR/integration" |
| 31 | |
| 32 | echo "" |
| 33 | echo "Looping until openstack is ready." |
| 34 | echo "This can take a bit of time, and you might see errors initially if openstack is still launching." |
| 35 | echo "" |
| 36 | echo "" |
| 37 | # Need to wait until openstack is up and running |
| 38 | COUNTER=0 |
| 39 | kubectl exec $OPENSTACK_CLI_POD -- sh -lc "openstack token issue" |
| 40 | until [ $? -eq 0 ] || [ $COUNTER -gt 60 ]; do |
| 41 | COUNTER=$((COUNTER +1)) |
| 42 | sleep 60 |
| 43 | echo "issuing auth token to openstack to verify openstack cli is up and running." |
| 44 | kubectl exec $OPENSTACK_CLI_POD -- sh -lc "openstack token issue" |
| 45 | done |
| 46 | |
| 47 | if [ $? -ne 0 ]; then |
| 48 | echo "Unable to communicate with openstack to create the integration-override.yaml file" |
| 49 | exit 1 |
| 50 | fi |
| 51 | |
| 52 | OS_PUBLIC_NETWORK_ID=`kubectl exec $OPENSTACK_CLI_POD -- sh -lc "openstack network show public -c id -f value"` |
| 53 | OS_OAM_NETWORK_ID=`kubectl exec $OPENSTACK_CLI_POD -- sh -lc "openstack network show private -c id -f value"` |
| 54 | OS_OAM_NETWORK_SUBNET_ID=`kubectl exec $OPENSTACK_CLI_POD -- sh -lc "openstack subnet show private-subnet -c id -f value"` |
| 55 | OS_SEC_GROUP=`kubectl exec $OPENSTACK_CLI_POD -- sh -lc "openstack security group list --project $OS_PROJECT_NAME -c ID -f value"` |
| 56 | OS_OAM_NETWORK_CIDR=`kubectl exec $OPENSTACK_CLI_POD -- sh -lc "openstack subnet show public-subnet -c cidr -f value"` |
| 57 | OS_OAM_NETWORK_PREFIX=`echo $OS_OAM_NETWORK_CIDR | cut -d '.' -f1-2` |
| 58 | |
| 59 | echo "export OS_PUBLIC_NETWORK_ID=$OS_PUBLIC_NETWORK_ID" > "$BUILD_DIR/openstack_params.conf" |
| 60 | echo "export DOCKER_REPOSITORY=$DOCKER_REPOSITORY" >> "$BUILD_DIR/openstack_params.conf" |
| 61 | echo "export OS_OAM_NETWORK_ID=$OS_OAM_NETWORK_ID" >> "$BUILD_DIR/openstack_params.conf" |
| 62 | echo "export OS_OAM_NETWORK_SUBNET_ID=$OS_OAM_NETWORK_SUBNET_ID" >> "$BUILD_DIR/openstack_params.conf" |
| 63 | echo "export OS_OAM_NETWORK_PREFIX=$OS_OAM_NETWORK_PREFIX" >> "$BUILD_DIR/openstack_params.conf" |
| 64 | echo "export OS_SEC_GROUP=$OS_SEC_GROUP" >> "$BUILD_DIR/openstack_params.conf" |
| 65 | echo "export OS_UBUNTU_14_IMAGE=trusty-server-cloudimg-amd64-disk1" >> "$BUILD_DIR/openstack_params.conf" |
| 66 | echo "export OS_UBUNTU_16_IMAGE=xenial-server-cloudimg-amd64-disk1" >> "$BUILD_DIR/openstack_params.conf" |
| 67 | echo "export OS_OAM_NETWORK_CIDR=$OS_OAM_NETWORK_CIDR" >> "$BUILD_DIR/openstack_params.conf" |
| 68 | echo "export NFS_IP_ADDR=$NFS_IP_ADDR" >> "$BUILD_DIR/openstack_params.conf" |
| 69 | echo "export K8S_01_VM_IP=$K8S_01_VM_IP" >> "$BUILD_DIR/openstack_params.conf" |
| 70 | |
| 71 | OS_PROJECT_ID=`kubectl exec $OPENSTACK_CLI_POD -- sh -lc "openstack project show $OS_PROJECT_NAME -c id -f value"` |
| 72 | |
| 73 | echo "export OS_PROJECT_ID=$OS_PROJECT_ID" >> "$OPENSTACK_RC" |
| 74 | |
| 75 | $DIR/create_robot_config.sh "$OPENSTACK_RC" "$BUILD_DIR/openstack_params.conf" "$BUILD_DIR" "$DIR/integration_override.template" |