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 [arguments] \n"
25 echo -e " undercloud <user> <command> : Connect to Undercloud VM as <user> and execute command <command>\n"
26 echo -e " <user> Optional: Defaults to 'stack', <command> Optional: Defaults to none\n"
27 echo -e " overcloud <node> <command> : Connect to an Overcloud <node> and execute command <command>\n"
28 echo -e " <node> Required in format controller|compute<number>. Example: controller0\n"
29 echo -e " <command> Optional: Defaults to none\n"
30 echo -e " debug-stack : Print parsed deployment failures to stdout \n"
33 ##translates the command line argument
34 ##params: $@ the entire command line is passed
35 ##usage: parse_cmd_line() "$@"
39 match=($(resolve_cmd $1 $VALID_CMDS))
40 if [ ${#match[*]} -gt 1 ]; then
41 echo "$1 is ambiguous, possible matches: ${match[*]}" >&2
43 elif [ ${#match[*]} -lt 1 ]; then
44 echo "$1 is not a recognized command. Use -h to see acceptable list" >&2
47 match=$(echo $match | tr -d ' ')
57 # connect as stack by default
58 undercloud_connect stack
59 elif [ -z "$3" ]; then
60 undercloud_connect "$2"
62 undercloud_connect "$2" "$3"
69 elif [ -z "$3" ]; then
70 overcloud_connect "$2"
72 overcloud_connect "$2" "$3"
77 undercloud_connect stack "$(typeset -f debug_stack); debug_stack"
81 echo -e "\n\nThis script is used to interact with Apex deployments\n\n"
82 echo "Use -h to display help"