~hudson-openstack/nova/trunk

« back to all changes in this revision

Viewing changes to nova/objectstore/image.py

  • Committer: Ewan Mellor
  • Date: 2010-08-09 11:10:27 UTC
  • mfrom: (212 trunk)
  • mto: (145.4.1 add-contains)
  • mto: This revision was merged to the branch mainline in revision 221.
  • Revision ID: ewan.mellor@citrix.com-20100809111027-xbdyu44l6nb68bvp
Merged with trunk again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
        except:
66
66
            pass
67
67
 
68
 
    def is_authorized(self, context):
 
68
    def is_authorized(self, context, readonly=False):
 
69
        # NOTE(devcamcar): Public images can be read by anyone,
 
70
        #                  but only modified by admin or owner.
69
71
        try:
70
 
            return self.metadata['isPublic'] or context.user.is_admin() or self.metadata['imageOwnerId'] == context.project.id
 
72
            return (self.metadata['isPublic'] and readonly) or \
 
73
                   context.user.is_admin() or \
 
74
                   self.metadata['imageOwnerId'] == context.project.id
71
75
        except:
72
76
            return False
73
77