summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-10-31 15:44:15 +0000
committerGerrit Code Review <review@openstack.org>2012-10-31 15:44:15 +0000
commit73066e842c44e72d60cfe7d6cda0a17b1efeb5b9 (patch)
treeca4be6538995a3d45189d476dc04d0def3a73765 /nova
parent1594785f00e73bbb767db7f53a1c2171d9eef210 (diff)
parent17149f688d22e4f4938674f7179a03caeafbfc93 (diff)
Merge "fetch_images() method no more needed"
Diffstat (limited to 'nova')
-rw-r--r--nova/compute/manager.py30
-rw-r--r--nova/image/glance.py2
2 files changed, 8 insertions, 24 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index f43aa0096..46da52c1a 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1241,43 +1241,27 @@ class ComputeManager(manager.SchedulerDependentManager):
:param rotation: int representing how many backups to keep around;
None if rotation shouldn't be used (as in the case of snapshots)
"""
- # NOTE(jk0): Eventually extract this out to the ImageService?
- def fetch_images():
- images = []
- marker = None
- while True:
- if marker is not None:
- batch = image_service.detail(context, filters=filters,
- marker=marker, sort_key='created_at',
- sort_dir='desc')
- else:
- batch = image_service.detail(context, filters=filters,
- sort_key='created_at', sort_dir='desc')
- if not batch:
- break
- images += batch
- marker = batch[-1]['id']
- return images
-
image_service = glance.get_default_image_service()
filters = {'property-image_type': 'backup',
'property-backup_type': backup_type,
'property-instance_uuid': instance['uuid']}
- images = fetch_images()
+ images = image_service.detail(context, filters=filters,
+ sort_key='created_at', sort_dir='desc')
num_images = len(images)
- LOG.debug(_("Found %(num_images)d images (rotation: %(rotation)d)")
- % locals(), instance=instance)
+ LOG.debug(_("Found %(num_images)d images (rotation: %(rotation)d)"),
+ locals(), instance=instance)
+
if num_images > rotation:
# NOTE(sirp): this deletes all backups that exceed the rotation
# limit
excess = len(images) - rotation
- LOG.debug(_("Rotating out %d backups") % excess,
+ LOG.debug(_("Rotating out %d backups"), excess,
instance=instance)
for i in xrange(excess):
image = images.pop()
image_id = image['id']
- LOG.debug(_("Deleting image %s") % image_id,
+ LOG.debug(_("Deleting image %s"), image_id,
instance=instance)
image_service.delete(context, image_id)
diff --git a/nova/image/glance.py b/nova/image/glance.py
index c306a6eef..4c77d1204 100644
--- a/nova/image/glance.py
+++ b/nova/image/glance.py
@@ -177,7 +177,7 @@ class GlanceImageService(object):
accepted_params = ('filters', 'marker', 'limit',
'sort_key', 'sort_dir')
for param in accepted_params:
- if param in params:
+ if params.get(param):
_params[param] = params.get(param)
# ensure filters is a dict