|
...
|
...
|
@@ -1388,15 +1388,19 @@ function upload_image() {
|
|
1388
|
1388
|
|
|
1389
|
1389
|
# Before we can upload vmdk type images to glance, we need to know it's
|
|
1390
|
1390
|
# disk type, storage adapter, and networking adapter. These values are
|
|
1391
|
|
- # passed to glance as custom properties.
|
|
|
1391
|
+ # passed to glance as custom properties.
|
|
1392
|
1392
|
# We take these values from the vmdk file if populated. Otherwise, we use
|
|
1393
|
1393
|
# vmdk filename, which is expected in the following format:
|
|
1394
|
1394
|
#
|
|
1395
|
|
- # <name>-<disk type>:<storage adapter>:<network adapter>
|
|
|
1395
|
+ # <name>-<disk type>;<storage adapter>;<network adapter>
|
|
1396
|
1396
|
#
|
|
1397
|
1397
|
# If the filename does not follow the above format then the vsphere
|
|
1398
|
1398
|
# driver will supply default values.
|
|
1399
|
1399
|
|
|
|
1400
|
+ vmdk_adapter_type=""
|
|
|
1401
|
+ vmdk_disktype=""
|
|
|
1402
|
+ vmdk_net_adapter=""
|
|
|
1403
|
+
|
|
1400
|
1404
|
# vmdk adapter type
|
|
1401
|
1405
|
vmdk_adapter_type="$(head -25 $IMAGE | grep -a -F -m 1 'ddb.adapterType =' $IMAGE)"
|
|
1402
|
1406
|
vmdk_adapter_type="${vmdk_adapter_type#*\"}"
|
|
...
|
...
|
@@ -1415,17 +1419,15 @@ function upload_image() {
|
|
1415
|
1415
|
#TODO(alegendre): handle streamOptimized once supported by VMware driver.
|
|
1416
|
1416
|
vmdk_disktype="preallocated"
|
|
1417
|
1417
|
fi
|
|
1418
|
|
- property_string=`echo "$IMAGE_NAME" | grep -oP '(?<=-)(?!.*-).+:.+:.+$'`
|
|
1419
|
|
- if [[ ! -z "$property_string" ]]; then
|
|
1420
|
|
- IFS=':' read -a props <<< "$property_string"
|
|
1421
|
|
- if [[ ! -z "${props[0]}" ]]; then
|
|
1422
|
|
- vmdk_disktype="${props[0]}"
|
|
1423
|
|
- fi
|
|
1424
|
|
- if [[ ! -z "${props[1]}" ]]; then
|
|
1425
|
|
- vmdk_adapter_type="${props[1]}"
|
|
1426
|
|
- fi
|
|
1427
|
|
- vmdk_net_adapter="${props[2]}"
|
|
1428
|
|
- fi
|
|
|
1418
|
+
|
|
|
1419
|
+ # NOTE: For backwards compatibility reasons, colons may be used in place
|
|
|
1420
|
+ # of semi-colons for property delimiters but they are not permitted
|
|
|
1421
|
+ # characters in NTFS filesystems.
|
|
|
1422
|
+ property_string=`echo "$IMAGE_NAME" | grep -oP '(?<=-)(?!.*-).+[:;].+[:;].+$'`
|
|
|
1423
|
+ IFS=':;' read -a props <<< "$property_string"
|
|
|
1424
|
+ vmdk_disktype="${props[0]:-$vmdk_disktype}"
|
|
|
1425
|
+ vmdk_adapter_type="${props[1]:-$vmdk_adapter_type}"
|
|
|
1426
|
+ vmdk_net_adapter="${props[2]:-$vmdk_net_adapter}"
|
|
1429
|
1427
|
|
|
1430
|
1428
|
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}"
|
|
1431
|
1429
|
return
|