From 6253f489077891271b2d116936b0539a63343940 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Wed, 14 Dec 2011 13:49:59 -0800 Subject: [PATCH] Cache a copy of all images on the template VM. This is part 1 of a 2 part change that will get the images pre-populated in the devstack directory on the vm so that they aren't downloaded via the Internet each time. This needs to be merged first so that the directory with the images is available on the vm. The next change, to the gate-host script, will expect it to be there. Change-Id: I230e3d3032a9d605b2e1192e1f1df6d5da75d01e --- slave_scripts/devstack-vm-update-image.py | 11 +++++++++++ slave_scripts/devstack-vm-update-image.sh | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/slave_scripts/devstack-vm-update-image.py b/slave_scripts/devstack-vm-update-image.py index f8533751..e1a34330 100755 --- a/slave_scripts/devstack-vm-update-image.py +++ b/slave_scripts/devstack-vm-update-image.py @@ -41,6 +41,7 @@ IMAGE_NAME = 'devstack-oneiric' debs = ' '.join(open(sys.argv[1]).read().split('\n')) pips = ' '.join(open(sys.argv[2]).read().split('\n')) +filedir = sys.argv[3] if CLOUD_SERVERS_DRIVER == 'rackspace': Driver = get_driver(Provider.RACKSPACE) @@ -70,6 +71,16 @@ def run(action, x): if ret: raise Exception("Unable to %s" % action) +def scp(source, dest): + print 'copy', source, dest + ftp = client.open_sftp() + ftp.put(source, dest) + ftp.close() + +run('make file cache directory', 'mkdir -p files') +for fn in os.listdir(filedir): + source = os.path.join(filedir, fn) + scp(source, 'files/%s'%fn) run('update package list', 'sudo apt-get update') run('install packages', 'sudo DEBIAN_FRONTEND=noninteractive apt-get --option "Dpkg::Options::=--force-confold" --assume-yes install %s' % debs) run('install pips', 'sudo pip install %s' % pips) diff --git a/slave_scripts/devstack-vm-update-image.sh b/slave_scripts/devstack-vm-update-image.sh index 44e0df0e..2304d7a7 100755 --- a/slave_scripts/devstack-vm-update-image.sh +++ b/slave_scripts/devstack-vm-update-image.sh @@ -32,4 +32,16 @@ cd $WORKSPACE cat devstack/files/apts/* | grep -v NOPRIME | cut -d\# -f1 > devstack-debs cat devstack/files/pips/* > devstack-pips -$CI_SCRIPT_DIR/devstack-vm-update-image.py $WORKSPACE/devstack-debs $WORKSPACE/devstack-pips +source $WORKSPACE/devstack/stackrc +mkdir -p files +# Excerpt from devstack that downloads the images +for image_url in ${IMAGE_URLS//,/ }; do + # Downloads the image (uec ami+aki style), then extracts it. + IMAGE_FNAME=`echo "$image_url" | python -c "import sys; print sys.stdin.read().split('/')[-1]"` + IMAGE_NAME=`echo "$IMAGE_FNAME" | python -c "import sys; print sys.stdin.read().split('.tar.gz')[0].split('.tgz')[0]"` + if [ ! -f files/$IMAGE_FNAME ]; then + wget -c $image_url -O files/$IMAGE_FNAME + fi +done + +$CI_SCRIPT_DIR/devstack-vm-update-image.py $WORKSPACE/devstack-debs $WORKSPACE/devstack-pips $WORKSPACE/files