Merge "Provide a means of setting vmdk custom properties via image filename"

This commit is contained in:
Jenkins 2013-09-09 17:03:04 +00:00 committed by Gerrit Code Review
commit b0f086011c

View File

@ -1256,7 +1256,25 @@ function upload_image() {
if [[ "$image_url" =~ '.vmdk' ]]; then if [[ "$image_url" =~ '.vmdk' ]]; then
IMAGE="$FILES/${IMAGE_FNAME}" IMAGE="$FILES/${IMAGE_FNAME}"
IMAGE_NAME="${IMAGE_FNAME%.vmdk}" IMAGE_NAME="${IMAGE_FNAME%.vmdk}"
glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --is-public=True --container-format bare --disk-format vmdk --property vmware-disktype="preallocated" < "${IMAGE}"
# Before we can upload vmdk type images to glance, we need to know it's
# disk type, storage adapter, and networking adapter. These values are
# passed to glance as custom properties. We take these values from the
# vmdk filename, which is expected in the following format:
#
# <name>-<disk type>:<storage adapter>:<network adapter>
#
# If the filename does not follow the above format then the vsphere
# driver will supply default values.
property_string=`echo "$IMAGE_NAME" | grep -oP '(?<=-)(?!.*-).+:.+:.+$'`
if [[ ! -z "$property_string" ]]; then
IFS=':' read -a props <<< "$property_string"
vmdk_disktype="${props[0]}"
vmdk_adapter_type="${props[1]}"
vmdk_net_adapter="${props[2]}"
fi
glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --is-public=True --container-format bare --disk-format vmdk --property vmware-disktype="$vmdk_disktype" --property vmware_adaptertype="$vmdk_adapter_type" --property hw_vif_model="$vmdk_net_adapter" < "${IMAGE}"
return return
fi fi