~gundlach/nova/servers_api

« back to all changes in this revision

Viewing changes to nova/objectstore/handler.py

  • Committer: Cerberus
  • Date: 2010-09-29 22:24:36 UTC
  • mfrom: (295.1.15 trunk)
  • Revision ID: matt.dietz@rackspace.com-20100929222436-haxgq7uool12oqs1
Merge from trunk and networking setup for new instances

Show diffs side-by-side

added added

removed removed

Lines of Context:
352
352
                m[u'imageType'] = m['type']
353
353
            elif 'imageType' in m:
354
354
                m[u'type'] = m['imageType']
 
355
            if 'displayName' not in m:
 
356
                m[u'displayName'] = u''
355
357
            return m
356
358
 
357
359
        request.write(json.dumps([decorate(i.metadata) for i in images]))
382
384
    def render_POST(self, request): # pylint: disable-msg=R0201
383
385
        """Update image attributes: public/private"""
384
386
 
 
387
        # image_id required for all requests
385
388
        image_id = get_argument(request, 'image_id', u'')
 
389
        image_object = image.Image(image_id)
 
390
        if not image_object.is_authorized(request.context):
 
391
            logging.debug("not authorized for render_POST in images")
 
392
            raise exception.NotAuthorized
 
393
 
386
394
        operation = get_argument(request, 'operation', u'')
387
 
 
388
 
        image_object = image.Image(image_id)
389
 
 
390
 
        if not image_object.is_authorized(request.context):
391
 
            raise exception.NotAuthorized
392
 
 
393
 
        image_object.set_public(operation=='add')
394
 
 
 
395
        if operation:
 
396
            # operation implies publicity toggle
 
397
            logging.debug("handling publicity toggle")
 
398
            image_object.set_public(operation=='add')
 
399
        else:
 
400
            # other attributes imply update
 
401
            logging.debug("update user fields")
 
402
            clean_args = {}
 
403
            for arg in request.args.keys():
 
404
                clean_args[arg] = request.args[arg][0]
 
405
            image_object.update_user_editable_fields(clean_args)
395
406
        return ''
396
407
 
397
408
    def render_DELETE(self, request): # pylint: disable-msg=R0201