[p/parser] Add aarch64 download option 97/54197/9
authorCharalampos Kominos <Charalampos.Kominos@enea.com>
Tue, 20 Mar 2018 13:06:08 +0000 (14:06 +0100)
committerCharalampos Kominos <charalampos.kominos@enea.com>
Wed, 28 Mar 2018 10:38:33 +0000 (10:38 +0000)
Hardcoded values within the parser project create problems
for opnfv-armband. In this patch we :
1) Add aarch64 image download conditional
2) Fix typos and comments

JIRA: ARMBAND-369
JIRA: PARSER-175

Change-Id: I001087a8783fef66336e9bddc8d67342f6810a1f
Signed-off-by: Charalampos Kominos <charalampos.kominos@enea.com>
tests/functest_run.sh

index 3f7656c..08181fa 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash -e
 ##############################################################################
-# Copyright (c) 2016 ZTE Corporation.
+# Copyright (c) 2018 ZTE Corporation, ENEA AB.
 #
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Apache License, Version 2.0
@@ -9,7 +9,8 @@
 ##############################################################################
 
 PARSER_CI_DEBUG=${CI_DEBUG:-false}
-PRASER_WORK_DIR=$(cd $(dirname $0) && pwd)
+PARSER_WORK_DIR=$(cd $(dirname $0) && pwd)
+POD_ARCH=${POD_ARCH:-$(uname -m)}
 
 [[ "${PARSER_CI_DEBUG}" == "true" ]] && {
     set -x
@@ -24,18 +25,28 @@ if [ -e "${LOCAL_IMAGE_FILE}" ]; then
     echo "Input local image file: ${LOCAL_IMAGE_FILE}"
     PARSER_IMAGE_URL_FILE=${LOCAL_IMAGE_FILE}
 else
-    echo "No local image file or the file(${LOCAL_IMAGE_FILE}) doesn't exsit!"
+    echo "No local image file or the file(${LOCAL_IMAGE_FILE}) doesn't exist!"
+
+    if [[ ${POD_ARCH} = 'aarch64' ]]; then
+        echo ""
+        echo "${POD_ARCH} Detected. The proper image file for that architecture will be downloaded"
+        PARSER_IMAGE_URL_FILE=cirros-0.4.0-aarch64-disk.img
+    else
+        PARSER_IMAGE_URL_FILE=cirros-0.3.5-x86_64-disk.img
+        # PARSER_IMAGE_URL=https://launchpad.net/cirros/trunk/0.3.0/+download/${PARSER_IMAGE_URL_FILE}
+    fi
 
-    PARSER_IMAGE_URL_FILE=cirros-0.3.5-x86_64-disk.img
     PARSER_IMAGE_VERSION=$(echo ${PARSER_IMAGE_URL_FILE} | awk -F- '{print $2}')
-    # PARSER_IMAGE_URL=https://launchpad.net/cirros/trunk/0.3.0/+download/${PARSER_IMAGE_URL_FILE}
     PARSER_IMAGE_URL=http://download.cirros-cloud.net/${PARSER_IMAGE_VERSION}/${PARSER_IMAGE_URL_FILE}
     echo "so will download image(${PARSER_IMAGE_URL_FILE}) from ${PARSER_IMAGE_URL}."
+
 fi
 
 # PARSER_IMAGE_NAME=rhel-6.5-test-image
-# fiexd image name according to the translator default vlaue of images
+# fixed image name according to the translator's default value of images
+
 PARSER_IMAGE_NAME=cirros-0.3.2-x86_64-uec
+
 PARSER_IMAGE_FILE="${PARSER_IMAGE_NAME}.img"
 PARSER_IMAGE_FORMAT=qcow2
 
@@ -54,23 +65,24 @@ VM_FLAVOR_DISK=1
 
 PARSER_STACK_NAME=vRNC_Stack
 
-# VRNC_INPUT_TEMPLATE_FILE=${PRASER_WORK_DIR}/../tosca2heat/tosca-parser/toscaparser/extensions/nfv/tests/data/vRNC/Definitions/vRNC.yaml
-# VRNC_INPUT_TEMPLATE_RAW_FILE=${PRASER_WORK_DIR}/../tosca2heat/heat-translator/translator/tests/data/test_tosca_nfv_sample.yaml
-VRNC_INPUT_TEMPLATE_RAW_FILE=${PRASER_WORK_DIR}/../tosca2heat/heat-translator/translator/tests/data/vRNC/Definitions/vRNC.yaml
-VRNC_OUTPUT_TEMPLATE_FILE=${PRASER_WORK_DIR}/../tosca2heat/heat-translator/translator/tests/data/vRNC/vRNC_Hot_Template.yaml
+# VRNC_INPUT_TEMPLATE_FILE=${PARSER_WORK_DIR}/../tosca2heat/tosca-parser/toscaparser/extensions/nfv/tests/data/vRNC/Definitions/vRNC.yaml
+# VRNC_INPUT_TEMPLATE_RAW_FILE=${PARSER_WORK_DIR}/../tosca2heat/heat-translator/translator/tests/data/test_tosca_nfv_sample.yaml
+VRNC_INPUT_TEMPLATE_RAW_FILE=${PARSER_WORK_DIR}/../tosca2heat/heat-translator/translator/tests/data/vRNC/Definitions/vRNC.yaml
+VRNC_OUTPUT_TEMPLATE_FILE=${PARSER_WORK_DIR}/../tosca2heat/heat-translator/translator/tests/data/vRNC/vRNC_Hot_Template.yaml
 
 VRNC_INPUT_TEMPLATE_FILE=${VRNC_INPUT_TEMPLATE_RAW_FILE%.*}_patch.yaml
 
 download_parser_image() {
     [ -e "${PARSER_IMAGE_URL_FILE}" ] && {
-        echo "  Image ${PARSER_IMAGE_URL_FILE} has bee cached, needn't download again."
+        echo "  Image ${PARSER_IMAGE_URL_FILE} has been cached, no need to download again."
         cp ${PARSER_IMAGE_URL_FILE} ${PARSER_IMAGE_FILE}
         return 0
     }
 
     echo ""
     echo "  Download image ${PARSER_IMAGE_URL_FILE}..."
-    wget ${PARSER_IMAGE_URL} -o ${PARSER_IMAGE_FILE}
+
+    wget ${PARSER_IMAGE_URL} -O ${PARSER_IMAGE_FILE} -o download.log
 }
 
 register_parser_image_and_flavor() {
@@ -87,17 +99,29 @@ register_parser_image_and_flavor() {
     }
 
     openstack ${debug} image list | grep -qwo "${PARSER_IMAGE_NAME}" && {
-        echo "  Image ${PARSER_IMAGE_NAME} has bee registed, needn't registe again."
+        echo "  Image ${PARSER_IMAGE_NAME} has been registed, no need to register again."
         return 0
     }
 
     echo ""
-    echo "  Registe image ${PARSER_IMAGE_NAME}..."
-    openstack ${debug} image create "${PARSER_IMAGE_NAME}" \
+    echo "  Register image ${PARSER_IMAGE_NAME}..."
+
+    if [[ ${POD_ARCH} = 'aarch64' ]]; then
+
+        openstack ${debug} image create "${PARSER_IMAGE_NAME}" \
+                            --public \
+                            --disk-format ${PARSER_IMAGE_FORMAT} \
+                            --container-format bare \
+                            --property hw_firmware_type="uefi" \
+                            --property short_id="cirros.aarch64" \
+                            --file ${PARSER_IMAGE_FILE}
+    else
+        openstack ${debug} image create "${PARSER_IMAGE_NAME}" \
                            --public \
                            --disk-format ${PARSER_IMAGE_FORMAT} \
                            --container-format bare \
                            --file ${PARSER_IMAGE_FILE}
+    fi
 
 }
 
@@ -105,7 +129,7 @@ create_parser_user_and_project() {
 
     # 1. create parser project
     openstack ${debug} project list | grep -qwo "${PARSER_PROJECT}" && {
-        echo "  Project ${PARSER_PROJECT} exist, doesn't create agian."
+        echo "  Project ${PARSER_PROJECT} exists, no need to create again."
     } || {
         openstack  ${debug} project create ${PARSER_PROJECT} \
             --description "Project for parser test"
@@ -114,7 +138,7 @@ create_parser_user_and_project() {
 
     # 2. create parser user.
     openstack ${debug} user list | grep -qwo ${PARSER_USER} && {
-        echo "  User ${PARSER_USER} exist, doesn't create again."
+        echo "  User ${PARSER_USER} exists , no need to create again."
     } || {
         openstack ${debug} user create ${PARSER_USER} --password ${PARSER_PASSWORD} \
             --project ${PARSER_PROJECT} --email ${PARSER_EMAIL}
@@ -124,7 +148,7 @@ create_parser_user_and_project() {
     # 3. grant role for parser user
     openstack ${debug} role assignment list --user ${PARSER_USER} --project ${PARSER_PROJECT} \
     | grep -qow ${PARSER_ROLE} && {
-        echo "  User ${PARSER_USER} has role ${PARSER_ROLE} in project ${PARSER_PROJECT}, doesn't create."
+        echo "  User ${PARSER_USER} has role ${PARSER_ROLE} in project ${PARSER_PROJECT}, no need to create."
     } || {
         openstack ${debug} role add ${PARSER_ROLE} --user ${PARSER_USER} \
                            --project ${PARSER_PROJECT}