2 # Utility script used to interact with a deployment
3 # @author Tim Rozet (trozet@redhat.com)
5 # Backwards compat for old ENV Vars
7 if [ -n "$CONFIG" ]; then
8 echo -e "${red}WARNING: ENV var CONFIG is Deprecated, please unset CONFIG and export BASE in its place${reset}"
9 echo -e "${red}WARNING: CONFIG will be removed in E${reset}"
12 if [ -n "$RESOURCES" ]; then
13 echo -e "${red}WARNING: ENV var RESOURCES is Deprecated, please unset RESOURCES and export IMAGES in its place${reset}"
14 echo -e "${red}WARNING: RESOURCES will be removed in E${reset}"
18 BASE=${BASE:-'/var/opt/opnfv'}
19 IMAGES=${IMAGES:-"$BASE/images"}
20 LIB=${LIB:-"$BASE/lib"}
21 VALID_CMDS="undercloud overcloud opendaylight debug-stack mock-detached -h --help"
23 source $LIB/utility-functions.sh
29 local inv=(${list[*]##${given}*})
30 local OIFS=$IFS; IFS='|'; local pat="${inv[*]}"; IFS=$OIFS
32 echo "${list[*]##+($pat)}"
37 echo -e "Usage:\n$0 subcommand [ arguments ]\n"
38 echo -e "Arguments:\n"
39 echo -e " undercloud [ user [ command ] ] Connect to Undercloud VM as user and optionally execute a command"
40 echo -e " user Optional: Defaults to 'stack'"
41 echo -e " command Optional: Defaults to none"
43 echo -e " opendaylight Connect to OpenDaylight Karaf console"
45 echo -e " overcloud [ node [ command ] ] Connect to an Overcloud node and optionally execute a command"
46 echo -e " node Required: in format controller|compute<number>. Example: controller0"
47 echo -e " command Optional: Defaults to none"
49 echo -e " debug-stack Print parsed deployment failures to stdout"
51 echo -e " mock-detached on | off Add firewall rules to the jump host to mock a detached deployment\n"
54 ##translates the command line argument
55 ##params: $@ the entire command line is passed
56 ##usage: parse_cmd_line() "$@"
60 match=($(resolve_cmd $1 $VALID_CMDS))
61 if [ ${#match[*]} -gt 1 ]; then
62 echo "$1 is ambiguous, possible matches: ${match[*]}" >&2
64 elif [ ${#match[*]} -lt 1 ]; then
65 echo "$1 is not a recognized command. Use -h to see acceptable list" >&2
68 match=$(echo $match | tr -d ' ')
78 # connect as stack by default
79 undercloud_connect stack
80 elif [ -z "$3" ]; then
81 undercloud_connect "$2"
83 undercloud_connect "$2" "$3"
90 elif [ -z "$3" ]; then
91 overcloud_connect "$2"
93 overcloud_connect "$2" "$3"
102 undercloud_connect stack "$(typeset -f debug_stack); debug_stack"
106 if [ "$2" == "on" ]; then
107 echo "Ensuring we can talk to gerrit.opnfv.org"
108 iptables -A OUTPUT -p tcp -d gerrit.opnfv.org --dport 443 -j ACCEPT
109 echo "Blocking output http (80) traffic"
110 iptables -A OUTPUT -p tcp --dport 80 -j REJECT
111 iptables -A FORWARD -p tcp --dport 80 -j REJECT
112 echo "Blocking output https (443) traffic"
113 iptables -A OUTPUT -p tcp --dport 443 -j REJECT
114 iptables -A FORWARD -p tcp --dport 443 -j REJECT
115 echo "Blocking output dns (53) traffic"
116 iptables -A FORWARD -p tcp --dport 53 -j REJECT
117 elif [ "$2" == "off" ]; then
118 echo "Cleaning gerrit.opnfv.org specific rule"
119 iptables -D OUTPUT -p tcp -d gerrit.opnfv.org --dport 443 -j ACCEPT
120 echo "Allowing output http (80) traffic"
121 iptables -D OUTPUT -p tcp --dport 80 -j REJECT
122 iptables -D FORWARD -p tcp --dport 80 -j REJECT
123 echo "Allowing output https (443) traffic"
124 iptables -D OUTPUT -p tcp --dport 443 -j REJECT
125 iptables -D FORWARD -p tcp --dport 443 -j REJECT
126 echo "Allowing output dns (53) traffic"
127 iptables -D OUTPUT -p tcp --dport 53 -j REJECT
128 iptables -D FORWARD -p tcp --dport 53 -j REJECT
135 echo -e "\n\nThis script is used to interact with Apex deployments\n\n"
136 echo "Use -h to display help"