diff options
Diffstat (limited to 'controller/share/dtf-controller/parse_credsfile')
-rw-r--r-- | controller/share/dtf-controller/parse_credsfile | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/controller/share/dtf-controller/parse_credsfile b/controller/share/dtf-controller/parse_credsfile new file mode 100644 index 0000000..2379e18 --- /dev/null +++ b/controller/share/dtf-controller/parse_credsfile @@ -0,0 +1,31 @@ +___perform_parsing() +{ + unset OS_USERNAME + local credsfile="$HOME/.dtf/private/os/$1.yml" + + if test -z "$1"; then + echo >&2 "argument expected: OpenStack ID" + return 1 + fi + + if test ! -f "$credsfile"; then + echo >&2 "file '$credsfile' not found" + return 1 + fi + + while read line; do + if [[ "$line" =~ ^([a-zA-Z0-9_]*):\ ?(.*)$ ]]; then + key="${BASH_REMATCH[1]}" + if test "$key" = os_nova_password; then + key=os_password + fi + eval set ${BASH_REMATCH[2]} + eval export "${key^^}"="\"$@\"" + fi + done < "$credsfile" +} + +unset OS_AUTH_URL OS_PASSWORD OS_TENANT_ID OS_TENANT_NAME OS_USERNAME +___perform_parsing "$@" + +# # vi: syntax=sh |