Change the local back-end id format
authorNikos Skalkotos <skalkoto@grnet.gr>
Fri, 4 Oct 2013 12:21:07 +0000 (15:21 +0300)
committerNikos Skalkotos <skalkoto@grnet.gr>
Fri, 4 Oct 2013 12:26:09 +0000 (15:26 +0300)
The id now should contain the relative path from the HELPER_DIR to
the image filename, including the image-type extension if needed.

snf-image-host/create

index 6272053..c0419b8 100755 (executable)
@@ -60,7 +60,7 @@ case $BACKEND_TYPE in
             IMAGE_NAME="${IMAGE_NAME:8}"
         elif [[ "$IMAGE_NAME" =~ ^file:// ]]; then
             IMAGE_NAME="${IMAGE_NAME:7}"
             IMAGE_NAME="${IMAGE_NAME:8}"
         elif [[ "$IMAGE_NAME" =~ ^file:// ]]; then
             IMAGE_NAME="${IMAGE_NAME:7}"
-            log_warning "The file:// back-end identifier is deprecated and " \
+            log_warning "The file:// back-end identifier is deprecated and" \
                         "will be removed in the future. Use local:// instead."
         fi
 
                         "will be removed in the future. Use local:// instead."
         fi
 
@@ -70,15 +70,22 @@ case $BACKEND_TYPE in
             report_error "Unable to retrieve image file."
         fi
 
             report_error "Unable to retrieve image file."
         fi
 
-        image_file="$IMAGE_DIR/$IMAGE_NAME.$IMAGE_TYPE"
-        canonical_image_file="$(canonicalize "$image_file")"
-
-        if [ ! -e "$canonical_image_file" ]; then
-            log_error "Image file \`$image_file' does not exist."
-            report_error "Unable to retrieve image file."
-            exit 1
+        image_file="$IMAGE_DIR/$IMAGE_NAME"
+        if [ ! -e "$image_file" ]; then
+            if [ -e "$image_file.$IMAGE_TYPE" ] ; then
+                image_file="$image_file.$IMAGE_TYPE"
+                log_warning "The \`.$IMAGE_TYPE' extension is missing from" \
+                    "the local back-end id. This id form is deprecated and" \
+                    " will be remove in the future."
+            else
+                log_error "Image file \`$image_file' does not exist."
+                report_error "Unable to retrieve image file."
+                exit 1
+            fi
         fi
 
         fi
 
+        canonical_image_file="$(canonicalize "$image_file")"
+
         if [[ "$canonical_image_file" != "$canonical_image_dir"* ]]; then
             log_error "Image ID points to a file outside the image directory: \`$IMAGE_DIR'"
             report_error "Invalid image ID"
         if [[ "$canonical_image_file" != "$canonical_image_dir"* ]]; then
             log_error "Image ID points to a file outside the image directory: \`$IMAGE_DIR'"
             report_error "Invalid image ID"