Browse code

Merge "Add/Overwrite default images in IMAGE_URLS and detect duplicates"

Jenkins authored on 2015/09/03 17:52:59
Showing 3 changed files
... ...
@@ -383,6 +383,24 @@ DevStack's default configuration in ``sql`` mode is set in
383 383
 ``files/keystone_data.sh``
384 384
 
385 385
 
386
+Guest Images
387
+------------
388
+
389
+Images provided in URLS via the comma-separated ``IMAGE_URLS``
390
+variable will be downloaded and uploaded to glance by DevStack.
391
+
392
+Default guest-images are predefined for each type of hypervisor and
393
+their testing-requirements in ``stack.sh``.  Setting
394
+``DOWNLOAD_DEFAULT_IMAGES=False`` will prevent DevStack downloading
395
+these default images; in that case, you will want to populate
396
+``IMAGE_URLS`` with sufficient images to satisfy testing-requirements.
397
+
398
+    ::
399
+
400
+        DOWNLOAD_DEFAULT_IMAGES=False
401
+        IMAGE_URLS="http://foo.bar.com/image.qcow,"
402
+        IMAGE_URLS+="http://foo.bar.com/image2.qcow"
403
+
386 404
 IP Version
387 405
 ----------
388 406
 
... ...
@@ -2,6 +2,11 @@
2 2
 #
3 3
 # stackrc
4 4
 #
5
+
6
+# ensure we don't re-source this in the same environment
7
+[[ -z "$_DEVSTACK_STACKRC" ]] || return 0
8
+declare -r _DEVSTACK_STACKRC=1
9
+
5 10
 # Find the other rc files
6 11
 RC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
7 12
 
... ...
@@ -558,40 +563,47 @@ CIRROS_ARCH=${CIRROS_ARCH:-"x86_64"}
558 558
 # Set default image based on ``VIRT_DRIVER`` and ``LIBVIRT_TYPE``, either of
559 559
 # which may be set in ``local.conf``.  Also allow ``DEFAULT_IMAGE_NAME`` and
560 560
 # ``IMAGE_URLS`` to be set in the `localrc` section of ``local.conf``.
