blob: 8f7413995f346d3f9a0b797ec038746692500cc9 [file] [log] [blame]
vaibhavjayasea9aee02018-08-31 06:22:26 +00001# Copyright © 2018 Amdocs, Bell Canada
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Gary Wubf7f1592018-09-14 10:29:27 -070015#!/bin/bash
Mandeep Khindad6ea9872017-06-24 11:49:37 -040016
17#
18# Execute tags built to support the hands on demo,
19#
20function usage
21{
BorislavG8bfc6cf2018-02-27 15:04:26 +000022 echo "Usage: demo.sh namespace <command> [<parameters>]"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040023 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000024 echo " demo.sh <namespace> init"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040025 echo " - Execute both init_customer + distribute"
26 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000027 echo " demo.sh <namespace> init_customer"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040028 echo " - Create demo customer (Demonstration) and services, etc."
29 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000030 echo " demo.sh <namespace> distribute [<prefix>]"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040031 echo " - Distribute demo models (demoVFW and demoVLB)"
32 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000033 echo " demo.sh <namespace> preload <vnf_name> <module_name>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040034 echo " - Preload data for VNF for the <module_name>"
35 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000036 echo " demo.sh <namespace> appc <module_name>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040037 echo " - provide APPC with vFW module mount point for closed loop"
38 echo " "
Mandeep Khinda7ea563e2018-04-17 03:26:26 +000039 echo " demo.sh <namespace> init_robot [ <etc_hosts_prefix> ]"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040040 echo " - Initialize robot after all ONAP VMs have started"
41 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000042 echo " demo.sh <namespace> instantiateVFW"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040043 echo " - Instantiate vFW module for the a demo customer (DemoCust<uuid>)"
44 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000045 echo " demo.sh <namespace> deleteVNF <module_name from instantiateVFW>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040046 echo " - Delete the module created by instantiateVFW"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -050047 echo " "
Marco Plataniaff0b6cb2018-10-29 17:27:15 -040048 echo " demo.sh <namespace> heatbridge <stack_name> <service_instance_id> <service> <oam-ip-address>"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -050049 echo " - Run heatbridge against the stack for the given service instance and service"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040050}
51
52# Set the defaults
Brian Freeman27066302018-04-23 17:24:35 -050053
54echo "Number of parameters:"
55echo $#
56
57if [ $# -lt 2 ];then
Mandeep Khindad6ea9872017-06-24 11:49:37 -040058 usage
59 exit
60fi
BorislavG8bfc6cf2018-02-27 15:04:26 +000061
62NAMESPACE=$1
63shift
64
Mandeep Khindad6ea9872017-06-24 11:49:37 -040065##
66## if more than 1 tag is supplied, the must be provided with -i or -e
67##
Brian Freeman27066302018-04-23 17:24:35 -050068while [ $# -gt 0 ]
Mandeep Khindad6ea9872017-06-24 11:49:37 -040069do
Brian Freeman27066302018-04-23 17:24:35 -050070 key="$1"
71 echo "KEY:"
72 echo $key
Mandeep Khindad6ea9872017-06-24 11:49:37 -040073
74 case $key in
75 init_robot)
76 TAG="UpdateWebPage"
77 read -s -p "WEB Site Password for user 'test': " WEB_PASSWORD
78 if [ "$WEB_PASSWORD" = "" ]; then
79 echo ""
80 echo "WEB Password is required for user 'test'"
81 exit
82 fi
83 VARIABLES="$VARIABLES -v WEB_PASSWORD:$WEB_PASSWORD"
84 shift
Mandeep Khinda7ea563e2018-04-17 03:26:26 +000085 if [ $# -eq 2 ];then
Brian Freeman7e13acc2018-05-15 17:49:50 -050086 VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1"
Mandeep Khinda7ea563e2018-04-17 03:26:26 +000087 fi
88 shift
Mandeep Khindad6ea9872017-06-24 11:49:37 -040089 ;;
90 init)
91 TAG="InitDemo"
92 shift
93 ;;
94 init_customer)
95 TAG="InitCustomer"
96 shift
97 ;;
98 distribute)
99 TAG="InitDistribution"
100 shift
Mandeep Khindac00c6872017-10-26 17:46:43 +0000101 if [ $# -eq 1 ];then
Brian Freeman7e13acc2018-05-15 17:49:50 -0500102 VARIABLES="$VARIABLES -v DEMO_PREFIX:$1"
Mandeep Khindac00c6872017-10-26 17:46:43 +0000103 fi
104 shift
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400105 ;;
106 preload)
107 TAG="PreloadDemo"
108 shift
109 if [ $# -ne 2 ];then
Brian Freeman7e13acc2018-05-15 17:49:50 -0500110 echo "Usage: demo.sh <namespace> preload <vnf_name> <module_name>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400111 exit
112 fi
Brian Freeman7e13acc2018-05-15 17:49:50 -0500113 VARIABLES="$VARIABLES -v VNF_NAME:$1"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400114 shift
Brian Freeman7e13acc2018-05-15 17:49:50 -0500115 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400116 shift
117 ;;
118 appc)
Brian Freeman7e13acc2018-05-15 17:49:50 -0500119 TAG="APPCMountPointDemo"
120 shift
121 if [ $# -ne 1 ];then
122 echo "Usage: demo.sh <namespace> appc <module_name>"
123 exit
124 fi
125 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
126 shift
127 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400128 instantiateVFW)
129 TAG="instantiateVFW"
130 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
131 shift
132 ;;
133 deleteVNF)
134 TAG="deleteVNF"
135 shift
136 if [ $# -ne 1 ];then
Brian Freeman7e13acc2018-05-15 17:49:50 -0500137 echo "Usage: demo.sh <namespace> deleteVNF <module_name from instantiateVFW>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400138 exit
139 fi
Brian Freeman7e13acc2018-05-15 17:49:50 -0500140 VARFILE=$1.py
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400141 if [ -e /opt/eteshare/${VARFILE} ]; then
142 VARIABLES="$VARIABLES -V /share/${VARFILE}"
143 else
144 echo "Cache file ${VARFILE} is not found"
145 exit
146 fi
Mandeep Khinda7ea563e2018-04-17 03:26:26 +0000147 shift
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500148 ;;
149 heatbridge)
150 TAG="heatbridge"
151 shift
Marco Plataniaff0b6cb2018-10-29 17:27:15 -0400152 if [ $# -ne 4 ];then
153 echo "Usage: demo.sh <namespace> heatbridge <stack_name> <service_instance_id> <service> <oam-ip-address>"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500154 exit
155 fi
Brian Freeman7e13acc2018-05-15 17:49:50 -0500156 VARIABLES="$VARIABLES -v HB_STACK:$1"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500157 shift
Brian Freeman7e13acc2018-05-15 17:49:50 -0500158 VARIABLES="$VARIABLES -v HB_SERVICE_INSTANCE_ID:$1"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500159 shift
Brian Freeman7e13acc2018-05-15 17:49:50 -0500160 VARIABLES="$VARIABLES -v HB_SERVICE:$1"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400161 shift
Marco Plataniaff0b6cb2018-10-29 17:27:15 -0400162 VARIABLES="$VARIABLES -v HB_IPV4_OAM_ADDRESS:$1"
163 shift
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400164 ;;
Yang Xue951fd22018-10-28 11:47:13 -0400165 cds)
166 TAG="cds"
167 shift
168 ;;
Yang Xu37eedd12018-11-01 12:56:55 -0400169 distributeVFWNG)
170 TAG="distributeVFWNG"
171 shift
172 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400173 *)
174 usage
175 exit
176 esac
177done
178
Gary Wubf7f1592018-09-14 10:29:27 -0700179set -x
180
BorislavG8bfc6cf2018-02-27 15:04:26 +0000181POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
Gary Wu4ec2c672018-11-01 11:57:27 -0700182
183ETEHOME=/var/opt/OpenECOMP_ETE
184
185export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l")
186OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key
187DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90))
188
189VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py -V /share/config/integration_preload_parameters.py"
190
191kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} -i ${TAG} --display $DISPLAY_NUM 2> ${TAG}.out
192