From 0f72625fba22783bf78ffdc809da7fd42d0c4310 Mon Sep 17 00:00:00 2001 From: Adam Gandelman Date: Wed, 1 Oct 2014 17:06:19 -0700 Subject: [PATCH] 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 --- lib/dib | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/dib b/lib/dib index d39d8016c5..30b31ec0ee 100644 --- a/lib/dib +++ b/lib/dib @@ -20,13 +20,28 @@ set +o xtrace # set up default directories DIB_DIR=$DEST/diskimage-builder TIE_DIR=$DEST/tripleo-image-elements + +# NOTE: Setting DIB_APT_SOURCES assumes you will be building +# Debian/Ubuntu based images. Leave unset for other flavors. +DIB_APT_SOURCES=${DIB_APT_SOURCES:-""} +DIB_BUILD_OFFLINE=$(trueorfalse False $DIB_BUILD_OFFLINE) DIB_IMAGE_CACHE=$DATA_DIR/diskimage-builder/image-create DIB_PIP_REPO=$DATA_DIR/diskimage-builder/pip-repo DIB_PIP_REPO_PORT=${DIB_PIP_REPO_PORT:-8899} + OCC_DIR=$DEST/os-collect-config ORC_DIR=$DEST/os-refresh-config OAC_DIR=$DEST/os-apply-config +# Include the apt-sources element in builds if we have an +# alternative sources.list specified. +if [ -n "$DIB_APT_SOURCES" ]; then + if [ ! -e "$DIB_APT_SOURCES" ]; then + die $LINENO "DIB_APT_SOURCES set but not found at $DIB_APT_SOURCES" + fi + EXTRA_ELEMENTS="apt-sources" +fi + # Functions # --------- @@ -106,9 +121,11 @@ function disk_image_create_upload { # The disk-image-create command to run ELEMENTS_PATH=$elements_path \ + DIB_APT_SOURCES=$DIB_APT_SOURCES \ + DIB_OFFLINE=$DIB_BUILD_OFFLINE \ PYPI_MIRROR_URL=$pypi_mirror_url \ PYPI_MIRROR_URL_1=$pypi_mirror_url_1 \ - disk-image-create -a amd64 $image_elements \ + disk-image-create -a amd64 $image_elements $EXTRA_ELEMENTS \ --image-cache $DIB_IMAGE_CACHE \ -o $image_path