Browse code

Enable DIB service to build with minimal net access

Adds two new options to lib/dib that will help devstack slaves
use cached content and content local to cloud provides:

* DIB_BUILD_OFFLINE: This will enable DIB to rely entirely on
cached images without making any additional calls to cloud-images.ubuntu.com
to validate hashes/freshness.

* DIB_APT_SOURCES: Used to specify alternatve sources.list for image builds.
Setting this enables the addition of the apt-sources element during image
builds and is only supported for ubuntu/debian builds.

Change-Id: I9b9ca72ec551565d454610aacb86c585f0384f13
Partial-bug: #1375488

Adam Gandelman authored on 2014/10/02 09:06:19
Showing 1 changed files
... ...
@@ -20,13 +20,28 @@ set +o xtrace
20 20
 # set up default directories
21 21
 DIB_DIR=$DEST/diskimage-builder
22 22
 TIE_DIR=$DEST/tripleo-image-elements
23
+
24
+# NOTE: Setting DIB_APT_SOURCES assumes you will be building
25
+# Debian/Ubuntu based images. Leave unset for other flavors.
26
+DIB_APT_SOURCES=${DIB_APT_SOURCES:-""}
27
+DIB_BUILD_OFFLINE=$(trueorfalse False $DIB_BUILD_OFFLINE)
23 28
 DIB_IMAGE_CACHE=$DATA_DIR/diskimage-builder/image-create
24 29
 DIB_PIP_REPO=$DATA_DIR/diskimage-builder/pip-repo
25 30
 DIB_PIP_REPO_PORT=${DIB_PIP_REPO_PORT:-8899}
31
+
26 32
 OCC_DIR=$DEST/os-collect-config
27 33
 ORC_DIR=$DEST/os-refresh-config
28 34
 OAC_DIR=$DEST/os-apply-config
29 35
 
36
+# Include the apt-sources element in builds if we have an
37
+# alternative sources.list specified.
38
+if [ -n "$DIB_APT_SOURCES" ]; then
39
+    if [ ! -e "$DIB_APT_SOURCES" ]; then
40
+        die $LINENO "DIB_APT_SOURCES set but not found at $DIB_APT_SOURCES"
41
+    fi
42
+    EXTRA_ELEMENTS="apt-sources"
43
+fi
44
+
30 45
 # Functions
31 46
 # ---------
32 47
 
... ...
@@ -106,9 +121,11 @@ function disk_image_create_upload {
106 106
 
107 107
     # The disk-image-create command to run
108 108
     ELEMENTS_PATH=$elements_path \
109
+    DIB_APT_SOURCES=$DIB_APT_SOURCES \
110
+    DIB_OFFLINE=$DIB_BUILD_OFFLINE \
109 111
     PYPI_MIRROR_URL=$pypi_mirror_url \
110 112
     PYPI_MIRROR_URL_1=$pypi_mirror_url_1 \
111
-    disk-image-create -a amd64 $image_elements \
113
+    disk-image-create -a amd64 $image_elements $EXTRA_ELEMENTS \
112 114
         --image-cache $DIB_IMAGE_CACHE \
113 115
         -o $image_path
114 116