Change the local-backend identifier to local://
authorNikos Skalkotos <skalkoto@grnet.gr>
Thu, 3 Oct 2013 12:30:09 +0000 (15:30 +0300)
committerNikos Skalkotos <skalkoto@grnet.gr>
Fri, 4 Oct 2013 09:58:14 +0000 (12:58 +0300)
This used to be file://

snf-image-host/common.sh.in
snf-image-host/create

index 02e567c..5236c1c 100644 (file)
@@ -50,6 +50,10 @@ log_error() {
     echo "[ERROR] $*" >&2
 }
 
+log_warning() {
+    echo "[WARNING] $*" >&2
+}
+
 report_error() {
     ERROR_MSGS+=("$@")
 }
index e302e26..f9fc7bc 100755 (executable)
@@ -56,7 +56,21 @@ trap report_and_cleanup EXIT
 
 case $BACKEND_TYPE in
     local)
-        image_file="$IMAGE_DIR/$(echo "$IMAGE_NAME" | sed 's/^file://').$IMAGE_TYPE"
+        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 " \
+                        "will be removed in the future. Use local:// instead."
+        fi
+
+        if [ "$IMAGE_NAME" != "${IMAGE_NAME##*/}" ]; then
+            report_error "Image id is not allowed to contain /'s"
+            log_error "Image id is not allowed to contain /'s"
+            exit 1
+        fi
+
+        image_file="$IMAGE_DIR/$IMAGE_NAME.$IMAGE_TYPE"
         if [ ! -e "$image_file" ]; then
             log_error "Image file \`$image_file' does not exit."
             report_error "Unable to retrieve image file."