Skip to content

Commit

Permalink
Bug fix lp:726864
Browse files Browse the repository at this point in the history
rename 'id' to 'image_id' to avoid conflict with builtin id function

Change-Id: I79605275bf2607331f5b74076cb5689f071c92d5
  • Loading branch information
Justin Shepherd committed Aug 31, 2011
1 parent b2381cc commit 3cd4613
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions glance/api/__init__.py
Expand Up @@ -25,21 +25,21 @@


class BaseController(object):
def get_image_meta_or_404(self, request, id):
def get_image_meta_or_404(self, request, image_id):
"""
Grabs the image metadata for an image with a supplied
identifier or raises an HTTPNotFound (404) response
:param request: The WSGI/Webob Request object
:param id: The opaque image identifier
:param image_id: The opaque image identifier
:raises HTTPNotFound if image does not exist
"""
context = request.context
try:
return registry.get_image_metadata(self.options, context, id)
return registry.get_image_metadata(self.options, context, image_id)
except exception.NotFound:
msg = _("Image with identifier %s not found") % id
msg = _("Image with identifier %s not found") % image_id
logger.debug(msg)
raise webob.exc.HTTPNotFound(
msg, request=request, content_type='text/plain')
Expand All @@ -49,14 +49,14 @@ def get_image_meta_or_404(self, request, id):
raise webob.exc.HTTPForbidden(msg, request=request,
content_type='text/plain')

def get_active_image_meta_or_404(self, request, id):
def get_active_image_meta_or_404(self, request, image_id):
"""
Same as get_image_meta_or_404 except that it will raise a 404 if the
image isn't 'active'.
"""
image = self.get_image_meta_or_404(request, id)
image = self.get_image_meta_or_404(request, image_id)
if image['status'] != 'active':
msg = _("Image %s is not active") % id
msg = _("Image %s is not active") % image_id
logger.debug(msg)
raise webob.exc.HTTPNotFound(
msg, request=request, content_type='text/plain')
Expand Down
8 changes: 4 additions & 4 deletions glance/api/cached_images.py
Expand Up @@ -54,8 +54,8 @@ def index(self, req):

return dict(cached_images=entries)

def delete(self, req, id):
self.cache.purge(id)
def delete(self, req, image_id):
self.cache.purge(image_id)

def delete_collection(self, req):
"""
Expand All @@ -74,9 +74,9 @@ def delete_collection(self, req):
num_purged = self.cache.clear()
return dict(num_purged=num_purged)

def update(self, req, id):
def update(self, req, image_id):
"""PUT /cached_images/1 is used to prefetch an image into the cache"""
image_meta = self.get_active_image_meta_or_404(req, id)
image_meta = self.get_active_image_meta_or_404(req, image_id)
try:
self.cache.queue_prefetch(image_meta)
except exception.Invalid, e:
Expand Down
6 changes: 3 additions & 3 deletions glance/store/__init__.py
Expand Up @@ -153,20 +153,20 @@ def get_store_from_location(uri):
return loc.store_name


def schedule_delete_from_backend(uri, options, context, id, **kwargs):
def schedule_delete_from_backend(uri, options, context, image_id, **kwargs):
"""
Given a uri and a time, schedule the deletion of an image.
"""
use_delay = config.get_option(options, 'delayed_delete', type='bool',
default=False)
if not use_delay:
registry.update_image_metadata(options, context, id,
registry.update_image_metadata(options, context, image_id,
{'status': 'deleted'})
try:
return delete_from_backend(uri, **kwargs)
except (UnsupportedBackend, exception.NotFound):
msg = _("Failed to delete image from store (%(uri)s).") % locals()
logger.error(msg)

registry.update_image_metadata(options, context, id,
registry.update_image_metadata(options, context, image_id,
{'status': 'pending_delete'})
4 changes: 2 additions & 2 deletions glance/store/scrubber.py
Expand Up @@ -79,7 +79,7 @@ def run(self, pool, event=None):
delete_work = [(p['id'], p['location']) for p in pending]
pool.starmap(self._delete, delete_work)

def _delete(self, id, location):
def _delete(self, image_id, location):
try:
logger.debug(_("Deleting %(location)s") % locals())
store.delete_from_backend(location)
Expand All @@ -88,7 +88,7 @@ def _delete(self, id, location):
logger.error(msg)

ctx = context.RequestContext(is_admin=True, show_deleted=True)
db_api.image_update(ctx, id, {'status': 'deleted'})
db_api.image_update(ctx, image_id, {'status': 'deleted'})


def app_factory(global_config, **local_conf):
Expand Down

0 comments on commit 3cd4613

Please sign in to comment.