Add oam-ip-addr to heatbridge input params
[oom.git] / kubernetes / robot / demo-k8s.sh
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
15 #!/bin/bash
16
17 #
18 # Execute tags built to support the hands on demo,
19 #
20 function usage
21 {
22         echo "Usage: demo.sh namespace <command> [<parameters>]"
23         echo " "
24         echo "       demo.sh <namespace> init"
25         echo "               - Execute both init_customer + distribute"
26         echo " "
27         echo "       demo.sh <namespace> init_customer"
28         echo "               - Create demo customer (Demonstration) and services, etc."
29         echo " "
30         echo "       demo.sh <namespace> distribute  [<prefix>]"
31         echo "               - Distribute demo models (demoVFW and demoVLB)"
32         echo " "
33         echo "       demo.sh <namespace> preload <vnf_name> <module_name>"
34         echo "               - Preload data for VNF for the <module_name>"
35         echo " "
36         echo "       demo.sh <namespace> appc <module_name>"
37     echo "               - provide APPC with vFW module mount point for closed loop"
38         echo " "
39         echo "       demo.sh <namespace> init_robot [ <etc_hosts_prefix> ]"
40     echo "               - Initialize robot after all ONAP VMs have started"
41         echo " "
42         echo "       demo.sh <namespace> instantiateVFW"
43     echo "               - Instantiate vFW module for the a demo customer (DemoCust<uuid>)"
44         echo " "
45         echo "       demo.sh <namespace> deleteVNF <module_name from instantiateVFW>"
46     echo "               - Delete the module created by instantiateVFW"
47         echo " "
48         echo "       demo.sh <namespace> heatbridge <stack_name> <service_instance_id> <service> <oam-ip-address>"
49     echo "               - Run heatbridge against the stack for the given service instance and service"
50 }
51
52 # Set the defaults
53
54 echo "Number of parameters:" 
55 echo $#
56
57 if [ $# -lt 2 ];then
58         usage
59         exit
60 fi
61
62 NAMESPACE=$1
63 shift
64
65 ##
66 ## if more than 1 tag is supplied, the must be provided with -i or -e
67 ##
68 while [ $# -gt 0 ]
69 do
70         key="$1"
71         echo "KEY:"
72         echo $key
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
85                         if [ $# -eq 2 ];then
86                                 VARIABLES="$VARIABLES -v HOSTS_PREFIX:$1"
87                         fi
88                         shift
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
101                         if [ $# -eq 1 ];then
102                                 VARIABLES="$VARIABLES -v DEMO_PREFIX:$1"
103                         fi
104                         shift
105                         ;;
106         preload)
107                         TAG="PreloadDemo"
108                         shift
109                         if [ $# -ne 2 ];then
110                                 echo "Usage: demo.sh <namespace> preload <vnf_name> <module_name>"
111                                 exit
112                         fi
113                         VARIABLES="$VARIABLES -v VNF_NAME:$1"
114                         shift
115                         VARIABLES="$VARIABLES -v MODULE_NAME:$1"
116                         shift
117                         ;;
118         appc)
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                         ;;
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
137                                 echo "Usage: demo.sh <namespace> deleteVNF <module_name from instantiateVFW>"
138                                 exit
139                         fi
140                         VARFILE=$1.py
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
147                         shift
148                         ;;
149         heatbridge)
150                         TAG="heatbridge"
151                         shift
152                         if [ $# -ne 4 ];then
153                                 echo "Usage: demo.sh <namespace> heatbridge <stack_name> <service_instance_id> <service> <oam-ip-address>"
154                                 exit
155                         fi
156                         VARIABLES="$VARIABLES -v HB_STACK:$1"
157                         shift
158                         VARIABLES="$VARIABLES -v HB_SERVICE_INSTANCE_ID:$1"
159                         shift
160                         VARIABLES="$VARIABLES -v HB_SERVICE:$1"
161                         shift
162                         VARIABLES="$VARIABLES -v HB_IPV4_OAM_ADDRESS:$1"
163                         shift
164                         ;;
165         cds)
166                         TAG="cds"
167                         shift
168                         ;;
169         *)
170                         usage
171                         exit
172         esac
173 done
174
175 set -x
176
177 ETEHOME=/var/opt/OpenECOMP_ETE
178 VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py -V /share/config/integration_preload_parameters.py"
179 POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
180 kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/demo/${TAG} -i ${TAG} --display 89 2> ${TAG}.out