blob: 8b76f64a253e97ab249f7c3fce23ed4d71ea31b9 [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 " "
Brian Freeman46d00ca2019-05-06 12:12:36 -050044 echo " demo-k8s.sh <namespace> instantiateVFWdirectso csar_filename"
45 echo " - Instantiate vFW module using direct SO interface using previously distributed model "
46 echo " that is in /tmp/csar in robot container"
47 echo " "
kaihlavi78e7f392019-04-16 14:53:04 +030048 echo " demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>"
49 echo " - Delete the module created by instantiateVFW"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -050050 echo " "
kaihlavi78e7f392019-04-16 14:53:04 +030051 echo " demo-k8s.sh <namespace> heatbridge <stack_name> <service_instance_id> <service> <oam-ip-address>"
52 echo " - Run heatbridge against the stack for the given service instance and service"
Gary Wu9d5abb42018-11-02 13:48:21 -070053 echo " "
kaihlavi78e7f392019-04-16 14:53:04 +030054 echo " demo-k8s.sh <namespace> vfwclosedloop <pgn-ip-address>"
Gary Wu9d5abb42018-11-02 13:48:21 -070055 echo " - vFWCL: Sets the packet generator to high and low rates, and checks whether the policy "
56 echo " kicks in to modulate the rates back to medium"
57 echo " "
Mandeep Khindad6ea9872017-06-24 11:49:37 -040058}
59
60# Set the defaults
Brian Freeman27066302018-04-23 17:24:35 -050061
62echo "Number of parameters:"
63echo $#
64
65if [ $# -lt 2 ];then
Mandeep Khindad6ea9872017-06-24 11:49:37 -040066 usage
67 exit
68fi
BorislavG8bfc6cf2018-02-27 15:04:26 +000069
70NAMESPACE=$1
71shift
72
Mandeep Khindad6ea9872017-06-24 11:49:37 -040073##
74## if more than 1 tag is supplied, the must be provided with -i or -e
75##
Brian Freeman27066302018-04-23 17:24:35 -050076while [ $# -gt 0 ]
Mandeep Khindad6ea9872017-06-24 11:49:37 -040077do
Brian Freeman27066302018-04-23 17:24:35 -050078 key="$1"
79 echo "KEY:"
80 echo $key
Mandeep Khindad6ea9872017-06-24 11:49:37 -040081
82 case $key in
83 init_robot)
84 TAG="UpdateWebPage"
85 read -s -p "WEB Site Password for user 'test': " WEB_PASSWORD
86 if [ "$WEB_PASSWORD" = "" ]; then
87 echo ""
88 echo "WEB Password is required for user 'test'"
89 exit
90 fi
91 VARIABLES="$VARIABLES -v WEB_PASSWORD:$WEB_PASSWORD"
92 shift
Mandeep Khinda7ea563e2018-04-17 03:26:26 +000093 if [ $# -eq 2 ];then
Brian Freeman7e13acc2018-05-15 17:49:50 -050094 VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1"
Mandeep Khinda7ea563e2018-04-17 03:26:26 +000095 fi
96 shift
Mandeep Khindad6ea9872017-06-24 11:49:37 -040097 ;;
98 init)
99 TAG="InitDemo"
100 shift
101 ;;
102 init_customer)
103 TAG="InitCustomer"
104 shift
105 ;;
106 distribute)
107 TAG="InitDistribution"
108 shift
Mandeep Khindac00c6872017-10-26 17:46:43 +0000109 if [ $# -eq 1 ];then
Brian Freeman7e13acc2018-05-15 17:49:50 -0500110 VARIABLES="$VARIABLES -v DEMO_PREFIX:$1"
Mandeep Khindac00c6872017-10-26 17:46:43 +0000111 fi
112 shift
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400113 ;;
114 preload)
115 TAG="PreloadDemo"
116 shift
117 if [ $# -ne 2 ];then
kaihlavi78e7f392019-04-16 14:53:04 +0300118 echo "Usage: demo-k8s.sh <namespace> preload <vnf_name> <module_name>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400119 exit
120 fi
Brian Freeman7e13acc2018-05-15 17:49:50 -0500121 VARIABLES="$VARIABLES -v VNF_NAME:$1"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400122 shift
Brian Freeman7e13acc2018-05-15 17:49:50 -0500123 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400124 shift
125 ;;
126 appc)
Brian Freeman7e13acc2018-05-15 17:49:50 -0500127 TAG="APPCMountPointDemo"
128 shift
129 if [ $# -ne 1 ];then
kaihlavi78e7f392019-04-16 14:53:04 +0300130 echo "Usage: demo-k8s.sh <namespace> appc <module_name>"
Brian Freeman7e13acc2018-05-15 17:49:50 -0500131 exit
132 fi
133 VARIABLES="$VARIABLES -v MODULE_NAME:$1"
134 shift
135 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400136 instantiateVFW)
137 TAG="instantiateVFW"
138 VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
139 shift
140 ;;
Brian Freeman46d00ca2019-05-06 12:12:36 -0500141 instantiateVFWdirectso)
142 TAG="instantiateVFWdirectso"
143 shift
144 if [ $# -ne 1 ];then
145 echo "Usage: demo-k8s.sh <namespace> instantiateVFWdirectso <csar_filename>"
146 exit
147 fi
148 VARIABLES="$VARIABLES -v CSAR_FILE:$1 -v GLOBAL_BUILD_NUMBER:$$"
149 shift
150 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400151 deleteVNF)
152 TAG="deleteVNF"
153 shift
154 if [ $# -ne 1 ];then
kaihlavi78e7f392019-04-16 14:53:04 +0300155 echo "Usage: demo-k8s.sh <namespace> deleteVNF <module_name from instantiateVFW>"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400156 exit
157 fi
Brian Freeman7e13acc2018-05-15 17:49:50 -0500158 VARFILE=$1.py
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400159 if [ -e /opt/eteshare/${VARFILE} ]; then
160 VARIABLES="$VARIABLES -V /share/${VARFILE}"
161 else
162 echo "Cache file ${VARFILE} is not found"
163 exit
164 fi
Mandeep Khinda7ea563e2018-04-17 03:26:26 +0000165 shift
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500166 ;;
167 heatbridge)
168 TAG="heatbridge"
169 shift
Marco Plataniaff0b6cb2018-10-29 17:27:15 -0400170 if [ $# -ne 4 ];then
kaihlavi78e7f392019-04-16 14:53:04 +0300171 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 -0500172 exit
173 fi
Brian Freeman7e13acc2018-05-15 17:49:50 -0500174 VARIABLES="$VARIABLES -v HB_STACK:$1"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500175 shift
Brian Freeman7e13acc2018-05-15 17:49:50 -0500176 VARIABLES="$VARIABLES -v HB_SERVICE_INSTANCE_ID:$1"
Alexis de Talhouët8e804c02017-12-07 16:23:15 -0500177 shift
Brian Freeman7e13acc2018-05-15 17:49:50 -0500178 VARIABLES="$VARIABLES -v HB_SERVICE:$1"
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400179 shift
Marco Plataniaff0b6cb2018-10-29 17:27:15 -0400180 VARIABLES="$VARIABLES -v HB_IPV4_OAM_ADDRESS:$1"
181 shift
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400182 ;;
Yang Xue951fd22018-10-28 11:47:13 -0400183 cds)
184 TAG="cds"
185 shift
186 ;;
Yang Xu37eedd12018-11-01 12:56:55 -0400187 distributeVFWNG)
188 TAG="distributeVFWNG"
189 shift
190 ;;
Brian Freemanab7c1742019-02-13 18:05:02 -0500191 distributeDemoVFWDT)
192 TAG="DistributeDemoVFWDT"
193 shift
194 ;;
195 instantiateDemoVFWDT)
196 TAG="instantiateVFWDT"
197 shift
198 ;;
Gary Wu9d5abb42018-11-02 13:48:21 -0700199 vfwclosedloop)
200 TAG="vfwclosedloop"
201 shift
202 VARIABLES="$VARIABLES -v pkg_host:$1"
203 shift
204 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -0400205 *)
206 usage
207 exit
208 esac
209done
210
Gary Wubf7f1592018-09-14 10:29:27 -0700211set -x
212
BorislavG8bfc6cf2018-02-27 15:04:26 +0000213POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
Gary Wu4ec2c672018-11-01 11:57:27 -0700214
Brian Freemanab7c1742019-02-13 18:05:02 -0500215ETEHOME=/var/opt/ONAP
Gary Wu4ec2c672018-11-01 11:57:27 -0700216
217export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l")
218OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key
219DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90))
220
221VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py -V /share/config/integration_preload_parameters.py"
222
223kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} -i ${TAG} --display $DISPLAY_NUM 2> ${TAG}.out
224