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 opendaylight debug-stack mock-detached -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 " opendaylight Connect to OpenDaylight Karaf console\n"
32 echo -e " overcloud [ node [ command ] ] Connect to an Overcloud node and optionally execute a command\n"
33 echo -e " node Required: in format controller|compute<number>. Example: controller0\n"
34 echo -e " command Optional: Defaults to none\n"
36 echo -e " debug-stack Print parsed deployment failures to stdout \n"
38 echo -e " mock-detached on | off Add firewall rules to the jump host to mock a detached deployment \n"
41 ##translates the command line argument
42 ##params: $@ the entire command line is passed
43 ##usage: parse_cmd_line() "$@"
47 match=($(resolve_cmd $1 $VALID_CMDS))
48 if [ ${#match[*]} -gt 1 ]; then
49 echo "$1 is ambiguous, possible matches: ${match[*]}" >&2
51 elif [ ${#match[*]} -lt 1 ]; then
52 echo "$1 is not a recognized command. Use -h to see acceptable list" >&2
55 match=$(echo $match | tr -d ' ')
65 # connect as stack by default
66 undercloud_connect stack
67 elif [ -z "$3" ]; then
68 undercloud_connect "$2"
70 undercloud_connect "$2" "$3"
77 elif [ -z "$3" ]; then
78 overcloud_connect "$2"
80 overcloud_connect "$2" "$3"
89 undercloud_connect stack "$(typeset -f debug_stack); debug_stack"
93 if [ "$2" == "on" ]; then
94 echo "Ensuring we can talk to gerrit.opnfv.org"
95 iptables -A OUTPUT -p tcp -d gerrit.opnfv.org --dport 443 -j ACCEPT
96 echo "Blocking output http (80) traffic"
97 iptables -A OUTPUT -p tcp --dport 80 -j REJECT
98 iptables -A FORWARD -p tcp --dport 80 -j REJECT
99 echo "Blocking output https (443) traffic"
100 iptables -A OUTPUT -p tcp --dport 443 -j REJECT
101 iptables -A FORWARD -p tcp --dport 443 -j REJECT
102 echo "Blocking output dns (53) traffic"
103 iptables -A FORWARD -p tcp --dport 53 -j REJECT
104 elif [ "$2" == "off" ]; then
105 echo "Cleaning gerrit.opnfv.org specific rule"
106 iptables -D OUTPUT -p tcp -d gerrit.opnfv.org --dport 443 -j ACCEPT
107 echo "Allowing output http (80) traffic"
108 iptables -D OUTPUT -p tcp --dport 80 -j REJECT
109 iptables -D FORWARD -p tcp --dport 80 -j REJECT
110 echo "Allowing output https (443) traffic"
111 iptables -D OUTPUT -p tcp --dport 443 -j REJECT
112 iptables -D FORWARD -p tcp --dport 443 -j REJECT
113 echo "Allowing output dns (53) traffic"
114 iptables -D OUTPUT -p tcp --dport 53 -j REJECT
115 iptables -D FORWARD -p tcp --dport 53 -j REJECT
122 echo -e "\n\nThis script is used to interact with Apex deployments\n\n"
123 echo "Use -h to display help"