Refactor vmdk upload code
A syntax error is hit when trying to upload a flat vmdk file that is accompanied by a descriptor file. The code block that handles this has some unneeded characters that cause the error. Also, an else-block has been removed so that we can remove an extra indent. Change-Id: Iaf5c914e09da6831eeeec141228b39554a1e2216 Closes-bug: #1288471
This commit is contained in:
parent
4981bd7532
commit
99b622a936
51
functions
51
functions
@ -163,38 +163,37 @@ function upload_image {
|
|||||||
if [[ ${IMAGE_NAME: -5} != "-flat" ]]; then
|
if [[ ${IMAGE_NAME: -5} != "-flat" ]]; then
|
||||||
warn $LINENO "Expected filename suffix: '-flat'."`
|
warn $LINENO "Expected filename suffix: '-flat'."`
|
||||||
`" Filename provided: ${IMAGE_NAME}"
|
`" Filename provided: ${IMAGE_NAME}"
|
||||||
else
|
fi
|
||||||
descriptor_fname="${IMAGE_NAME:0:${#IMAGE_NAME} - 5}.vmdk"
|
|
||||||
path_len=`expr ${#image_url} - ${#IMAGE_FNAME}`
|
descriptor_fname="${IMAGE_NAME:0:${#IMAGE_NAME} - 5}.vmdk"
|
||||||
flat_path="${image_url:0:$path_len}"
|
path_len=`expr ${#image_url} - ${#IMAGE_FNAME}`
|
||||||
descriptor_url=$flat_path$descriptor_fname
|
flat_path="${image_url:0:$path_len}"
|
||||||
warn $LINENO "$descriptor_data_pair_msg"`
|
descriptor_url=$flat_path$descriptor_fname
|
||||||
`" Attempt to retrieve the descriptor *.vmdk: $descriptor_url"
|
warn $LINENO "$descriptor_data_pair_msg"`
|
||||||
if [[ $flat_path != file* ]]; then
|
`" Attempt to retrieve the descriptor *.vmdk: $descriptor_url"
|
||||||
if [[ ! -f $FILES/$descriptor_fname || \
|
if [[ $flat_path != file* ]]; then
|
||||||
"$(stat -c "%s" $FILES/$descriptor_fname)" = "0" ]]; then
|
if [[ ! -f $FILES/$descriptor_fname || \
|
||||||
wget -c $descriptor_url -O $FILES/$descriptor_fname
|
"$(stat -c "%s" $FILES/$descriptor_fname)" = "0" ]]; then
|
||||||
if [[ $? -ne 0 ]]; then
|
wget -c $descriptor_url -O $FILES/$descriptor_fname
|
||||||
warn $LINENO "Descriptor not found $descriptor_url"
|
if [[ $? -ne 0 ]]; then
|
||||||
descriptor_found=false
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
descriptor_url="$FILES/$descriptor_fname"
|
|
||||||
else
|
|
||||||
descriptor_url=$(echo $descriptor_url | sed "s/^file:\/\///g")
|
|
||||||
if [[ ! -f $descriptor_url || \
|
|
||||||
"$(stat -c "%s" $descriptor_url)" == "0" ]]; then
|
|
||||||
warn $LINENO "Descriptor not found $descriptor_url"
|
warn $LINENO "Descriptor not found $descriptor_url"
|
||||||
descriptor_found=false
|
descriptor_found=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if $descriptor_found; then
|
descriptor_url="$FILES/$descriptor_fname"
|
||||||
vmdk_adapter_type="$(head -25 $descriptor_url |"`
|
else
|
||||||
`" { grep -a -F -m 1 'ddb.adapterType =' $descriptor_url || true; })"
|
descriptor_url=$(echo $descriptor_url | sed "s/^file:\/\///g")
|
||||||
vmdk_adapter_type="${vmdk_adapter_type#*\"}"
|
if [[ ! -f $descriptor_url || \
|
||||||
vmdk_adapter_type="${vmdk_adapter_type%?}"
|
"$(stat -c "%s" $descriptor_url)" == "0" ]]; then
|
||||||
|
warn $LINENO "Descriptor not found $descriptor_url"
|
||||||
|
descriptor_found=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if $descriptor_found; then
|
||||||
|
vmdk_adapter_type="$(head -25 $descriptor_url | { grep -a -F -m 1 'ddb.adapterType =' $descriptor_url || true; })"
|
||||||
|
vmdk_adapter_type="${vmdk_adapter_type#*\"}"
|
||||||
|
vmdk_adapter_type="${vmdk_adapter_type%?}"
|
||||||
|
fi
|
||||||
vmdk_disktype="preallocated"
|
vmdk_disktype="preallocated"
|
||||||
else
|
else
|
||||||
vmdk_disktype="preallocated"
|
vmdk_disktype="preallocated"
|
||||||
|
Loading…
Reference in New Issue
Block a user