Browse code

Merge "Fix for glance image-create of *.qcow2 and *.img files"

Jenkins authored on 2012/08/17 23:58:14
Showing 1 changed files
... ...
@@ -2174,6 +2174,8 @@ if is_service_enabled g-reg; then
2174 2174
         RAMDISK=""
2175 2175
         DISK_FORMAT=""
2176 2176
         CONTAINER_FORMAT=""
2177
+        UNPACK=""
2178
+        
2177 2179
         case "$IMAGE_FNAME" in
2178 2180
             *.tar.gz|*.tgz)
2179 2181
                 # Extract ami and aki files
... ...
@@ -2205,6 +2207,7 @@ if is_service_enabled g-reg; then
2205 2205
                 IMAGE_NAME=$(basename "$IMAGE" ".img.gz")
2206 2206
                 DISK_FORMAT=raw
2207 2207
                 CONTAINER_FORMAT=bare
2208
+                UNPACK=zcat
2208 2209
                 ;;
2209 2210
             *.qcow2)
2210 2211
                 IMAGE="$FILES/${IMAGE_FNAME}"
... ...
@@ -2216,7 +2219,11 @@ if is_service_enabled g-reg; then
2216 2216
         esac
2217 2217
 
2218 2218
         if [ "$CONTAINER_FORMAT" = "bare" ]; then
2219
-            glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --is-public=True --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT < <(zcat --force "${IMAGE}")
2219
+            if [ "$UNPACK" = "zcat" ]; then
2220
+                glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --is-public=True --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT <  <(zcat --force "${IMAGE}")
2221
+            else
2222
+                glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --is-public=True --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT < ${IMAGE}
2223
+            fi
2220 2224
         else
2221 2225
             # Use glance client to add the kernel the root filesystem.
2222 2226
             # We parse the results of the first upload to get the glance ID of the