3 # Copyright 2018 Huawei Technologies Co., Ltd.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
15 if [ -z "$WORKSPACE" ]; then
16 export WORKSPACE=`git rev-parse --show-toplevel`
20 echo "Usage: $0 [ -n <number of VMs {2-15}> ][ -s <stack name> ][ -m <manifest> ][ -r ][ -q ] <env>" 1>&2;
22 echo "n: Set the number of VM's that will be installed. This number must be between 2 and 15" 1>&2;
23 echo "s: Set the name to be used for stack. This name will be used for naming of resources" 1>&2;
24 echo "m: The docker manifest to apply; must be either \"docker-manifest-staging.csv\" or \"docker-manifest.csv\"." 1>&2;
25 echo "r: Delete all resources relating to ONAP within enviroment." 1>&2;
26 echo "q: Quiet Delete of all ONAP resources." 1>&2;
32 while getopts ":n:s:m:rq" o; do
35 if [[ ${OPTARG} =~ ^[0-9]+$ ]];then
36 if [ ${OPTARG} -ge 2 -a ${OPTARG} -le 15 ]; then
46 if [[ ! ${OPTARG} =~ ^[0-9]+$ ]];then
53 if [ -f $WORKSPACE/version-manifest/src/main/resources/${OPTARG} ]; then
54 docker_manifest=${OPTARG}
60 echo "The following command will delete all information relating to onap within your enviroment"
61 read -p "Are you certain this is what you want? (type y to confirm):" answer
63 if [ $answer = "y" ] || [ $answer = "Y" ] || [ $answer = "yes" ] || [ $answer = "Yes"]; then
64 echo "This may delete the work of other colleages within the same enviroment"
65 read -p "Are you certain this is what you want? (type y to confirm):" answer2
67 if [ $answer2 = "y" ] || [ $answer2 = "Y" ] || [ $answer2 = "yes" ] || [ $answer2 = "Yes"]; then
88 if [ "$#" -ne 1 ]; then
94 if [ ! -f $ENV_FILE ];then
95 echo ENV file does not exist or was not given
101 SSH_KEY=~/.ssh/onap_key
103 source $WORKSPACE/test/ete/scripts/install_openstack_cli.sh
105 SO_ENCRYPTION_KEY=aa3871669d893c7fb8abbcda31b88b4f
106 export OS_PASSWORD_ENCRYPTED=$(echo -n "$OS_PASSWORD" | openssl aes-128-ecb -e -K "$SO_ENCRYPTION_KEY" -nosalt | xxd -c 256 -p)
108 for n in $(seq 1 5); do
109 if [ $full_deletion = true ] ; then
110 $WORKSPACE/test/ete/scripts/teardown-onap.sh -n $stack_name -q
112 $WORKSPACE/test/ete/scripts/teardown-onap.sh -n $stack_name
115 cd $WORKSPACE/deployment/heat/onap-oom
116 envsubst < $ENV_FILE > $ENV_FILE~
117 if [ -z "$vm_num" ]; then
118 cp onap-oom.yaml onap-oom.yaml~
120 ./scripts/gen-onap-oom-yaml.sh $vm_num > onap-oom.yaml~
123 if ! openstack stack create -t ./onap-oom.yaml~ -e $ENV_FILE~ $stack_name --parameter docker_manifest=$docker_manifest; then
127 while [ "CREATE_IN_PROGRESS" == "$(openstack stack show -c stack_status -f value $stack_name)" ]; do
131 STATUS=$(openstack stack show -c stack_status -f value $stack_name)
133 if [ "CREATE_COMPLETE" != "$STATUS" ]; then
137 for i in $(seq 1 30); do
139 RANCHER_IP=$(openstack stack output show $stack_name rancher_vm_ip -c output_value -f value)
140 K8S_IP=$(openstack stack output show $stack_name k8s_01_vm_ip -c output_value -f value)
141 timeout 1 ping -c 1 "$RANCHER_IP" && break
144 timeout 1 ping -c 1 "$RANCHER_IP" && break
146 echo Error: OpenStack infrastructure issue: unable to reach rancher "$RANCHER_IP"
150 if ! timeout 1 ping -c 1 "$RANCHER_IP"; then
154 ssh-keygen -R $RANCHER_IP
157 ssh -o StrictHostKeychecking=no -i $SSH_KEY ubuntu@$RANCHER_IP "sed -u '/Cloud-init.*finished/q' <(tail -n+0 -f /var/log/cloud-init-output.log)"
160 for n in $(seq 1 20); do
161 RESULT=$(ssh -i $SSH_KEY ubuntu@$RANCHER_IP 'sudo su -c "kubectl -n onap get pods"' | grep -vE 'Running|Complete|NAME' | wc -l)
162 if [[ $? -eq 0 && ( $RESULT -eq 0 || $RESULT -eq $PREV_RESULT ) ]]; then
170 for n in $(seq 1 20); do
171 echo "Wait for HEALTHCHECK count $n of 10"
172 ROBOT_POD=$(ssh -i $SSH_KEY ubuntu@$RANCHER_IP 'sudo su -c "kubectl --namespace onap get pods"' | grep robot | sed 's/ .*//')
173 ssh -i $SSH_KEY ubuntu@$RANCHER_IP 'sudo su -l root -c "/root/oom/kubernetes/robot/ete-k8s.sh onap health"'
175 if [[ $RESULT -lt 10 && ( $RESULT -eq 0 || $RESULT -eq $PREV_RESULT ) ]]; then
181 if [ "$ROBOT_POD" == "" ]; then
185 LOG_DIR=$(echo "kubectl exec -n onap $ROBOT_POD -- ls -1t /share/logs | grep health | head -1" | ssh -i $SSH_KEY ubuntu@$RANCHER_IP sudo su)
186 echo "kubectl cp -n onap $ROBOT_POD:share/logs/$LOG_DIR /tmp/robot/logs/$LOG_DIR" | ssh -i $SSH_KEY ubuntu@$RANCHER_IP sudo su
187 echo "Browse Robot results at http://$K8S_IP:30209/logs/$LOG_DIR/"
188 mkdir -p $WORKSPACE/archives/healthcheck
189 rsync -e "ssh -i $SSH_KEY" -avtz ubuntu@$RANCHER_IP:/tmp/robot/logs/$LOG_DIR/ $WORKSPACE/archives/healthcheck