upload_image.sh should parse filenames correctly

The upload_image script gives the ability to the user to provide
specific metadata using the filename:
file-adapter_type;disk_type;network_type.vmdk
Currently, the regex expects each of these types to be populated.
This patch fixes this issue by making the regex more flexible and
accepts only one of these metadata to be populated.

Change-Id: If74cb06cc640864e7e91fd88943cdb37e05935d6
Closes-Bug: #1272126
This commit is contained in:
Arnaud Legendre 2014-01-23 17:12:21 -08:00
parent 6d323f43b4
commit b93cd64343

View File

@ -1539,7 +1539,7 @@ function upload_image() {
# 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 '(?<=-)(?!.*-).+[:;].+[:;].+$'`
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}"