Support image type for guest image building

Change-Id: I8d640c47f00446d7f912ece9892b17585cde3add
(cherry picked from commit 428e3644f8)
This commit is contained in:
Lingxian Kong 2020-06-12 23:42:17 +12:00
parent 8d9b938a55
commit 775abab528
3 changed files with 9 additions and 3 deletions

View File

@ -141,7 +141,7 @@ The trove guest agent image could be created by running the following command:
guest_os_release=xenial
dev_mode=true
guest_username=ubuntu
imagepath=$HOME/images/trove-${guest_os}-${guest_os_release}-${datastore_type}
imagepath=$HOME/images/trove-${guest_os}-${guest_os_release}-${datastore_type}.qcow2
* ``dev_mode=true`` is mainly for testing purpose for trove developers and it's
necessary to build the image on the trove controller host, because the host
@ -165,6 +165,10 @@ The trove guest agent image could be created by running the following command:
repository, by default it's master, use other branches as needed such as
stable/train.
* The image type can be easily changed by specifying a different image file
extension, e.g. to build a raw image, you can specify
``$your-image-name.raw`` as the ``imagepath`` parameter.
For example, in order to build a MySQL image for Ubuntu Xenial operating
system in development mode:

View File

@ -13,13 +13,14 @@ function build_vm() {
local dev_mode=$4
local guest_username=$5
local image_output=$6
local image_type=${image_output##*.}
local working_dir=$(dirname ${image_output})
local elementes="base vm"
local trove_elements_path=${PATH_TROVE}/integration/scripts/files/elements
local GUEST_IMAGETYPE=${GUEST_IMAGETYPE:-"qcow2"}
local GUEST_IMAGESIZE=${GUEST_IMAGESIZE:-4}
local GUEST_CACHEDIR=${GUEST_CACHEDIR:-"$HOME/.cache/image-create"}
local working_dir=$(dirname ${image_output})
export GUEST_USERNAME=${guest_username}
@ -79,6 +80,7 @@ function build_vm() {
disk-image-create -x \
-a amd64 \
-o ${image_output} \
-t ${image_type} \
-t ${GUEST_IMAGETYPE} \
--image-size ${GUEST_IMAGESIZE} \
--image-cache ${GUEST_CACHEDIR} \

View File

@ -781,7 +781,7 @@ function cmd_build_image() {
if [[ -z "$output" ]]; then
image_name="trove-datastore-${IMAGE_GUEST_OS}-${IMAGE_GUEST_RELEASE}-${IMAGE_DATASTORE_TYPE}"
image_folder=$HOME/images
output="${image_folder}/${image_name}"
output="${image_folder}/${image_name}.qcow2"
fi
# Always rebuild the image.
sudo rm -f $output