79 lines
2.5 KiB
Plaintext
79 lines
2.5 KiB
Plaintext
|
|
#!/bin/bash
|
|
|
|
_rally()
|
|
{
|
|
declare -A SUBCOMMANDS
|
|
declare -A OPTS
|
|
|
|
OPTS["info_BenchmarkScenarios"]=""
|
|
OPTS["info_DeployEngines"]=""
|
|
OPTS["info_SLA"]=""
|
|
OPTS["info_ServerProviders"]=""
|
|
OPTS["info_find"]="--query"
|
|
OPTS["info_list"]=""
|
|
OPTS["use_deployment"]="--uuid --name"
|
|
OPTS["use_task"]="--uuid"
|
|
OPTS["use_verification"]="--uuid"
|
|
OPTS["task_abort"]="--uuid"
|
|
OPTS["task_delete"]="--force --uuid"
|
|
OPTS["task_detailed"]="--uuid --iterations-data"
|
|
OPTS["task_list"]=""
|
|
OPTS["task_plot2html"]="--uuid --out --open"
|
|
OPTS["task_report"]="--uuid --out --open"
|
|
OPTS["task_results"]="--uuid"
|
|
OPTS["task_sla_check"]="--uuid --json"
|
|
OPTS["task_start"]="--deploy-id --task --tag --no-use"
|
|
OPTS["task_status"]="--uuid"
|
|
OPTS["task_validate"]="--deploy-id --task"
|
|
OPTS["show_flavors"]="--deploy-id"
|
|
OPTS["show_images"]="--deploy-id"
|
|
OPTS["show_keypairs"]="--deploy-id"
|
|
OPTS["show_networks"]="--deploy-id"
|
|
OPTS["show_secgroups"]="--deploy-id"
|
|
OPTS["verify_compare"]="--uuid-1 --uuid-2 --csv --html --json --output-file --threshold"
|
|
OPTS["verify_detailed"]="--uuid --sort-by"
|
|
OPTS["verify_list"]=""
|
|
OPTS["verify_results"]="--uuid --html --json --output-file"
|
|
OPTS["verify_show"]="--uuid --sort-by --detailed"
|
|
OPTS["verify_start"]="--deploy-id --set --regex --tempest-config --no-use"
|
|
OPTS["deployment_check"]="--uuid"
|
|
OPTS["deployment_config"]="--uuid"
|
|
OPTS["deployment_create"]="--name --fromenv --filename --no-use"
|
|
OPTS["deployment_destroy"]="--uuid"
|
|
OPTS["deployment_list"]=""
|
|
OPTS["deployment_recreate"]="--uuid"
|
|
OPTS["deployment_show"]="--uuid"
|
|
|
|
|
|
for OPT in ${!OPTS[*]} ; do
|
|
CMDSUB=(${OPT//_/ })
|
|
SUBCOMMANDS[${CMDSUB[0]}]+="${CMDSUB[1]} "
|
|
done
|
|
|
|
COMMANDS="${!SUBCOMMANDS[*]}"
|
|
COMPREPLY=()
|
|
|
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
|
local prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
if [[ $cur =~ (\.|\~|\/).* ]] ; then
|
|
_filedir
|
|
elif [ $COMP_CWORD == "1" ] ; then
|
|
COMPREPLY=($(compgen -W "$COMMANDS" -- ${cur}))
|
|
elif [ $COMP_CWORD == "2" ] ; then
|
|
COMPREPLY=($(compgen -W "${SUBCOMMANDS[${prev}]}" -- ${cur}))
|
|
else
|
|
if [ $prev == "--filename" ] ; then
|
|
_filedir '@(json|ya?ml)'
|
|
elif [ $prev == "--output-file" ] || [ $prev == "--out" ]; then
|
|
_filedir
|
|
else
|
|
COMMAND="${COMP_WORDS[1]}_${COMP_WORDS[2]}"
|
|
COMPREPLY=($(compgen -W "${OPTS[$COMMAND]}" -- ${cur}))
|
|
fi
|
|
fi
|
|
return 0
|
|
}
|
|
complete -F _rally rally
|