Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Victor Morales | 90e9c74 | 2017-08-15 18:12:12 -0500 | [diff] [blame] | 3 | function usage { |
| 4 | cat <<EOF |
| 5 | Usage: run.sh Command [-y] [-?] |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 6 | Optional arguments: |
| 7 | -y |
| 8 | Skips warning prompt. |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 9 | -g |
| 10 | Skips creation or retrieve image process. |
| 11 | -i |
| 12 | Skips installation service process. |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 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. |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame^] | 19 | dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc|vfc|vnfsdk|multicloud|ccsdk|vvp|openstack Deploy chosen service. |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 20 | testing Deploy in testing mode. |
| 21 | EOF |
| 22 | } |
| 23 | |
| 24 | run=false |
| 25 | test_suite="*" |
| 26 | test_case="*" |
| 27 | |
Victor Morales | 90e9c74 | 2017-08-15 18:12:12 -0500 | [diff] [blame] | 28 | COMMAND=$1 |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 29 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 30 | while getopts "ygis:c:" OPTION "${@:2}"; do |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 31 | case "$OPTION" in |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 32 | y) |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 33 | run=true |
| 34 | ;; |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 35 | g) |
| 36 | export SKIP_GET_IMAGES="True" |
| 37 | ;; |
| 38 | i) |
| 39 | export SKIP_INSTALL="True" |
| 40 | ;; |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 41 | s) |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 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 | ;; |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 49 | c) |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 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 | ;; |
Victor Morales | 90e9c74 | 2017-08-15 18:12:12 -0500 | [diff] [blame] | 57 | \?) |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 58 | usage |
Victor Morales | 90e9c74 | 2017-08-15 18:12:12 -0500 | [diff] [blame] | 59 | exit 1 |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 60 | ;; |
| 61 | esac |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 62 | done |
| 63 | |
| 64 | case $COMMAND in |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 65 | "all_in_one" ) |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 66 | export DEPLOY_MODE='all-in-one' |
| 67 | ;; |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame^] | 68 | "dns" | "mr" | "sdc" | "aai" | "mso" | "robot" | "vid" | "sdnc" | "portal" | "dcae" | "policy" | "appc" | "vfc" | "vnfsdk"| "multicloud" | "ccsdk" | "vvp" | "openstack" ) |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 69 | export DEPLOY_MODE='individual' |
| 70 | ;; |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 71 | "testing" ) |
| 72 | export DEPLOY_MODE='testing' |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 73 | if [ "$run" == false ] ; then |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 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 |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 87 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 88 | |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 89 | export TEST_SUITE=$test_suite |
| 90 | export TEST_CASE=$test_case |
Victor Morales | 80ef0a4 | 2017-08-21 19:17:07 -0500 | [diff] [blame] | 91 | rm -rf ./opt/ |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 92 | rm -rf ~/.m2/ |
| 93 | ;; |
Victor Morales | 2016306 | 2017-08-09 10:50:44 -0500 | [diff] [blame] | 94 | * ) |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 95 | usage |
Victor Morales | 2016306 | 2017-08-09 10:50:44 -0500 | [diff] [blame] | 96 | exit 1 |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 97 | esac |
Nate Potter | 8a0c945 | 2017-08-02 15:17:41 -0700 | [diff] [blame] | 98 | |
| 99 | vagrant destroy -f $COMMAND |
| 100 | vagrant up $COMMAND |