Gary Wu | 9d5abb4 | 2018-11-02 13:48:21 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # Copyright (C) 2018 Amdocs, Bell Canada |
vaibhavjayas | ea9aee0 | 2018-08-31 06:22:26 +0000 | [diff] [blame] | 3 | # |
| 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 Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 15 | # |
| 16 | # Execute tags built to support the hands on demo, |
| 17 | # |
| 18 | function usage |
| 19 | { |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 20 | echo "Usage: demo.sh namespace <command> [<parameters>]" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 21 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 22 | echo " demo.sh <namespace> init" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 23 | echo " - Execute both init_customer + distribute" |
| 24 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 25 | echo " demo.sh <namespace> init_customer" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 26 | echo " - Create demo customer (Demonstration) and services, etc." |
| 27 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 28 | echo " demo.sh <namespace> distribute [<prefix>]" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 29 | echo " - Distribute demo models (demoVFW and demoVLB)" |
| 30 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 31 | echo " demo.sh <namespace> preload <vnf_name> <module_name>" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 32 | echo " - Preload data for VNF for the <module_name>" |
| 33 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 34 | echo " demo.sh <namespace> appc <module_name>" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 35 | echo " - provide APPC with vFW module mount point for closed loop" |
| 36 | echo " " |
Mandeep Khinda | 7ea563e | 2018-04-17 03:26:26 +0000 | [diff] [blame] | 37 | echo " demo.sh <namespace> init_robot [ <etc_hosts_prefix> ]" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 38 | echo " - Initialize robot after all ONAP VMs have started" |
| 39 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 40 | echo " demo.sh <namespace> instantiateVFW" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 41 | echo " - Instantiate vFW module for the a demo customer (DemoCust<uuid>)" |
| 42 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 43 | echo " demo.sh <namespace> deleteVNF <module_name from instantiateVFW>" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 44 | echo " - Delete the module created by instantiateVFW" |
Alexis de Talhouët | 8e804c0 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 45 | echo " " |
Marco Platania | ff0b6cb | 2018-10-29 17:27:15 -0400 | [diff] [blame] | 46 | echo " demo.sh <namespace> heatbridge <stack_name> <service_instance_id> <service> <oam-ip-address>" |
Alexis de Talhouët | 8e804c0 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 47 | echo " - Run heatbridge against the stack for the given service instance and service" |
Gary Wu | 9d5abb4 | 2018-11-02 13:48:21 -0700 | [diff] [blame^] | 48 | 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 Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | # Set the defaults |
Brian Freeman | 2706630 | 2018-04-23 17:24:35 -0500 | [diff] [blame] | 56 | |
| 57 | echo "Number of parameters:" |
| 58 | echo $# |
| 59 | |
| 60 | if [ $# -lt 2 ];then |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 61 | usage |
| 62 | exit |
| 63 | fi |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 64 | |
| 65 | NAMESPACE=$1 |
| 66 | shift |
| 67 | |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 68 | ## |
| 69 | ## if more than 1 tag is supplied, the must be provided with -i or -e |
| 70 | ## |
Brian Freeman | 2706630 | 2018-04-23 17:24:35 -0500 | [diff] [blame] | 71 | while [ $# -gt 0 ] |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 72 | do |
Brian Freeman | 2706630 | 2018-04-23 17:24:35 -0500 | [diff] [blame] | 73 | key="$1" |
| 74 | echo "KEY:" |
| 75 | echo $key |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 76 | |
| 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 Khinda | 7ea563e | 2018-04-17 03:26:26 +0000 | [diff] [blame] | 88 | if [ $# -eq 2 ];then |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 89 | VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1" |
Mandeep Khinda | 7ea563e | 2018-04-17 03:26:26 +0000 | [diff] [blame] | 90 | fi |
| 91 | shift |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 92 | ;; |
| 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 Khinda | c00c687 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 104 | if [ $# -eq 1 ];then |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 105 | VARIABLES="$VARIABLES -v DEMO_PREFIX:$1" |
Mandeep Khinda | c00c687 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 106 | fi |
| 107 | shift |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 108 | ;; |
| 109 | preload) |
| 110 | TAG="PreloadDemo" |
| 111 | shift |
| 112 | if [ $# -ne 2 ];then |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 113 | echo "Usage: demo.sh <namespace> preload <vnf_name> <module_name>" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 114 | exit |
| 115 | fi |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 116 | VARIABLES="$VARIABLES -v VNF_NAME:$1" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 117 | shift |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 118 | VARIABLES="$VARIABLES -v MODULE_NAME:$1" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 119 | shift |
| 120 | ;; |
| 121 | appc) |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 122 | 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 Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 131 | 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 Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 140 | echo "Usage: demo.sh <namespace> deleteVNF <module_name from instantiateVFW>" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 141 | exit |
| 142 | fi |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 143 | VARFILE=$1.py |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 144 | 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 Khinda | 7ea563e | 2018-04-17 03:26:26 +0000 | [diff] [blame] | 150 | shift |
Alexis de Talhouët | 8e804c0 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 151 | ;; |
| 152 | heatbridge) |
| 153 | TAG="heatbridge" |
| 154 | shift |
Marco Platania | ff0b6cb | 2018-10-29 17:27:15 -0400 | [diff] [blame] | 155 | if [ $# -ne 4 ];then |
| 156 | echo "Usage: demo.sh <namespace> heatbridge <stack_name> <service_instance_id> <service> <oam-ip-address>" |
Alexis de Talhouët | 8e804c0 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 157 | exit |
| 158 | fi |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 159 | VARIABLES="$VARIABLES -v HB_STACK:$1" |
Alexis de Talhouët | 8e804c0 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 160 | shift |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 161 | VARIABLES="$VARIABLES -v HB_SERVICE_INSTANCE_ID:$1" |
Alexis de Talhouët | 8e804c0 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 162 | shift |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 163 | VARIABLES="$VARIABLES -v HB_SERVICE:$1" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 164 | shift |
Marco Platania | ff0b6cb | 2018-10-29 17:27:15 -0400 | [diff] [blame] | 165 | VARIABLES="$VARIABLES -v HB_IPV4_OAM_ADDRESS:$1" |
| 166 | shift |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 167 | ;; |
Yang Xu | e951fd2 | 2018-10-28 11:47:13 -0400 | [diff] [blame] | 168 | cds) |
| 169 | TAG="cds" |
| 170 | shift |
| 171 | ;; |
Yang Xu | 37eedd1 | 2018-11-01 12:56:55 -0400 | [diff] [blame] | 172 | distributeVFWNG) |
| 173 | TAG="distributeVFWNG" |
| 174 | shift |
| 175 | ;; |
Gary Wu | 9d5abb4 | 2018-11-02 13:48:21 -0700 | [diff] [blame^] | 176 | vfwclosedloop) |
| 177 | TAG="vfwclosedloop" |
| 178 | shift |
| 179 | VARIABLES="$VARIABLES -v pkg_host:$1" |
| 180 | shift |
| 181 | ;; |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 182 | *) |
| 183 | usage |
| 184 | exit |
| 185 | esac |
| 186 | done |
| 187 | |
Gary Wu | bf7f159 | 2018-09-14 10:29:27 -0700 | [diff] [blame] | 188 | set -x |
| 189 | |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 190 | POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot) |
Gary Wu | 4ec2c67 | 2018-11-01 11:57:27 -0700 | [diff] [blame] | 191 | |
| 192 | ETEHOME=/var/opt/OpenECOMP_ETE |
| 193 | |
| 194 | export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l") |
| 195 | OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key |
| 196 | DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90)) |
| 197 | |
| 198 | VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py -V /share/config/integration_preload_parameters.py" |
| 199 | |
| 200 | kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} -i ${TAG} --display $DISPLAY_NUM 2> ${TAG}.out |
| 201 | |