561
-case "$VIRT_DRIVER" in
562
-    openvz)
563
-        DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-ubuntu-12.04-x86_64}
564
-        IMAGE_URLS=${IMAGE_URLS:-"http://download.openvz.org/template/precreated/ubuntu-12.04-x86_64.tar.gz"};;
565
-    libvirt)
566
-        case "$LIBVIRT_TYPE" in
567
-            lxc) # the cirros root disk in the uec tarball is empty, so it will not work for lxc
568
-                DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-rootfs}
569
-                IMAGE_URLS=${IMAGE_URLS:-"http://download.cirros-cloud.net/${CIRROS_VERSION}/cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-rootfs.img.gz"};;
570
-            *) # otherwise, use the uec style image (with kernel, ramdisk, disk)
571
-                DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-uec}
572
-                IMAGE_URLS=${IMAGE_URLS:-"http://download.cirros-cloud.net/${CIRROS_VERSION}/cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-uec.tar.gz"};;
573
-        esac
574
-        ;;
575
-    vsphere)
576
-        DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-0.3.2-i386-disk.vmdk}
577
-        IMAGE_URLS=${IMAGE_URLS:-"http://partnerweb.vmware.com/programs/vmdkimage/cirros-0.3.2-i386-disk.vmdk"};;
578
-    xenserver)
579
-        DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-0.3.4-x86_64-disk}
580
-        IMAGE_URLS=${IMAGE_URLS:-"http://ca.downloads.xensource.com/OpenStack/cirros-0.3.4-x86_64-disk.vhd.tgz"}
581
-        IMAGE_URLS+=",http://download.cirros-cloud.net/${CIRROS_VERSION}/cirros-${CIRROS_VERSION}-x86_64-uec.tar.gz";;
582
-    ironic)
583
-        # Ironic can do both partition and full disk images, depending on the driver
584
-        if [[ "$IRONIC_DEPLOY_DRIVER" == "agent_ssh" ]]; then
585
-            DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-${CIRROS_VERSION}-x86_64-disk}
586
-        else
587
-            DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-${CIRROS_VERSION}-x86_64-uec}
588
-        fi
589
-        IMAGE_URLS=${IMAGE_URLS:-"http://download.cirros-cloud.net/${CIRROS_VERSION}/cirros-${CIRROS_VERSION}-x86_64-uec.tar.gz"}
590
-        IMAGE_URLS+=",http://download.cirros-cloud.net/${CIRROS_VERSION}/cirros-${CIRROS_VERSION}-x86_64-disk.img";;
591
-    *) # Default to Cirros with kernel, ramdisk and disk image
592
-        DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-uec}
593
-        IMAGE_URLS=${IMAGE_URLS:-"http://download.cirros-cloud.net/${CIRROS_VERSION}/cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-uec.tar.gz"};;
594
-esac
561
+DOWNLOAD_DEFAULT_IMAGES=$(trueorfalse True DOWNLOAD_DEFAULT_IMAGES)
562
+if [[ "$DOWNLOAD_DEFAULT_IMAGES" == "True" ]]; then
563
+    if [ -n $IMAGE_URLS ]; then
564
+        IMAGE_URLS+=","
565
+    fi
566
+    case "$VIRT_DRIVER" in
567
+        openvz)
568
+            DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-ubuntu-12.04-x86_64}
569
+            IMAGE_URLS+="http://download.openvz.org/template/precreated/ubuntu-12.04-x86_64.tar.gz";;
570
+        libvirt)
571
+            case "$LIBVIRT_TYPE" in
572
+                lxc) # the cirros root disk in the uec tarball is empty, so it will not work for lxc
573
+                    DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-rootfs}
574
+                    IMAGE_URLS+="http://download.cirros-cloud.net/${CIRROS_VERSION}/cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-rootfs.img.gz";;
575
+                *) # otherwise, use the uec style image (with kernel, ramdisk, disk)
576
+                    DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-uec}
577
+                    IMAGE_URLS+="http://download.cirros-cloud.net/${CIRROS_VERSION}/cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-uec.tar.gz";;
578
+                esac
579
+            ;;
580
+        vsphere)
581
+            DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-0.3.2-i386-disk.vmdk}
582
+            IMAGE_URLS+="http://partnerweb.vmware.com/programs/vmdkimage/cirros-0.3.2-i386-disk.vmdk";;
583
+        xenserver)
584
+            DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-0.3.4-x86_64-disk}
585
+            IMAGE_URLS+="http://ca.downloads.xensource.com/OpenStack/cirros-0.3.4-x86_64-disk.vhd.tgz"
586
+            IMAGE_URLS+=",http://download.cirros-cloud.net/${CIRROS_VERSION}/cirros-${CIRROS_VERSION}-x86_64-uec.tar.gz";;
587
+        ironic)
588
+            # Ironic can do both partition and full disk images, depending on the driver
589
+            if [[ "$IRONIC_DEPLOY_DRIVER" == "agent_ssh" ]]; then
590
+                DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-${CIRROS_VERSION}-x86_64-disk}
591
+            else
592
+                DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-${CIRROS_VERSION}-x86_64-uec}
593
+            fi
594
+            IMAGE_URLS+="http://download.cirros-cloud.net/${CIRROS_VERSION}/cirros-${CIRROS_VERSION}-x86_64-uec.tar.gz"
595
+            IMAGE_URLS+=",http://download.cirros-cloud.net/${CIRROS_VERSION}/cirros-${CIRROS_VERSION}-x86_64-disk.img";;
596
+        *) # Default to Cirros with kernel, ramdisk and disk image
597
+            DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-uec}
598
+            IMAGE_URLS+="http://download.cirros-cloud.net/${CIRROS_VERSION}/cirros-${CIRROS_VERSION}-${CIRROS_ARCH}-uec.tar.gz";;
599
+    esac
600
+    DOWNLOAD_DEFAULT_IMAGES=False
601
+fi
595 602
 
596 603
 # Staging Area for New Images, have them here for at least 24hrs for nodepool
597 604
 # to cache them otherwise the failure rates in the gate are too high
... ...
@@ -604,6 +616,13 @@ if [[ "$PRECACHE_IMAGES" == "True" ]]; then
604 604
     fi
605 605
 fi
606 606
 
607
+# Detect duplicate values in IMAGE_URLS
608
+for image_url in ${IMAGE_URLS//,/ }; do
609
+    if [ $(echo "$IMAGE_URLS" | grep -o -F "$image_url" | wc -l) -gt 1 ]; then
610
+        die $LINENO "$image_url is duplicate, please remove it from IMAGE_URLS."
611
+    fi
612
+done
613
+
607 614
 # 10Gb default volume backing file size
608 615
 VOLUME_BACKING_FILE_SIZE=${VOLUME_BACKING_FILE_SIZE:-10250M}
609 616
 
... ...
@@ -94,11 +94,6 @@ Of course, use real passwords if this machine is exposed.
94 94
     XENAPI_CONNECTION_URL="http://address_of_your_xenserver"
95 95
     VNCSERVER_PROXYCLIENT_ADDRESS=address_of_your_xenserver
96 96
 
97
-    # Download a vhd and a uec image
98
-    IMAGE_URLS="\
99
-    https://github.com/downloads/citrix-openstack/warehouse/cirros-0.3.0-x86_64-disk.vhd.tgz,\
100
-    http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-uec.tar.gz"
101
-
102 97
     # Explicitly set virt driver
103 98
     VIRT_DRIVER=xenserver
104 99