Skip to content

Commit

Permalink
Merge pull request #1 from ggtakec/update_codes
Browse files Browse the repository at this point in the history
Updated interactive logic for values about OpenStack user, passphrase and tenant
  • Loading branch information
ggtakec authored Apr 7, 2021
2 parents 26cdbcc + 5af053f commit 0acd066
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 24 deletions.
67 changes: 52 additions & 15 deletions src/libexec/database/openstack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,25 @@ complement_op_user_name()
#
# Reset user id / passphrase / tokens
#
K2HR3CLI_OPENSTACK_USER_ID=""
K2HR3CLI_OPENSTACK_PASS=""
K2HR3CLI_OPENSTACK_TOKEN=""
K2HR3CLI_OPENSTACK_SCOPED_TOKEN=""

if [ "X${K2HR3CLI_USER}" != "X" ]; then
K2HR3CLI_OPENSTACK_USER=${K2HR3CLI_USER}
if [ "X${K2HR3CLI_OPT_INTERACTIVE}" = "X1" ]; then
_TOKEN_LIB_COMFIRM_TMP=""
completion_variable "_TOKEN_LIB_COMFIRM_TMP" "Would you use the K2HR3 User(${K2HR3CLI_USER}) as an OpenStack User? (y/n): " 1
if [ $? -eq 0 ]; then
if [ "X${_TOKEN_LIB_COMFIRM_TMP}" = "Xy" ] || [ "X${_TOKEN_LIB_COMFIRM_TMP}" = "Xyes" ] || [ "X${_TOKEN_LIB_COMFIRM_TMP}" = "XY" ] || [ "X${_TOKEN_LIB_COMFIRM_TMP}" = "XYES" ]; then
K2HR3CLI_OPENSTACK_USER=${K2HR3CLI_USER}
fi
fi
fi
fi

#
# Re-check
#
if [ "X${K2HR3CLI_OPENSTACK_USER}" = "X" ]; then
K2HR3CLI_OPENSTACK_USER_ID=""
K2HR3CLI_OPENSTACK_TOKEN=""
K2HR3CLI_OPENSTACK_SCOPED_TOKEN=""
fi
fi

Expand Down Expand Up @@ -99,11 +111,24 @@ complement_op_user_passphrase()
#
# Reset tokens
#
K2HR3CLI_OPENSTACK_TOKEN=""
K2HR3CLI_OPENSTACK_SCOPED_TOKEN=""

if [ "X${K2HR3CLI_PASS}" != "X" ]; then
K2HR3CLI_OPENSTACK_PASS=${K2HR3CLI_PASS}
if [ "X${K2HR3CLI_OPT_INTERACTIVE}" = "X1" ]; then
_TOKEN_LIB_COMFIRM_TMP=""
completion_variable "_TOKEN_LIB_COMFIRM_TMP" "Would you use the K2HR3 User passphrase as an OpenStack User? (y/n): " 1
if [ $? -eq 0 ]; then
if [ "X${_TOKEN_LIB_COMFIRM_TMP}" = "Xy" ] || [ "X${_TOKEN_LIB_COMFIRM_TMP}" = "Xyes" ] || [ "X${_TOKEN_LIB_COMFIRM_TMP}" = "XY" ] || [ "X${_TOKEN_LIB_COMFIRM_TMP}" = "XYES" ]; then
K2HR3CLI_OPENSTACK_PASS=${K2HR3CLI_PASS}
fi
fi
fi
fi

#
# Re-check
#
if [ "X${K2HR3CLI_OPENSTACK_PASS}" = "X" ]; then
K2HR3CLI_OPENSTACK_TOKEN=""
K2HR3CLI_OPENSTACK_SCOPED_TOKEN=""
fi
fi

Expand Down Expand Up @@ -135,12 +160,24 @@ complement_op_tenant()
#
# Reset tenant id / tokens
#
K2HR3CLI_OPENSTACK_TENANT_ID=""
K2HR3CLI_OPENSTACK_TOKEN=""
K2HR3CLI_OPENSTACK_SCOPED_TOKEN=""

if [ "X${K2HR3CLI_TENANT}" != "X" ]; then
K2HR3CLI_OPENSTACK_TENANT=${K2HR3CLI_TENANT}
if [ "X${K2HR3CLI_OPT_INTERACTIVE}" = "X1" ]; then
_TOKEN_LIB_COMFIRM_TMP=""
completion_variable "_TOKEN_LIB_COMFIRM_TMP" "Would you use the K2HR3 Tenant(${K2HR3CLI_TENANT}) as an OpenStack Tenant(Project)? (y/n): " 1
if [ $? -eq 0 ]; then
if [ "X${_TOKEN_LIB_COMFIRM_TMP}" = "Xy" ] || [ "X${_TOKEN_LIB_COMFIRM_TMP}" = "Xyes" ] || [ "X${_TOKEN_LIB_COMFIRM_TMP}" = "XY" ] || [ "X${_TOKEN_LIB_COMFIRM_TMP}" = "XYES" ]; then
K2HR3CLI_OPENSTACK_TENANT=${K2HR3CLI_TENANT}
fi
fi
fi
fi

#
# Re-check
#
if [ "X${K2HR3CLI_OPENSTACK_TENANT}" = "X" ]; then
K2HR3CLI_OPENSTACK_TENANT_ID=""
K2HR3CLI_OPENSTACK_SCOPED_TOKEN=""
fi
fi
#
Expand Down
9 changes: 0 additions & 9 deletions src/libexec/database/options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -485,25 +485,16 @@ parse_dbaas_option()
K2HR3CLI_OPENSTACK_USER=${_OPT_TMP_DBAAS_OPENSTACK_USER}
# shellcheck disable=SC2034
K2HR3CLI_OPENSTACK_USER_ID=""
else
# shellcheck disable=SC2034
K2HR3CLI_OPENSTACK_USER=${K2HR3CLI_USER}
fi
if [ -n "${_OPT_TMP_DBAAS_OPENSTACK_PASS}" ]; then
# shellcheck disable=SC2034
K2HR3CLI_OPENSTACK_PASS=${_OPT_TMP_DBAAS_OPENSTACK_PASS}
else
# shellcheck disable=SC2034
K2HR3CLI_OPENSTACK_PASS=${K2HR3CLI_PASS}
fi
if [ -n "${_OPT_TMP_DBAAS_OPENSTACK_TENANT}" ]; then
# shellcheck disable=SC2034
K2HR3CLI_OPENSTACK_TENANT=${_OPT_TMP_DBAAS_OPENSTACK_TENANT}
# shellcheck disable=SC2034
K2HR3CLI_OPENSTACK_TENANT_ID=""
else
# shellcheck disable=SC2034
K2HR3CLI_OPENSTACK_TENANT=${K2HR3CLI_TENANT}
fi
if [ -n "${_OPT_TMP_DBAAS_OPENSTACK_NO_SECGRP}" ]; then
# shellcheck disable=SC2034
Expand Down

0 comments on commit 0acd066

Please sign in to comment.