Browse code

xenapi: devstack support for raw tgz image upload

Devstack will recognise the .xen-raw.tgz extensions, and upload them to
glance as raw tgz images with xen pv_mode. This change also adds "tgz" to
the recognised container formats of glance. The changes for raw tgz
support are:

https://review.openstack.org/#/c/40908/
https://review.openstack.org/#/c/40909/
https://review.openstack.org/#/c/41651/

related to blueprint xenapi-supported-image-import-export

Change-Id: I077564587d4303291bb4f10d62bb16380b574106

Mate Lakat authored on 2013/08/16 02:06:59
Showing 2 changed files
... ...
@@ -1240,7 +1240,7 @@ function upload_image() {
1240 1240
         return
1241 1241
     fi
1242 1242
 
1243
-    # XenServer-ovf-format images are provided as .vhd.tgz as well
1243
+    # XenServer-vhd-ovf-format images are provided as .vhd.tgz
1244 1244
     # and should not be decompressed prior to loading
1245 1245
     if [[ "$image_url" =~ '.vhd.tgz' ]]; then
1246 1246
         IMAGE="$FILES/${IMAGE_FNAME}"
... ...
@@ -1249,6 +1249,22 @@ function upload_image() {
1249 1249
         return
1250 1250
     fi
1251 1251
 
1252
+    # .xen-raw.tgz suggests a Xen capable raw image inside a tgz.
1253
+    # and should not be decompressed prior to loading.
1254
+    # Setting metadata, so PV mode is used.
1255
+    if [[ "$image_url" =~ '.xen-raw.tgz' ]]; then
1256
+        IMAGE="$FILES/${IMAGE_FNAME}"
1257
+        IMAGE_NAME="${IMAGE_FNAME%.xen-raw.tgz}"
1258
+        glance \
1259
+          --os-auth-token $token \
1260
+          --os-image-url http://$GLANCE_HOSTPORT \
1261
+          image-create \
1262
+            --name "$IMAGE_NAME" --is-public=True \
1263
+            --container-format=tgz --disk-format=raw \
1264
+            --property vm_mode=xen < "${IMAGE}"
1265
+        return
1266
+    fi
1267
+
1252 1268
     KERNEL=""
1253 1269
     RAMDISK=""
1254 1270
     DISK_FORMAT=""
... ...
@@ -108,6 +108,10 @@ function configure_glance() {
108 108
     fi
109 109
     iniset_rpc_backend glance $GLANCE_API_CONF DEFAULT
110 110
     iniset $GLANCE_API_CONF keystone_authtoken signing_dir $GLANCE_AUTH_CACHE_DIR/api
111
+    if [ "$VIRT_DRIVER" = 'xenserver' ]; then
112
+        iniset $GLANCE_API_CONF DEFAULT container_formats "ami,ari,aki,bare,ovf,tgz"
113
+        iniset $GLANCE_API_CONF DEFAULT disk_formats "ami,ari,aki,vhd,raw,iso"
114
+    fi
111 115
 
112 116
     # Store the images in swift if enabled.
113 117
     if is_service_enabled s-proxy; then