From 278a8fcc9ac9d18d8192d22aca50b39371894db5 Mon Sep 17 00:00:00 2001 From: shangxdy Date: Wed, 17 Aug 2016 16:09:53 +0800 Subject: Fix bug: authentication error when deploy vRNC with nfv tosca template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When deploy vRNC, the follow errors occured: openstack stack create -t ./vRNC_Hot_Template.yaml vRNC_Stack The request you have made requires authentication. (HTTP 401) (Request-ID: req-d0ddd5bd-5291-4b2f-ab92-95618881647a) The reason is that creating user is before creating project, and the order will be reverse. JIRA:PARSER-90 Change-Id: I890be71bfe7b2ec5f393f235c4c79c705340dfaa Signed-off-by: shangxdy --- tests/functest_run.sh | 74 ++++++++++++++++++++++++++++--------------------- tests/parser_install.sh | 2 ++ 2 files changed, 44 insertions(+), 32 deletions(-) (limited to 'tests') diff --git a/tests/functest_run.sh b/tests/functest_run.sh index d60e894..e5341c0 100755 --- a/tests/functest_run.sh +++ b/tests/functest_run.sh @@ -8,7 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -PARSER_CI_DEBUG=${CI_DEBUG:-true} +PARSER_CI_DEBUG=${CI_DEBUG:-false} [[ "${PARSER_CI_DEBUG}" == "true" ]] && set -x PARSER_IMAGE_URL_FILE=cirros-0.3.0-x86_64-disk.img @@ -21,6 +21,7 @@ PARSER_VM_FLAVOR=m1.tiny PARSER_USER=parser PARSER_PASSWORD=parser +PARSER_EMAIL='shang.xiaodong@zte.com.cn' PARSER_PROJECT=parser PARSER_TENANT=${PARSER_PROJECT} @@ -41,7 +42,7 @@ download_parser_image() { } echo "Download image ${PARSER_IMAGE_URL_FILE}..." - wget "${PARSER_IMAGE_URL}" -o "${PARSER_IMAGE_FILE}" + wget ${PARSER_IMAGE_URL} -o ${PARSER_IMAGE_FILE} } register_parser_image() { @@ -53,36 +54,39 @@ register_parser_image() { echo "Registe image ${PARSER_IMAGE_NAME}..." openstack image create "${PARSER_IMAGE_NAME}" \ --public \ - --disk-format "${PARSER_IMAGE_FORMAT}" \ + --disk-format ${PARSER_IMAGE_FORMAT} \ --container-format bare \ - --file "${PARSER_IMAGE_FILE}" + --file ${PARSER_IMAGE_FILE} } create_parser_user_and_project() { - # 1. create parser user. - openstack user list | grep -qwo "${PARSER_USER}" && { - echo "User ${PARSER_USER} exist, doesn't create again." - } || { - openstack user create "${PARSER_USER}" --password "${PARSER_PASSWORD}" - echo "Create user ${PARSER_USER} successful." - } - # 2. create parser project + # 1. create parser project openstack project list | grep -qwo "${PARSER_PROJECT}" && { echo "Project ${PARSER_PROJECT} exist, doesn't create agian." } || { - openstack project create "${PARSER_PROJECT}" + openstack project create ${PARSER_PROJECT} \ + --description "Project for parser test" echo "Create project ${PARSER_PROJECT} successful." } + # 2. create parser user. + openstack user list | grep -qwo ${PARSER_USER} && { + echo "User ${PARSER_USER} exist, doesn't create again." + } || { + openstack user create ${PARSER_USER} --password ${PARSER_PASSWORD} \ + --project ${PARSER_PROJECT} --email ${PARSER_EMAIL} + echo "Create user ${PARSER_USER} successful." + } + # 3. grant role for parser user - openstack user role list "${PARSER_USER}" --project "${PARSER_PROJECT}" \ - | grep -qow " ${PARSER_ROLE}" && { + openstack user role list ${PARSER_USER} --project ${PARSER_PROJECT} \ + | grep -qow ${PARSER_ROLE} && { echo "User ${PARSER_USER} has role ${PARSER_ROLE} in project ${PARSER_PROJECT}, doesn't create." } || { - openstack role add "${PARSER_ROLE}" --user "${PARSER_USER}" \ - --project "${PARSER_PROJECT}" + openstack role add ${PARSER_ROLE} --user ${PARSER_USER} \ + --project ${PARSER_PROJECT} echo "Grant user ${PARSER_USER} the role ${PARSER_ROLE} in project ${PARSER_PROJECT} successful." } @@ -90,10 +94,10 @@ create_parser_user_and_project() { change_env_to_parser_user_project() { - export OS_USERNAME="$PARSER_USER" - export OS_PASSWORD="$PARSER_PASSWORD" - export OS_PROJECT_NAME="$PARSER_PROJECT" - export OS_TENANT_NAME="$PARSER_TENANT" + export OS_USERNAME=${PARSER_USER} + export OS_PASSWORD=${PARSER_PASSWORD} + export OS_PROJECT_NAME=${PARSER_PROJECT} + export OS_TENANT_NAME=${PARSER_TENANT} } @@ -105,7 +109,7 @@ translator_and_deploy_vRNC() { openstack stack delete --yes --wait ${PARSER_STACK_NAME} } # 2. Switch env to parser project temporally - echo "switch openstak env to parser project" + echo "switch openstack env to parser project" change_env_to_parser_user_project # 3. Translator yaml @@ -118,6 +122,7 @@ translator_and_deploy_vRNC() { openstack stack create -t ${VRNC_OUTPUT_TEMPLATE_FILE} ${PARSER_STACK_NAME} # 5. Wait for create vRNC + echo "Waiting for deploying stack..." sleep 180 # 6. Validate the deploy result. @@ -202,34 +207,39 @@ reset_parser_test() { --project "${PARSER_PROJECT}" } + openstack user list | grep -qow "${PARSER_USER}" && { + openstack user delete "${PARSER_USER}" + } + openstack project list | grep -qwo "${PARSER_PROJECT}" && { openstack project delete "${PARSER_PROJECT}" } - openstack user list | grep -qow "${PARSER_USER}" && { - openstack user delete "${PARSER_USER}" - } + echo "" + echo "======================= Parser functest end ==========================" + echo "" + echo "" } - +echo "" +echo "" echo "======================= Parser functest begin ==========================" +echo "" trap reset_parser_test EXIT # start syslog for loghander service rsyslog restart -echo " ========= 1/4. Preparing VM image for parser... ========= " +echo "|========= 1/4. Preparing VM image for parser... =========|" download_parser_image register_parser_image -echo " ========= 2/4. Creating test user for parser... ========= " +echo "|========= 2/4. Creating test user for parser... =========|" create_parser_user_and_project -echo " ========= 3/4. Parse -> translate -> deploy vRNC... ========= " +echo "|========= 3/4. Parse -> translate -> deploy vRNC... =========|" translator_and_deploy_vRNC -echo " ========= 4/4. Test ok... ========= " - -echo "======================= Parser functest end ==========================" +echo "|========= 4/4. Test ok... =========|" diff --git a/tests/parser_install.sh b/tests/parser_install.sh index 48f07ac..308b8bc 100755 --- a/tests/parser_install.sh +++ b/tests/parser_install.sh @@ -8,6 +8,8 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +set +e + parser_repos_dir=$1 # start syslog for loghander -- cgit 1.2.3-korg