Make it possible to set a size from within a flavour, and use that for devstack.

This commit is contained in:
Robert Collins 2012-11-12 11:47:26 +13:00
parent ac930076fb
commit 40e954735c
7 changed files with 38 additions and 9 deletions

View File

@ -57,6 +57,16 @@ Writing a flavour
Make as many of the following subdirectories as you need, depending on what
part of the process you need to customise:
* block-device-size.d: Alter the size (in GB) of the disk image. This is useful
when a particular flavour will require a certain minimum (or maximum) size.
You can either error and stop the build, or adjust the size to match.
NB: Due to the current simple implementation, the last output value wins
so this should be used rarely - only one flavour in a mix can reliably set
a size.
* outputs: $IMAGE\_SIZE={size_in_GB}
* inputs: $IMAGE_SIZE={size_in_GB}
* block-device.d: customise the block device that the image will be made on
(e.g. to make partitions).

View File

@ -46,6 +46,7 @@ ensure_nbd
mk_build_dir
ensure_base_available
eval_run_d block-device-size "IMAGE_SIZE="
qemu-img create -f qcow2 $TMP_IMAGE_PATH ${IMAGE_SIZE}G
@ -60,10 +61,7 @@ fi
sudo qemu-nbd -c $NBD_DEV $CACHE $TMP_IMAGE_PATH
export EXTRA_UNMOUNT="sudo qemu-nbd -d $NBD_DEV"
export IMAGE_BLOCK_DEVICE=$NBD_DEV
TEMP=`run_d block-device`
echo "$TEMP"
TEMP=`echo "$TEMP" | grep "IMAGE_BLOCK_DEVICE="`
eval "$TEMP"
eval_run_d block-device "IMAGE_BLOCK_DEVICE="
sudo mkfs -F -t $FS_TYPE -L cloudimg-rootfs ${IMAGE_BLOCK_DEVICE}

View File

@ -16,7 +16,7 @@ Jenkins
* Jobs to build:
* bootstrap VM from-scratch (archive bootstrap.qcow2).
disk-image-create vm devstack -o bootstrap.qcow2 -a i386
disk-image-create vm devstack -o bootstrap -a i386
* devstack nova-bm execution (archive the resulting image).
Chained off of the bootstrap vm build
@ -26,17 +26,17 @@ Jenkins
* bootstrap VM via image-build chain (archive bm-cloud.qcow2).
disk-image-create vm glance nova-bm swift mysql haproxy-api \
haproxy-mysql cinder quantum rabbitmq -o bootstrap-prod.qcow2
haproxy-mysql cinder quantum rabbitmq -o bootstrap-prod
* baremetal SPOF node build (archive the resulting image).
disk-image-create mysql haproxy-mysql haproxy-api local-boot \
rabbitmq -o baremetal-spof.qcow2
rabbitmq -o baremetal-spof
* baremetal demo node build (archive the resulting image).
disk-image-create vm glance nova-bm swift cinder quantum \
-o bootstrap-prod.qcow2
-o bootstrap-prod
* ramdisk deploy image buil

View File

@ -1,2 +1,5 @@
Creates an image prepped to make a devstack baremetal cloud. See
demo/scripts/demo within the built image.
This flavour forces a 16GB image to allow room for Swift, Cinder and instance
disk images.

View File

@ -0,0 +1,9 @@
#!/bin/bash
# Add the stack user we recommend folk use.
set -e
set -x
if (( '16' '>' $IMAGE_SIZE )); then
echo IMAGE_SIZE=16
fi

View File

@ -34,3 +34,12 @@ function check_flavour () {
[ -d $TMP_HOOKS_PATH ] || generate_hooks
}
# Run a hook, looking for a regex in its stdout, and eval the matched lines.
# $1 is the hook to run
# $2 is the regex to look for
function eval_run_d () {
local TEMP=`run_d $1`
echo "$TEMP"
TEMP=`echo "$TEMP" | grep "$2"`
eval "$TEMP"
}

View File

@ -7,7 +7,7 @@ FS_TYPE=${FS_TYPE:-ext4}
# Used to set the file extension only at this stage.
IMAGE_TYPE=${IMAGE_TYPE:-qcow2}
IMAGE_NAME=${IMAGE_NAME:-image}
IMAGE_SIZE=${IMAGE_SIZE:-1} # N.B. This size is in GB
export IMAGE_SIZE=${IMAGE_SIZE:-1} # N.B. This size is in GB
# Set via the CLI normally.
# IMAGE_FLAVOUR=
IMG_PATH=~/.cache/image-create