vaibhavjayas | ea9aee0 | 2018-08-31 06:22:26 +0000 | [diff] [blame] | 1 | # Copyright © 2018 Amdocs, Bell Canada |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Gary Wu | bf7f159 | 2018-09-14 10:29:27 -0700 | [diff] [blame] | 15 | #!/bin/bash |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 16 | |
| 17 | # |
| 18 | # Execute tags built to support the hands on demo, |
| 19 | # |
| 20 | function usage |
| 21 | { |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 22 | echo "Usage: demo.sh namespace <command> [<parameters>]" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 23 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 24 | echo " demo.sh <namespace> init" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 25 | echo " - Execute both init_customer + distribute" |
| 26 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 27 | echo " demo.sh <namespace> init_customer" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 28 | echo " - Create demo customer (Demonstration) and services, etc." |
| 29 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 30 | echo " demo.sh <namespace> distribute [<prefix>]" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 31 | echo " - Distribute demo models (demoVFW and demoVLB)" |
| 32 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 33 | echo " demo.sh <namespace> preload <vnf_name> <module_name>" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 34 | echo " - Preload data for VNF for the <module_name>" |
| 35 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 36 | echo " demo.sh <namespace> appc <module_name>" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 37 | echo " - provide APPC with vFW module mount point for closed loop" |
| 38 | echo " " |
Mandeep Khinda | 7ea563e | 2018-04-17 03:26:26 +0000 | [diff] [blame] | 39 | echo " demo.sh <namespace> init_robot [ <etc_hosts_prefix> ]" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 40 | echo " - Initialize robot after all ONAP VMs have started" |
| 41 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 42 | echo " demo.sh <namespace> instantiateVFW" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 43 | echo " - Instantiate vFW module for the a demo customer (DemoCust<uuid>)" |
| 44 | echo " " |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 45 | echo " demo.sh <namespace> deleteVNF <module_name from instantiateVFW>" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 46 | echo " - Delete the module created by instantiateVFW" |
Alexis de Talhouët | 8e804c0 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 47 | echo " " |
Marco Platania | ff0b6cb | 2018-10-29 17:27:15 -0400 | [diff] [blame] | 48 | 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] | 49 | echo " - Run heatbridge against the stack for the given service instance and service" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | # Set the defaults |
Brian Freeman | 2706630 | 2018-04-23 17:24:35 -0500 | [diff] [blame] | 53 | |
| 54 | echo "Number of parameters:" |
| 55 | echo $# |
| 56 | |
| 57 | if [ $# -lt 2 ];then |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 58 | usage |
| 59 | exit |
| 60 | fi |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 61 | |
| 62 | NAMESPACE=$1 |
| 63 | shift |
| 64 | |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 65 | ## |
| 66 | ## if more than 1 tag is supplied, the must be provided with -i or -e |
| 67 | ## |
Brian Freeman | 2706630 | 2018-04-23 17:24:35 -0500 | [diff] [blame] | 68 | while [ $# -gt 0 ] |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 69 | do |
Brian Freeman | 2706630 | 2018-04-23 17:24:35 -0500 | [diff] [blame] | 70 | key="$1" |
| 71 | echo "KEY:" |
| 72 | echo $key |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 73 | |
| 74 | case $key in |
| 75 | init_robot) |
| 76 | TAG="UpdateWebPage" |
| 77 | read -s -p "WEB Site Password for user 'test': " WEB_PASSWORD |
| 78 | if [ "$WEB_PASSWORD" = "" ]; then |
| 79 | echo "" |
| 80 | echo "WEB Password is required for user 'test'" |
| 81 | exit |
| 82 | fi |
| 83 | VARIABLES="$VARIABLES -v WEB_PASSWORD:$WEB_PASSWORD" |
| 84 | shift |
Mandeep Khinda | 7ea563e | 2018-04-17 03:26:26 +0000 | [diff] [blame] | 85 | if [ $# -eq 2 ];then |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 86 | VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1" |
Mandeep Khinda | 7ea563e | 2018-04-17 03:26:26 +0000 | [diff] [blame] | 87 | fi |
| 88 | shift |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 89 | ;; |
| 90 | init) |
| 91 | TAG="InitDemo" |
| 92 | shift |
| 93 | ;; |
| 94 | init_customer) |
| 95 | TAG="InitCustomer" |
| 96 | shift |
| 97 | ;; |
| 98 | distribute) |
| 99 | TAG="InitDistribution" |
| 100 | shift |
Mandeep Khinda | c00c687 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 101 | if [ $# -eq 1 ];then |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 102 | VARIABLES="$VARIABLES -v DEMO_PREFIX:$1" |
Mandeep Khinda | c00c687 | 2017-10-26 17:46:43 +0000 | [diff] [blame] | 103 | fi |
| 104 | shift |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 105 | ;; |
| 106 | preload) |
| 107 | TAG="PreloadDemo" |
| 108 | shift |
| 109 | if [ $# -ne 2 ];then |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 110 | echo "Usage: demo.sh <namespace> preload <vnf_name> <module_name>" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 111 | exit |
| 112 | fi |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 113 | VARIABLES="$VARIABLES -v VNF_NAME:$1" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 114 | shift |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 115 | VARIABLES="$VARIABLES -v MODULE_NAME:$1" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 116 | shift |
| 117 | ;; |
| 118 | appc) |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 119 | TAG="APPCMountPointDemo" |
| 120 | shift |
| 121 | if [ $# -ne 1 ];then |
| 122 | echo "Usage: demo.sh <namespace> appc <module_name>" |
| 123 | exit |
| 124 | fi |
| 125 | VARIABLES="$VARIABLES -v MODULE_NAME:$1" |
| 126 | shift |
| 127 | ;; |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 128 | instantiateVFW) |
| 129 | TAG="instantiateVFW" |
| 130 | VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$" |
| 131 | shift |
| 132 | ;; |
| 133 | deleteVNF) |
| 134 | TAG="deleteVNF" |
| 135 | shift |
| 136 | if [ $# -ne 1 ];then |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 137 | echo "Usage: demo.sh <namespace> deleteVNF <module_name from instantiateVFW>" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 138 | exit |
| 139 | fi |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 140 | VARFILE=$1.py |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 141 | if [ -e /opt/eteshare/${VARFILE} ]; then |
| 142 | VARIABLES="$VARIABLES -V /share/${VARFILE}" |
| 143 | else |
| 144 | echo "Cache file ${VARFILE} is not found" |
| 145 | exit |
| 146 | fi |
Mandeep Khinda | 7ea563e | 2018-04-17 03:26:26 +0000 | [diff] [blame] | 147 | shift |
Alexis de Talhouët | 8e804c0 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 148 | ;; |
| 149 | heatbridge) |
| 150 | TAG="heatbridge" |
| 151 | shift |
Marco Platania | ff0b6cb | 2018-10-29 17:27:15 -0400 | [diff] [blame] | 152 | if [ $# -ne 4 ];then |
| 153 | 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] | 154 | exit |
| 155 | fi |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 156 | VARIABLES="$VARIABLES -v HB_STACK:$1" |
Alexis de Talhouët | 8e804c0 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 157 | shift |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 158 | VARIABLES="$VARIABLES -v HB_SERVICE_INSTANCE_ID:$1" |
Alexis de Talhouët | 8e804c0 | 2017-12-07 16:23:15 -0500 | [diff] [blame] | 159 | shift |
Brian Freeman | 7e13acc | 2018-05-15 17:49:50 -0500 | [diff] [blame] | 160 | VARIABLES="$VARIABLES -v HB_SERVICE:$1" |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 161 | shift |
Marco Platania | ff0b6cb | 2018-10-29 17:27:15 -0400 | [diff] [blame] | 162 | VARIABLES="$VARIABLES -v HB_IPV4_OAM_ADDRESS:$1" |
| 163 | shift |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 164 | ;; |
Yang Xu | e951fd2 | 2018-10-28 11:47:13 -0400 | [diff] [blame] | 165 | cds) |
| 166 | TAG="cds" |
| 167 | shift |
| 168 | ;; |
Yang Xu | 37eedd1 | 2018-11-01 12:56:55 -0400 | [diff] [blame] | 169 | distributeVFWNG) |
| 170 | TAG="distributeVFWNG" |
| 171 | shift |
| 172 | ;; |
Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 173 | *) |
| 174 | usage |
| 175 | exit |
| 176 | esac |
| 177 | done |
| 178 | |
Gary Wu | bf7f159 | 2018-09-14 10:29:27 -0700 | [diff] [blame] | 179 | set -x |
| 180 | |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 181 | POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot) |
Gary Wu | 4ec2c67 | 2018-11-01 11:57:27 -0700 | [diff] [blame] | 182 | |
| 183 | ETEHOME=/var/opt/OpenECOMP_ETE |
| 184 | |
| 185 | export GLOBAL_BUILD_NUMBER=$(kubectl --namespace $NAMESPACE exec ${POD} -- bash -c "ls -1q /share/logs/ | wc -l") |
| 186 | OUTPUT_FOLDER=$(printf %04d $GLOBAL_BUILD_NUMBER)_demo_$key |
| 187 | DISPLAY_NUM=$(($GLOBAL_BUILD_NUMBER + 90)) |
| 188 | |
| 189 | VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py -V /share/config/integration_preload_parameters.py" |
| 190 | |
| 191 | kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/${OUTPUT_FOLDER} -i ${TAG} --display $DISPLAY_NUM 2> ${TAG}.out |
| 192 | |