blob: 11d41a37b2471e113b2c4b2510655b52f2f40737 [file] [log] [blame]
Gary Wu9d5abb42018-11-02 13:48:21 -07001#!/bin/bash
2# Copyright (C) 2018 Amdocs, Bell Canada
vaibhavjayasea9aee02018-08-31 06:22:26 +00003#
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.
Mandeep Khindad6ea9872017-06-24 11:49:37 -040015#
16# Execute tags built to support the hands on demo,
17#
18function usage
19{
BorislavG8bfc6cf2018-02-27 15:04:26 +000020 echo "Usage: demo.sh namespace <command> [<parameters>]"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040021 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000022 echo " demo.sh <namespace> init"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040023 echo " - Execute both init_customer + distribute"
24 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000025 echo " demo.sh <namespace> init_customer"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040026 echo " - Create demo customer (Demonstration) and services, etc."
27 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000028 echo " demo.sh <namespace> distribute [<prefix>]"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040029 echo " - Distribute demo models (demoVFW and demoVLB)"
30 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000031 echo " demo.sh <namespace> preload <vnf_name> <module_name>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040032 echo " - Preload data for VNF for the <module_name>"
33 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000034 echo " demo.sh <namespace> appc <module_name>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040035 echo " - provide APPC with vFW module mount point for closed loop"
36 echo " "
Mandeep Khinda7ea563e2018-04-17 03:26:26 +000037 echo " demo.sh <namespace> init_robot [ <etc_hosts_prefix> ]"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040038 echo " - Initialize robot after all ONAP VMs have started"
39 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000040 echo " demo.sh <namespace> instantiateVFW"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040041 echo " - Instantiate vFW module for the a demo customer (DemoCust<uuid>)"
42 echo " "
BorislavG8bfc6cf2018-02-27 15:04:26 +000043 echo " demo.sh <namespace> deleteVNF <module_name from instantiateVFW>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040044 echo " - Delete the module created by instantiateVFW"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -050045 echo " "
Marco Plataniaff0b6cb2018-10-29 17:27:15 -040046 echo " demo.sh <namespace> heatbridge <stack_name> <service_instance_id> <service> <oam-ip-address>"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -050047 echo " - Run heatbridge against the stack for the given service instance and service"
Gary Wu9d5abb42018-11-02 13:48:21 -070048 echo " "
49 echo " demo.sh <namespace> vfwclosedloop <pgn-ip-address>"
50 echo " - vFWCL: Sets the packet generator to high and low rates, and checks whether the policy "
51 echo " kicks in to modulate the rates back to medium"
52 echo " "
Mandeep Khindad6ea9872017-06-24 11:49:37 -040053}
54
55# Set the defaults
Brian Freeman27066302018-04-23 17:24:35 -050056
57echo "Number of parameters:"
58echo $#
59
60if [ $# -lt 2 ];then
Mandeep Khindad6ea9872017-06-24 11:49:37 -040061 usage
62 exit
63fi
BorislavG8bfc6cf2018-02-27 15:04:26 +000064
65NAMESPACE=$1
66shift
67
Mandeep Khindad6ea9872017-06-24 11:49:37 -040068##
69## if more than 1 tag is supplied, the must be provided with -i or -e
70##
Brian Freeman27066302018-04-23 17:24:35 -050071while [ $# -gt 0 ]
Mandeep Khindad6ea9872017-06-24 11:49:37 -040072do
Brian Freeman27066302018-04-23 17:24:35 -050073 key="$1"
74 echo "KEY:"
75 echo $key
Mandeep Khindad6ea9872017-06-24 11:49:37 -040076
77 case $key in
78 init_robot)
79 TAG="UpdateWebPage"
80 read -s -p "WEB Site Password for user 'test': " WEB_PASSWORD
81 if [ "$WEB_PASSWORD" = "" ]; then
82 echo ""
83 echo "WEB Password is required for user 'test'"
84 exit
85 fi
86 VARIABLES="$VARIABLES -v WEB_PASSWORD:$WEB_PASSWORD"
87 shift
Mandeep Khinda7ea563e2018-04-17 03:26:26 +000088 if [ $# -eq 2 ];then
Brian Freeman7e13acc2018-05-15 17:49:50 -050089 VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1"
Mandeep Khinda7ea563e2018-04-17 03:26:26 +000090 fi
91 shift
Mandeep Khindad6ea9872017-06-24 11:49:37 -040092 ;;
93 init)
94 TAG="InitDemo"
95 shift
96 ;;
97 init_customer)
98 TAG="InitCustomer"
99 shift
100 ;;
101 distribute)
102 TAG="InitDistribution"
103 shift
Mandeep Khindac00c6872017-10-26 17:46:43 +0000104 if [ $# -eq 1 ];then
Brian Freeman7e13acc2018-05-15 17:49:50 -0500105 VARIABLES="$VARIABLES -v DEMO_PREFIX:$1"
Mandeep Khindac00c6872017-10-26 17:46:43 +0000106 fi
107 shift
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400108 ;;
109 preload)
110 TAG="PreloadDemo"
111 shift
112 if [ $# -ne 2 ];then
Brian Freeman7e13acc2018-05-15 17:49:50 -0500113 echo "Usage: demo.sh <namespace> preload <vnf_name> <module_name>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400114 exit
115 fi
Brian Freeman7e13acc2018-05-15 17:49:50 -0500116 VARIABLES="$VARIABLES -v VNF_NAME:$1"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400117 shift
Brian Freeman7e13acc2018-05-15 17:49:50 -0500118 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400119 shift
120 ;;
121 appc)
Brian Freeman7e13acc2018-05-15 17:49:50 -0500122 TAG="APPCMountPointDemo"
123 shift
124 if [ $# -ne 1 ];then
125 echo "Usage: demo.sh <namespace> appc <module_name>"
126 exit
127 fi
128 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
129 shift
130 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400131 instantiateVFW)
132 TAG="instantiateVFW"
133 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
134 shift
135 ;;
136 deleteVNF)
137 TAG="deleteVNF"
138 shift
139 if [ $# -ne 1 ];then
Brian Freeman7e13acc2018-05-15 17:49:50 -0500140 echo "Usage: demo.sh <namespace> deleteVNF <module_name from instantiateVFW>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400141 exit
142 fi
Brian Freeman7e13acc2018-05-15 17:49:50 -0500143 VARFILE=$1.py
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400144 if [ -e /opt/eteshare/${VARFILE} ]; then
145 VARIABLES="$VARIABLES -V /share/${VARFILE}"
146 else
147 echo "Cache file ${VARFILE} is not found"
148 exit
149 fi
Mandeep Khinda7ea563e2018-04-17 03:26:26 +0000150 shift
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500151 ;;
152 heatbridge)
153 TAG="heatbridge"
154 shift
Marco Plataniaff0b6cb2018-10-29 17:27:15 -0400155 if [ $# -ne 4 ];then
156 echo "Usage: demo.sh <namespace> heatbridge <stack_name> <service_instance_id> <service> <oam-ip-address>"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500157 exit
158 fi
Brian Freeman7e13acc2018-05-15 17:49:50 -0500159 VARIABLES="$VARIABLES -v HB_STACK:$1"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500160 shift
Brian Freeman7e13acc2018-05-15 17:49:50 -0500161 VARIABLES="$VARIABLES -v HB_SERVICE_INSTANCE_ID:$1"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500162 shift
Brian Freeman7e13acc2018-05-15 17:49:50 -0500163 VARIABLES="$VARIABLES -v HB_SERVICE:$1"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400164 shift
Marco Plataniaff0b6cb2018-10-29 17:27:15 -0400165 VARIABLES="$VARIABLES -v HB_IPV4_OAM_ADDRESS:$1"
166 shift
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400167 ;;
Yang Xue951fd22018-10-28 11:47:13 -0400168 cds)
169 TAG="cds"
170 shift
171 ;;
Yang Xu37eedd12018-11-01 12:56:55 -0400172 distributeVFWNG)
173 TAG="distributeVFWNG"
174 shift
175 ;;
Gary Wu9d5abb42018-11-02 13:48:21 -0700176 vfwclosedloop)
177 TAG="vfwclosedloop"
178 shift
179 VARIABLES="$VARIABLES -v pkg_host:$1"
180 shift
181 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400182 *)
183 usage
184 exit
185 esac
186done
187
Gary Wubf7f1592018-09-14 10:29:27 -0700188set -x
189
BorislavG8bfc6cf2018-02-27 15:04:26 +0000190POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
Gary Wu4ec2c672018-11-01 11:57:27 -0700191
192ETEHOME=/var/opt/OpenECOMP_ETE
193
194export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l")
195OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key
196DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90))
197
198VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py -V /share/config/integration_preload_parameters.py"
199
200kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} -i ${TAG} --display $DISPLAY_NUM 2> ${TAG}.out
201