Merge "Change from using chef to local config files"
[integration.git] / bootstrap / vagrant-onap / tools / run.sh
1 #!/bin/bash
2
3 function usage {
4     cat <<EOF
5 Usage: run.sh Command [-y] [-?]
6 Optional arguments:
7     -y
8         Skips warning prompt.
9     -g
10         Skips creation or retrieve image process.
11     -i
12         Skips installation service process.
13     -s <suite>
14         Test suite to use in testing mode.
15     -c <case>
16         Test case to use in testing mode.
17 Commands:
18     all_in_one  Deploy in all-in-one mode.
19     dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc|vfc|vnfsdk|multicloud|ccsdk|vvp|openstack|msb|oom  Deploy chosen service.
20     testing  Deploy in testing mode.
21 EOF
22 }
23
24 run=false
25 test_suite="*"
26 test_case="*"
27
28 COMMAND=$1
29
30 while getopts "ygis:c:" OPTION "${@:2}"; do
31     case "$OPTION" in
32     y)
33         run=true
34         ;;
35     g)
36         export SKIP_GET_IMAGES="True"
37         ;;
38     i)
39         export SKIP_INSTALL="True"
40         ;;
41     s)
42         if [ "$COMMAND" != "testing" ] ; then
43             echo "Test suite should only be specified in testing mode."
44             echo "./tools/run.sh -? for usage."
45             exit 1
46         fi
47         test_suite=$OPTARG
48         ;;
49     c)
50         if [ "$COMMAND" != "testing" ] ; then
51             echo "Test case should only be specified in testing mode."
52             echo "./tools/run.sh -? for usage."
53             exit 1
54         fi
55         test_case=$OPTARG
56         ;;
57     \?)
58         usage
59         exit 1
60         ;;
61     esac
62 done
63
64 case $COMMAND in
65     "all_in_one" )
66         export DEPLOY_MODE='all-in-one'
67         ;;
68     "dns" | "mr" | "sdc" | "aai" | "mso" | "robot" | "vid" | "sdnc" | "portal" | "dcae" | "policy" | "appc" | "vfc" | "vnfsdk"| "multicloud" | "ccsdk" | "vvp" | "openstack" | "msb" | "oom" )
69         export DEPLOY_MODE='individual'
70         ;;
71     "testing" )
72         export DEPLOY_MODE='testing'
73         if  [ "$run" == false ] ; then
74             while true ; do
75                 echo "Warning: This test script will delete the contents of ../opt/ and ~/.m2."
76                 read -p "Would you like to continue? [y]es/[n]o: " yn
77                 case $yn in
78                     [Yy]*)
79                         break
80                         ;;
81                     [Nn]*)
82                         echo "Exiting."
83                         exit 0
84                         ;;
85                 esac
86             done
87         fi
88
89         export TEST_SUITE=$test_suite
90         export TEST_CASE=$test_case
91         rm -rf ./opt/
92         rm -rf ~/.m2/
93         ;;
94     * )
95         usage
96         exit 1
97 esac
98
99 vagrant destroy -f $COMMAND
100 vagrant up $COMMAND