diff --git a/functions b/functions index effdc53afb..d3de1427ba 100644 --- a/functions +++ b/functions @@ -1362,15 +1362,19 @@ function upload_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. + # passed to glance as custom properties. # We take these values from the vmdk file if populated. Otherwise, we use # vmdk filename, which is expected in the following format: # - # -:: + # -;; # # If the filename does not follow the above format then the vsphere # driver will supply default values. + vmdk_adapter_type="" + vmdk_disktype="" + vmdk_net_adapter="" + # vmdk adapter type vmdk_adapter_type="$(head -25 $IMAGE | grep -a -F -m 1 'ddb.adapterType =' $IMAGE)" vmdk_adapter_type="${vmdk_adapter_type#*\"}" @@ -1389,17 +1393,15 @@ function upload_image() { #TODO(alegendre): handle streamOptimized once supported by VMware driver. vmdk_disktype="preallocated" fi - property_string=`echo "$IMAGE_NAME" | grep -oP '(?<=-)(?!.*-).+:.+:.+$'` - if [[ ! -z "$property_string" ]]; then - IFS=':' read -a props <<< "$property_string" - if [[ ! -z "${props[0]}" ]]; then - vmdk_disktype="${props[0]}" - fi - if [[ ! -z "${props[1]}" ]]; then - vmdk_adapter_type="${props[1]}" - fi - vmdk_net_adapter="${props[2]}" - fi + + # NOTE: For backwards compatibility reasons, colons may be used in place + # of semi-colons for property delimiters but they are not permitted + # characters in NTFS filesystems. + property_string=`echo "$IMAGE_NAME" | grep -oP '(?<=-)(?!.*-).+[:;].+[:;].+$'` + IFS=':;' read -a props <<< "$property_string" + vmdk_disktype="${props[0]:-$vmdk_disktype}" + vmdk_adapter_type="${props[1]:-$vmdk_adapter_type}" + vmdk_net_adapter="${props[2]:-$vmdk_net_adapter}" 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