docs: Remove reference to a file:// img_id prefix
[snf-image] / snf-image-host / create
index 6272053..9fa084b 100755 (executable)
@@ -28,7 +28,7 @@ if [ "$IMAGE_DEBUG" = "yes" ]; then
     PS4='$(date "+%s.%N ($LINENO) + ")'
     set -x
 elif [ "$IMAGE_DEBUG" != "no" ]; then
-    echo "Warning: Unsupported IMAGE_DEBUG value: \`$IMAGE_DEBUG'"
+    log_warning "Unsupported IMAGE_DEBUG value: \`$IMAGE_DEBUG'"
 fi
 
 monitor_pipe=$(mktemp -u)
@@ -54,13 +54,15 @@ trap "" SIGPIPE
 
 trap report_and_cleanup EXIT
 
+echo "Processing image with ID: \`$IMG_ID' and type: \`$IMAGE_TYPE'" >&2
+
 case $BACKEND_TYPE in
     local)
         if [[ "$IMAGE_NAME" =~ ^local:// ]]; then
             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
 
@@ -70,15 +72,22 @@ case $BACKEND_TYPE in
             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
 
+        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"