2 # Utility script used to interact with a deployment
3 # @author Tim Rozet (trozet@redhat.com)
5 CONFIG=${CONFIG:-'/var/opt/opnfv'}
6 RESOURCES=${RESOURCES:-"$CONFIG/images"}
7 LIB=${LIB:-"$CONFIG/lib"}
8 VALID_CMDS="undercloud overcloud debug-stack -h --help"
10 source $LIB/utility-functions.sh
16 local inv=(${list[*]##${given}*})
17 local OIFS=$IFS; IFS='|'; local pat="${inv[*]}"; IFS=$OIFS
19 echo "${list[*]##+($pat)}"
24 echo -e "Usage:\n$0 subcommand [ arguments ]\n"
25 echo -e "Arguments:\n"
26 echo -e " undercloud [ user [ command ] ] Connect to Undercloud VM as user and optionally execute a command\n"
27 echo -e " user Optional: Defaults to 'stack'\n"
28 echo -e " command Optional: Defaults to none\n"
30 echo -e " overcloud [ node [ command ] ] Connect to an Overcloud node and optionally execute a command\n"
31 echo -e " node Required: in format controller|compute<number>. Example: controller0\n"
32 echo -e " command Optional: Defaults to none\n"
34 echo -e " debug-stack Print parsed deployment failures to stdout \n"
36 echo -e " mock-detached on | off Add firewall rules to the jump host to mock a detached deployment \n"
39 ##translates the command line argument
40 ##params: $@ the entire command line is passed
41 ##usage: parse_cmd_line() "$@"
45 match=($(resolve_cmd $1 $VALID_CMDS))
46 if [ ${#match[*]} -gt 1 ]; then
47 echo "$1 is ambiguous, possible matches: ${match[*]}" >&2
49 elif [ ${#match[*]} -lt 1 ]; then
50 echo "$1 is not a recognized command. Use -h to see acceptable list" >&2
53 match=$(echo $match | tr -d ' ')
63 # connect as stack by default
64 undercloud_connect stack
65 elif [ -z "$3" ]; then
66 undercloud_connect "$2"
68 undercloud_connect "$2" "$3"
75 elif [ -z "$3" ]; then
76 overcloud_connect "$2"
78 overcloud_connect "$2" "$3"
83 undercloud_connect stack "$(typeset -f debug_stack); debug_stack"
87 if [ "$2" == "on" ]; then
88 echo "Blocking output http and https traffic"
89 iptables -A OUTPUT -p tcp --dport 80 -j REJECT
90 iptables -A OUTPUT -p tcp --dport 443 -j REJECT
91 elif [ "$2" == "off" ]; then
92 echo "Allowing output http and https traffic"
93 iptables -D OUTPUT -p tcp --dport 80 -j REJECT
94 iptables -D OUTPUT -p tcp --dport 443 -j REJECT
101 echo -e "\n\nThis script is used to interact with Apex deployments\n\n"
102 echo "Use -h to display help"