Fix demo-k8
[oom.git] / kubernetes / robot / demo-k8s.sh
1 #!/bin/bash -x
2
3 #
4 # Execute tags built to support the hands on demo,
5 #
6 function usage
7 {
8         echo "Usage: demo.sh namespace <command> [<parameters>]"
9         echo " "
10         echo "       demo.sh <namespace> init"
11         echo "               - Execute both init_customer + distribute"
12         echo " "
13         echo "       demo.sh <namespace> init_customer"
14         echo "               - Create demo customer (Demonstration) and services, etc."
15         echo " "
16         echo "       demo.sh <namespace> distribute  [<prefix>]"
17         echo "               - Distribute demo models (demoVFW and demoVLB)"
18         echo " "
19         echo "       demo.sh <namespace> preload <vnf_name> <module_name>"
20         echo "               - Preload data for VNF for the <module_name>"
21         echo " "
22         echo "       demo.sh <namespace> appc <module_name>"
23     echo "               - provide APPC with vFW module mount point for closed loop"
24         echo " "
25         echo "       demo.sh <namespace> init_robot [ <etc_hosts_prefix> ]"
26     echo "               - Initialize robot after all ONAP VMs have started"
27         echo " "
28         echo "       demo.sh <namespace> instantiateVFW"
29     echo "               - Instantiate vFW module for the a demo customer (DemoCust<uuid>)"
30         echo " "
31         echo "       demo.sh <namespace> deleteVNF <module_name from instantiateVFW>"
32     echo "               - Delete the module created by instantiateVFW"
33         echo " "
34         echo "       demo.sh <namespace> heatbridge <stack_name> <service_instance_id> <service>"
35     echo "               - Run heatbridge against the stack for the given service instance and service"
36 }
37
38 # Set the defaults
39
40 echo "Number of parameters:" 
41 echo $#
42
43 if [ $# -lt 2 ];then
44         usage
45         exit
46 fi
47
48 NAMESPACE=$1
49 shift
50
51 ##
52 ## if more than 1 tag is supplied, the must be provided with -i or -e
53 ##
54 while [ $# -gt 0 ]
55 do
56         key="$1"
57         echo "KEY:"
58         echo $key
59
60         case $key in
61         init_robot)
62                         TAG="UpdateWebPage"
63                         read -s -p "WEB Site Password for user 'test': " WEB_PASSWORD
64                         if [ "$WEB_PASSWORD" = "" ]; then
65                                 echo ""
66                                 echo "WEB Password is required for user 'test'"
67                                 exit
68                         fi
69                         VARIABLES="$VARIABLES -v WEB_PASSWORD:$WEB_PASSWORD"
70                         shift
71                         if [ $# -eq 2 ];then
72                                 VARIABLES="$VARIABLES -v HOSTS_PREFIX:$2"
73                         fi
74                         shift
75                         ;;
76         init)
77                         TAG="InitDemo"
78                         shift
79                         ;;
80         init_customer)
81                         TAG="InitCustomer"
82                         shift
83                         ;;
84         distribute)
85                         TAG="InitDistribution"
86                         shift
87                         if [ $# -eq 1 ];then
88                                 VARIABLES="$VARIABLES -v DEMO_PREFIX:$2"
89                         fi
90                         shift
91                         ;;
92         preload)
93                         TAG="PreloadDemo"
94                         shift
95                         if [ $# -ne 2 ];then
96                                 echo "Usage: demo.sh preload <vnf_name> <module_name>"
97                                 exit
98                         fi
99                         VARIABLES="$VARIABLES -v VNF_NAME:$2"
100                         shift
101                         VARIABLES="$VARIABLES -v MODULE_NAME:$2"
102                         shift
103                         ;;
104         appc)
105         TAG="APPCMountPointDemo"
106         shift
107         if [ $# -ne 1 ];then
108                         echo "Usage: demo.sh appc <module_name>"
109                         exit
110                 fi
111         VARIABLES="$VARIABLES -v MODULE_NAME:$2"
112         shift
113         ;;
114         instantiateVFW)
115                         TAG="instantiateVFW"
116                         VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
117                         shift
118                         ;;
119         deleteVNF)
120                         TAG="deleteVNF"
121                         shift
122                         if [ $# -ne 1 ];then
123                                 echo "Usage: demo.sh deleteVNF <module_name from instantiateVFW>"
124                                 exit
125                         fi
126                         VARFILE=$2.py
127                         if [ -e /opt/eteshare/${VARFILE} ]; then
128                                 VARIABLES="$VARIABLES -V /share/${VARFILE}"
129                         else
130                                 echo "Cache file ${VARFILE} is not found"
131                                 exit
132                         fi
133                         shift
134                         ;;
135         heatbridge)
136                         TAG="heatbridge"
137                         shift
138                         if [ $# -ne 3 ];then
139                                 echo "Usage: demo.sh heatbridge <stack_name> <service_instance_id> <service>"
140                                 exit
141                         fi
142                         VARIABLES="$VARIABLES -v HB_STACK:$2"
143                         shift
144                         VARIABLES="$VARIABLES -v HB_SERVICE_INSTANCE_ID:$2"
145                         shift
146                         VARIABLES="$VARIABLES -v HB_SERVICE:$2"
147                         shift
148                         ;;
149         *)
150                         usage
151                         exit
152         esac
153 done
154
155 ETEHOME=/var/opt/OpenECOMP_ETE
156 VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py -V /share/config/integration_preload_parameters.py"
157 POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
158 kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/demo/${TAG} -i ${TAG} --display 89 2> ${TAG}.out