Run all components in one namespace
[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"
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 if [ $# -le 1 ];then
40         usage
41         exit
42 fi
43
44 NAMESPACE=$1
45 shift
46
47 ##
48 ## if more than 1 tag is supplied, the must be provided with -i or -e
49 ##
50 while [ $# -gt 0 ]
51 do
52         key="$1"
53
54         case $key in
55         init_robot)
56                         TAG="UpdateWebPage"
57                         read -s -p "WEB Site Password for user 'test': " WEB_PASSWORD
58                         if [ "$WEB_PASSWORD" = "" ]; then
59                                 echo ""
60                                 echo "WEB Password is required for user 'test'"
61                                 exit
62                         fi
63                         VARIABLES="$VARIABLES -v WEB_PASSWORD:$WEB_PASSWORD"
64                         shift
65                         ;;
66         init)
67                         TAG="InitDemo"
68                         shift
69                         ;;
70         init_customer)
71                         TAG="InitCustomer"
72                         shift
73                         ;;
74         distribute)
75                         TAG="InitDistribution"
76                         shift
77                         if [ $# -eq 1 ];then
78                                 VARIABLES="$VARIABLES -v DEMO_PREFIX:$1"
79                         fi
80                         shift
81                         ;;
82         preload)
83                         TAG="PreloadDemo"
84                         shift
85                         if [ $# -ne 2 ];then
86                                 echo "Usage: demo.sh preload <vnf_name> <module_name>"
87                                 exit
88                         fi
89                         VARIABLES="$VARIABLES -v VNF_NAME:$1"
90                         shift
91                         VARIABLES="$VARIABLES -v MODULE_NAME:$1"
92                         shift
93                         ;;
94         appc)
95         TAG="APPCMountPointDemo"
96         shift
97         if [ $# -ne 1 ];then
98                         echo "Usage: demo.sh appc <module_name>"
99                         exit
100                 fi
101         VARIABLES="$VARIABLES -v MODULE_NAME:$1"
102         shift
103         ;;
104         instantiateVFW)
105                         TAG="instantiateVFW"
106                         VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
107                         shift
108                         ;;
109         deleteVNF)
110                         TAG="deleteVNF"
111                         shift
112                         if [ $# -ne 1 ];then
113                                 echo "Usage: demo.sh deleteVNF <module_name from instantiateVFW>"
114                                 exit
115                         fi
116                         VARFILE=$1.py
117                         if [ -e /opt/eteshare/${VARFILE} ]; then
118                                 VARIABLES="$VARIABLES -V /share/${VARFILE}"
119                         else
120                                 echo "Cache file ${VARFILE} is not found"
121                                 exit
122                         fi
123       shift
124                         ;;
125         heatbridge)
126                         TAG="heatbridge"
127                         shift
128                         if [ $# -ne 3 ];then
129                                 echo "Usage: demo.sh heatbridge <stack_name> <service_instance_id> <service>"
130                                 exit
131                         fi
132                         VARIABLES="$VARIABLES -v HB_STACK:$1"
133                         shift
134                         VARIABLES="$VARIABLES -v HB_SERVICE_INSTANCE_ID:$1"
135                         shift
136                         VARIABLES="$VARIABLES -v HB_SERVICE:$1"
137                         shift
138                         ;;
139         *)
140                         usage
141                         exit
142         esac
143 done
144
145 ETEHOME=/var/opt/OpenECOMP_ETE
146 VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py -V /share/config/integration_preload_parameters.py"
147 POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
148 kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/demo/${TAG} -i ${TAG} --display 89 2> ${TAG}.out