Merge "Update vfc charts configutation"
[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 if [ $# -le 2 ];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 1 ]
51 do
52         key="$2"
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                         if [ $# -eq 2 ];then
66                                 VARIABLES="$VARIABLES -v HOSTS_PREFIX:$2"
67                         fi
68                         shift
69                         ;;
70         init)
71                         TAG="InitDemo"
72                         shift
73                         ;;
74         init_customer)
75                         TAG="InitCustomer"
76                         shift
77                         ;;
78         distribute)
79                         TAG="InitDistribution"
80                         shift
81                         if [ $# -eq 1 ];then
82                                 VARIABLES="$VARIABLES -v DEMO_PREFIX:$2"
83                         fi
84                         shift
85                         ;;
86         preload)
87                         TAG="PreloadDemo"
88                         shift
89                         if [ $# -ne 2 ];then
90                                 echo "Usage: demo.sh preload <vnf_name> <module_name>"
91                                 exit
92                         fi
93                         VARIABLES="$VARIABLES -v VNF_NAME:$2"
94                         shift
95                         VARIABLES="$VARIABLES -v MODULE_NAME:$2"
96                         shift
97                         ;;
98         appc)
99         TAG="APPCMountPointDemo"
100         shift
101         if [ $# -ne 1 ];then
102                         echo "Usage: demo.sh appc <module_name>"
103                         exit
104                 fi
105         VARIABLES="$VARIABLES -v MODULE_NAME:$2"
106         shift
107         ;;
108         instantiateVFW)
109                         TAG="instantiateVFW"
110                         VARIABLES="$VARIABLES -v GLOBAL_BUILD_NUMBER:$$"
111                         shift
112                         ;;
113         deleteVNF)
114                         TAG="deleteVNF"
115                         shift
116                         if [ $# -ne 1 ];then
117                                 echo "Usage: demo.sh deleteVNF <module_name from instantiateVFW>"
118                                 exit
119                         fi
120                         VARFILE=$2.py
121                         if [ -e /opt/eteshare/${VARFILE} ]; then
122                                 VARIABLES="$VARIABLES -V /share/${VARFILE}"
123                         else
124                                 echo "Cache file ${VARFILE} is not found"
125                                 exit
126                         fi
127                         shift
128                         ;;
129         heatbridge)
130                         TAG="heatbridge"
131                         shift
132                         if [ $# -ne 3 ];then
133                                 echo "Usage: demo.sh heatbridge <stack_name> <service_instance_id> <service>"
134                                 exit
135                         fi
136                         VARIABLES="$VARIABLES -v HB_STACK:$2"
137                         shift
138                         VARIABLES="$VARIABLES -v HB_SERVICE_INSTANCE_ID:$2"
139                         shift
140                         VARIABLES="$VARIABLES -v HB_SERVICE:$2"
141                         shift
142                         ;;
143         *)
144                         usage
145                         exit
146         esac
147 done
148
149 ETEHOME=/var/opt/OpenECOMP_ETE
150 VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py -V /share/config/integration_preload_parameters.py"
151 POD=$(kubectl --namespace $NAMESPACE get pods | sed 's/ .*//'| grep robot)
152 kubectl --namespace $NAMESPACE exec ${POD} -- ${ETEHOME}/runTags.sh ${VARIABLEFILES} ${VARIABLES} -d /share/logs/demo/${TAG} -i ${TAG} --display 89 2> ${TAG}.out