Browse code

Generate glance image with SCSI bus type for ppc arch

This patch fixes wrong assumptions for bus types of disk and cdrom
on ppc64. Qemu driver assumes IDE bus type for cdrom device, which
is not supported on ppc arch.
Adds capability to add --property key-value to the glance
image-create command.
Using double brackets for portability reasons.

Change-Id: I9f55fa0b6a894a93926e4f8c3d0ea410b5283f9c

Rafael Folco authored on 2013/12/03 01:04:32
Showing 1 changed files
... ...
@@ -554,7 +554,7 @@ function exit_distro_not_supported {
554 554
 function is_arch {
555 555
     ARCH_TYPE=$1
556 556
 
557
-    [ "($uname -m)" = "$ARCH_TYPE" ]
557
+    [[ "$(uname -m)" == "$ARCH_TYPE" ]]
558 558
 }
559 559
 
560 560
 # Checks if installed Apache is <= given version
... ...
@@ -1510,11 +1510,15 @@ function upload_image() {
1510 1510
         *) echo "Do not know what to do with $IMAGE_FNAME"; false;;
1511 1511
     esac
1512 1512
 
1513
+    if is_arch "ppc64"; then
1514
+        IMG_PROPERTY="--property hw_disk_bus=scsi --property hw_cdrom_bus=scsi"
1515
+    fi
1516
+
1513 1517
     if [ "$CONTAINER_FORMAT" = "bare" ]; then
1514 1518
         if [ "$UNPACK" = "zcat" ]; then
1515
-            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}")
1519
+            glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" $IMG_PROPERTY --is-public True --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT < <(zcat --force "${IMAGE}")
1516 1520
         else
1517
-            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}"
1521
+            glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" $IMG_PROPERTY --is-public True --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT < "${IMAGE}"
1518 1522
         fi
1519 1523
     else
1520 1524
         # Use glance client to add the kernel the root filesystem.
... ...
@@ -1522,12 +1526,12 @@ function upload_image() {
1522 1522
         # kernel for use when uploading the root filesystem.
1523 1523
         KERNEL_ID=""; RAMDISK_ID="";
1524 1524
         if [ -n "$KERNEL" ]; then
1525
-            KERNEL_ID=$(glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME-kernel" --is-public True --container-format aki --disk-format aki < "$KERNEL" | grep ' id ' | get_field 2)
1525
+            KERNEL_ID=$(glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME-kernel" $IMG_PROPERTY --is-public True --container-format aki --disk-format aki < "$KERNEL" | grep ' id ' | get_field 2)
1526 1526
         fi
1527 1527
         if [ -n "$RAMDISK" ]; then
1528
-            RAMDISK_ID=$(glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME-ramdisk" --is-public True --container-format ari --disk-format ari < "$RAMDISK" | grep ' id ' | get_field 2)
1528
+            RAMDISK_ID=$(glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME-ramdisk" $IMG_PROPERTY --is-public True --container-format ari --disk-format ari < "$RAMDISK" | grep ' id ' | get_field 2)
1529 1529
         fi
1530
-        glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "${IMAGE_NAME%.img}" --is-public True --container-format ami --disk-format ami ${KERNEL_ID:+--property kernel_id=$KERNEL_ID} ${RAMDISK_ID:+--property ramdisk_id=$RAMDISK_ID} < "${IMAGE}"
1530
+        glance --os-auth-token $token --os-image-url http://$GLANCE_HOSTPORT image-create --name "${IMAGE_NAME%.img}" $IMG_PROPERTY --is-public True --container-format ami --disk-format ami ${KERNEL_ID:+--property kernel_id=$KERNEL_ID} ${RAMDISK_ID:+--property ramdisk_id=$RAMDISK_ID} < "${IMAGE}"
1531 1531
     fi
1532 1532
 }
1533 1533