From 4bce373528376fa169213267fe5ffee886f04626 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 8 Dec 2011 12:46:23 -0800 Subject: [PATCH] Use a new image name each time we snapshot. Work around a bug in RS cloud servers where after deleting an image, you may not be able to create a new one with the same name. Instead, generate a unique name for every image, and when we go to use it, find an image that _starts_ with the name we're looking for. Change-Id: I2e674c544b96e976c0460298ab74de1da8e7144c --- slave_scripts/devstack-vm-launch.py | 5 ++++- slave_scripts/devstack-vm-update-image.py | 11 +++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/slave_scripts/devstack-vm-launch.py b/slave_scripts/devstack-vm-launch.py index 7a54f4e9..540567a5 100755 --- a/slave_scripts/devstack-vm-launch.py +++ b/slave_scripts/devstack-vm-launch.py @@ -52,7 +52,10 @@ if CLOUD_SERVERS_DRIVER == 'rackspace': sizes = [sz for sz in conn.list_sizes() if sz.ram >= MIN_RAM] sizes.sort(lambda a,b: cmp(a.ram, b.ram)) size = sizes[0] - image = [img for img in conn.list_images() if img.name==IMAGE_NAME][0] + images = [img for img in conn.list_images() + if img.name.startswith(IMAGE_NAME)] + images.sort() + image = images[-1] else: raise Exception ("Driver not supported") diff --git a/slave_scripts/devstack-vm-update-image.py b/slave_scripts/devstack-vm-update-image.py index c3a5dbef..03a9fa05 100755 --- a/slave_scripts/devstack-vm-update-image.py +++ b/slave_scripts/devstack-vm-update-image.py @@ -50,11 +50,8 @@ if CLOUD_SERVERS_DRIVER == 'rackspace': node = [n for n in conn.list_nodes() if n.name==SERVER_NAME][0] print "Searching for %s image" % IMAGE_NAME - image = [img for img in conn.list_images() if img.name==IMAGE_NAME] - if image: - image = image[0] - else: - image = None + images = [img for img in conn.list_images() + if img.name.startswith(IMAGE_NAME)] else: raise Exception ("Driver not supported") @@ -81,9 +78,11 @@ run('run puppet', 'sudo bash -c "cd /root/openstack-ci-puppet && /usr/bin/git pu run('stop mysql', 'sudo /etc/init.d/mysql stop') run('stop rabbitmq', 'sudo /etc/init.d/rabbitmq-server stop') -if image: +for image in images: conn.ex_delete_image(image) +IMAGE_NAME = IMAGE_NAME+'-'+str(int(time.time())) + image = conn.ex_save_image(node=node, name=IMAGE_NAME) last_extra = None