blob: 6f1cb54d4b7e0c9f4971525e47884e1f14e5dce0 [file] [log] [blame]
Victor Moralesdd074802017-07-26 16:06:35 -05001#!/bin/bash
2
Victor Morales90e9c742017-08-15 18:12:12 -05003function usage {
4 cat <<EOF
5Usage: run.sh Command [-y] [-?]
Nate Potter8a0c9452017-08-02 15:17:41 -07006Optional arguments:
7 -y
8 Skips warning prompt.
Victor Morales6a919972017-09-28 18:29:54 -07009 -g
10 Skips creation or retrieve image process.
11 -i
12 Skips installation service process.
Nate Potter8a0c9452017-08-02 15:17:41 -070013 -s <suite>
14 Test suite to use in testing mode.
15 -c <case>
16 Test case to use in testing mode.
17Commands:
18 all_in_one Deploy in all-in-one mode.
Victor Morales9d205bc2017-12-01 17:52:07 -080019 dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc|vfc|vnfsdk|multicloud|ccsdk|vvp|openstack|msb Deploy chosen service.
Nate Potter8a0c9452017-08-02 15:17:41 -070020 testing Deploy in testing mode.
21EOF
22}
23
24run=false
25test_suite="*"
26test_case="*"
27
Victor Morales90e9c742017-08-15 18:12:12 -050028COMMAND=$1
Nate Potter8a0c9452017-08-02 15:17:41 -070029
Victor Morales6a919972017-09-28 18:29:54 -070030while getopts "ygis:c:" OPTION "${@:2}"; do
Victor Morales5d5c5da2017-08-15 16:24:05 -050031 case "$OPTION" in
Nate Potter8a0c9452017-08-02 15:17:41 -070032 y)
Victor Morales5d5c5da2017-08-15 16:24:05 -050033 run=true
34 ;;
Victor Morales6a919972017-09-28 18:29:54 -070035 g)
36 export SKIP_GET_IMAGES="True"
37 ;;
38 i)
39 export SKIP_INSTALL="True"
40 ;;
Nate Potter8a0c9452017-08-02 15:17:41 -070041 s)
Victor Morales5d5c5da2017-08-15 16:24:05 -050042 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 ;;
Nate Potter8a0c9452017-08-02 15:17:41 -070049 c)
Victor Morales5d5c5da2017-08-15 16:24:05 -050050 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 ;;
Victor Morales90e9c742017-08-15 18:12:12 -050057 \?)
Victor Morales5d5c5da2017-08-15 16:24:05 -050058 usage
Victor Morales90e9c742017-08-15 18:12:12 -050059 exit 1
Victor Morales5d5c5da2017-08-15 16:24:05 -050060 ;;
61 esac
Nate Potter8a0c9452017-08-02 15:17:41 -070062done
63
64case $COMMAND in
Victor Moralesdd074802017-07-26 16:06:35 -050065 "all_in_one" )
Nate Potter8a0c9452017-08-02 15:17:41 -070066 export DEPLOY_MODE='all-in-one'
67 ;;
Victor Morales9d205bc2017-12-01 17:52:07 -080068 "dns" | "mr" | "sdc" | "aai" | "mso" | "robot" | "vid" | "sdnc" | "portal" | "dcae" | "policy" | "appc" | "vfc" | "vnfsdk"| "multicloud" | "ccsdk" | "vvp" | "openstack" | "msb" )
Nate Potter8a0c9452017-08-02 15:17:41 -070069 export DEPLOY_MODE='individual'
70 ;;
Victor Moralesdd074802017-07-26 16:06:35 -050071 "testing" )
72 export DEPLOY_MODE='testing'
Nate Potter8a0c9452017-08-02 15:17:41 -070073 if [ "$run" == false ] ; then
Victor Morales5d5c5da2017-08-15 16:24:05 -050074 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
Nate Potter8a0c9452017-08-02 15:17:41 -070087 fi
Victor Moralesdd074802017-07-26 16:06:35 -050088
Nate Potter8a0c9452017-08-02 15:17:41 -070089 export TEST_SUITE=$test_suite
90 export TEST_CASE=$test_case
Victor Morales80ef0a42017-08-21 19:17:07 -050091 rm -rf ./opt/
Nate Potter8a0c9452017-08-02 15:17:41 -070092 rm -rf ~/.m2/
93 ;;
Victor Morales20163062017-08-09 10:50:44 -050094 * )
Nate Potter8a0c9452017-08-02 15:17:41 -070095 usage
Victor Morales20163062017-08-09 10:50:44 -050096 exit 1
Victor Moralesdd074802017-07-26 16:06:35 -050097esac
Nate Potter8a0c9452017-08-02 15:17:41 -070098
99vagrant destroy -f $COMMAND
100vagrant up $COMMAND