blob: 31b86436f0c59b2e3823769348cfa3306e637253 [file] [log] [blame]
Gary Wu9d5abb42018-11-02 13:48:21 -07001#!/bin/bash
2# Copyright (C) 2018 Amdocs, Bell Canada
kaihlavi78e7f392019-04-16 14:53:04 +03003# Modifications Copyright (C) 2019 Samsung
vaibhavjayasea9aee02018-08-31 06:22:26 +00004#
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
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
Mandeep Khindad6ea9872017-06-24 11:49:37 -040016#
kaihlavi78e7f392019-04-16 14:53:04 +030017# Execute tags built to support the hands-on demo
Mandeep Khindad6ea9872017-06-24 11:49:37 -040018#
19function usage
20{
kaihlavi78e7f392019-04-16 14:53:04 +030021 echo "Usage: demo-k8s.sh <namespace> <command> [<parameters>]"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040022 echo " "
kaihlavi78e7f392019-04-16 14:53:04 +030023 echo " demo-k8s.sh <namespace> init"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040024 echo " - Execute both init_customer + distribute"
25 echo " "
kaihlavi78e7f392019-04-16 14:53:04 +030026 echo " demo-k8s.sh <namespace> init_customer"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040027 echo " - Create demo customer (Demonstration) and services, etc."
28 echo " "
kaihlavi78e7f392019-04-16 14:53:04 +030029 echo " demo-k8s.sh <namespace> distribute [<prefix>]"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040030 echo " - Distribute demo models (demoVFW and demoVLB)"
31 echo " "
kaihlavi78e7f392019-04-16 14:53:04 +030032 echo " demo-k8s.sh <namespace> preload <vnf_name> <module_name>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040033 echo " - Preload data for VNF for the <module_name>"
34 echo " "
kaihlavi78e7f392019-04-16 14:53:04 +030035 echo " demo-k8s.sh <namespace> appc <module_name>"
36 echo " - provide APPC with vFW module mount point for closed loop"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040037 echo " "
kaihlavi78e7f392019-04-16 14:53:04 +030038 echo " demo-k8s.sh <namespace> init_robot [ <etc_hosts_prefix> ]"
39 echo " - Initialize robot after all ONAP VMs have started"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040040 echo " "
kaihlavi78e7f392019-04-16 14:53:04 +030041 echo " demo-k8s.sh <namespace> instantiateVFW"
42 echo " - Instantiate vFW module for the demo customer (DemoCust<uuid>)"
Mandeep Khindad6ea9872017-06-24 11:49:37 -040043 echo " "
kaihlavi78e7f392019-04-16 14:53:04 +030044 echo " demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>"
45 echo " - Delete the module created by instantiateVFW"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -050046 echo " "
kaihlavi78e7f392019-04-16 14:53:04 +030047 echo " demo-k8s.sh <namespace> heatbridge <stack_name> <service_instance_id> <service> <oam-ip-address>"
48 echo " - Run heatbridge against the stack for the given service instance and service"
Gary Wu9d5abb42018-11-02 13:48:21 -070049 echo " "
kaihlavi78e7f392019-04-16 14:53:04 +030050 echo " demo-k8s.sh <namespace> vfwclosedloop <pgn-ip-address>"
Gary Wu9d5abb42018-11-02 13:48:21 -070051 echo " - vFWCL: Sets the packet generator to high and low rates, and checks whether the policy "
52 echo " kicks in to modulate the rates back to medium"
53 echo " "
Mandeep Khindad6ea9872017-06-24 11:49:37 -040054}
55
56# Set the defaults
Brian Freeman27066302018-04-23 17:24:35 -050057
58echo "Number of parameters:"
59echo $#
60
61if [ $# -lt 2 ];then
Mandeep Khindad6ea9872017-06-24 11:49:37 -040062 usage
63 exit
64fi
BorislavG8bfc6cf2018-02-27 15:04:26 +000065
66NAMESPACE=$1
67shift
68
Mandeep Khindad6ea9872017-06-24 11:49:37 -040069##
70## if more than 1 tag is supplied, the must be provided with -i or -e
71##
Brian Freeman27066302018-04-23 17:24:35 -050072while [ $# -gt 0 ]
Mandeep Khindad6ea9872017-06-24 11:49:37 -040073do
Brian Freeman27066302018-04-23 17:24:35 -050074 key="$1"
75 echo "KEY:"
76 echo $key
Mandeep Khindad6ea9872017-06-24 11:49:37 -040077
78 case $key in
79 init_robot)
80 TAG="UpdateWebPage"
81 read -s -p "WEB Site Password for user 'test': " WEB_PASSWORD
82 if [ "$WEB_PASSWORD" = "" ]; then
83 echo ""
84 echo "WEB Password is required for user 'test'"
85 exit
86 fi
87 VARIABLES="$VARIABLES -v WEB_PASSWORD:$WEB_PASSWORD"
88 shift
Mandeep Khinda7ea563e2018-04-17 03:26:26 +000089 if [ $# -eq 2 ];then
Brian Freeman7e13acc2018-05-15 17:49:50 -050090 VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1"
Mandeep Khinda7ea563e2018-04-17 03:26:26 +000091 fi
92 shift
Mandeep Khindad6ea9872017-06-24 11:49:37 -040093 ;;
94 init)
95 TAG="InitDemo"
96 shift
97 ;;
98 init_customer)
99 TAG="InitCustomer"
100 shift
101 ;;
102 distribute)
103 TAG="InitDistribution"
104 shift
Mandeep Khindac00c6872017-10-26 17:46:43 +0000105 if [ $# -eq 1 ];then
Brian Freeman7e13acc2018-05-15 17:49:50 -0500106 VARIABLES="$VARIABLES -v DEMO_PREFIX:$1"
Mandeep Khindac00c6872017-10-26 17:46:43 +0000107 fi
108 shift
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400109 ;;
110 preload)
111 TAG="PreloadDemo"
112 shift
113 if [ $# -ne 2 ];then
kaihlavi78e7f392019-04-16 14:53:04 +0300114 echo "Usage: demo-k8s.sh <namespace> preload <vnf_name> <module_name>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400115 exit
116 fi
Brian Freeman7e13acc2018-05-15 17:49:50 -0500117 VARIABLES="$VARIABLES -v VNF_NAME:$1"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400118 shift
Brian Freeman7e13acc2018-05-15 17:49:50 -0500119 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400120 shift
121 ;;
122 appc)
Brian Freeman7e13acc2018-05-15 17:49:50 -0500123 TAG="APPCMountPointDemo"
124 shift
125 if [ $# -ne 1 ];then
kaihlavi78e7f392019-04-16 14:53:04 +0300126 echo "Usage: demo-k8s.sh <namespace> appc <module_name>"
Brian Freeman7e13acc2018-05-15 17:49:50 -0500127 exit
128 fi
129 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
130 shift
131 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400132 instantiateVFW)
133 TAG="instantiateVFW"
134 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
135 shift
136 ;;
137 deleteVNF)
138 TAG="deleteVNF"
139 shift
140 if [ $# -ne 1 ];then
kaihlavi78e7f392019-04-16 14:53:04 +0300141 echo "Usage: demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400142 exit
143 fi
Brian Freeman7e13acc2018-05-15 17:49:50 -0500144 VARFILE=$1.py
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400145 if [ -e /opt/eteshare/${VARFILE} ]; then
146 VARIABLES="$VARIABLES -V /share/${VARFILE}"
147 else
148 echo "Cache file ${VARFILE} is not found"
149 exit
150 fi
Mandeep Khinda7ea563e2018-04-17 03:26:26 +0000151 shift
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500152 ;;
153 heatbridge)
154 TAG="heatbridge"
155 shift
Marco Plataniaff0b6cb2018-10-29 17:27:15 -0400156 if [ $# -ne 4 ];then
kaihlavi78e7f392019-04-16 14:53:04 +0300157 echo "Usage: demo-k8s.sh <namespace> heatbridge <stack_name> <service_instance_id> <service> <oam-ip-address>"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500158 exit
159 fi
Brian Freeman7e13acc2018-05-15 17:49:50 -0500160 VARIABLES="$VARIABLES -v HB_STACK:$1"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500161 shift
Brian Freeman7e13acc2018-05-15 17:49:50 -0500162 VARIABLES="$VARIABLES -v HB_SERVICE_INSTANCE_ID:$1"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500163 shift
Brian Freeman7e13acc2018-05-15 17:49:50 -0500164 VARIABLES="$VARIABLES -v HB_SERVICE:$1"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400165 shift
Marco Plataniaff0b6cb2018-10-29 17:27:15 -0400166 VARIABLES="$VARIABLES -v HB_IPV4_OAM_ADDRESS:$1"
167 shift
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400168 ;;
Yang Xue951fd22018-10-28 11:47:13 -0400169 cds)
170 TAG="cds"
171 shift
172 ;;
Yang Xu37eedd12018-11-01 12:56:55 -0400173 distributeVFWNG)
174 TAG="distributeVFWNG"
175 shift
176 ;;
Brian Freemanab7c1742019-02-13 18:05:02 -0500177 distributeDemoVFWDT)
178 TAG="DistributeDemoVFWDT"
179 shift
180 ;;
181 instantiateDemoVFWDT)
182 TAG="instantiateVFWDT"
183 shift
184 ;;
Gary Wu9d5abb42018-11-02 13:48:21 -0700185 vfwclosedloop)
186 TAG="vfwclosedloop"
187 shift
188 VARIABLES="$VARIABLES -v pkg_host:$1"
189 shift
190 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400191 *)
192 usage
193 exit
194 esac
195done
196
Gary Wubf7f1592018-09-14 10:29:27 -0700197set -x
198
BorislavG8bfc6cf2018-02-27 15:04:26 +0000199POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
Gary Wu4ec2c672018-11-01 11:57:27 -0700200
Brian Freemanab7c1742019-02-13 18:05:02 -0500201ETEHOME=/var/opt/ONAP
Gary Wu4ec2c672018-11-01 11:57:27 -0700202
203export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l")
204OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key
205DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90))
206
207VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py -V /share/config/integration_preload_parameters.py"
208
209kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} -i ${TAG} --display $DISPLAY_NUM 2> ${TAG}.out
210