#!/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
##############################################################################
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
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
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() {
}
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
}
# 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"
# 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}
# 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}