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