示例#1
0
文件: __init__.py 项目: isethi/glance
def update_image_read_acl(req, db_api, image):
    """Helper function to set ACL permissions on images in the image store"""
    location_uri = image['location']
    public = image['is_public']
    image_id = image['id']
    if location_uri:
        try:
            read_tenants = []
            write_tenants = []
            members = db_api.image_member_find(req.context, image_id=image_id)
            for member in members:
                if not member['deleted']:
                    if member['can_share']:
                        write_tenants.append(member['member'])
                    else:
                        read_tenants.append(member['member'])
            set_acls(req.context,
                     location_uri,
                     public=public,
                     read_tenants=read_tenants,
                     write_tenants=write_tenants)
        except exception.UnknownScheme:
            msg = _("Store for image_id not found: %s") % image_id
            raise webob.exc.HTTPBadRequest(explanation=msg,
                                           request=req,
                                           content_type='text/plain')
示例#2
0
def update_image_read_acl(req, db_api, image):
    """Helper function to set ACL permissions on images in the image store"""
    location_uri = image['location']
    public = image['is_public']
    image_id = image['id']
    if location_uri:
        try:
            read_tenants = []
            write_tenants = []
            members = db_api.image_member_find(req.context,
                                               image_id=image_id)
            for member in members:
                if not member['deleted']:
                    if member['can_share']:
                        write_tenants.append(member['member'])
                    else:
                        read_tenants.append(member['member'])
            set_acls(req.context, location_uri, public=public,
                     read_tenants=read_tenants,
                     write_tenants=write_tenants)
        except exception.UnknownScheme:
            msg = _("Store for image_id not found: %s") % image_id
            raise webob.exc.HTTPBadRequest(explanation=msg,
                                           request=req,
                                           content_type='text/plain')
示例#3
0
 def update_store_acls(self, req, image_id, location_uri, public=False):
     if location_uri:
         try:
             read_tenants = []
             write_tenants = []
             members = registry.get_image_members(req.context, image_id)
             if members:
                 for member in members:
                     if member['can_share']:
                         write_tenants.append(member['member_id'])
                     else:
                         read_tenants.append(member['member_id'])
             store.set_acls(req.context, location_uri, public=public,
                            read_tenants=read_tenants,
                            write_tenants=write_tenants)
         except exception.UnknownScheme:
             msg = _("Store for image_id not found: %s") % image_id
             raise webob.exc.HTTPBadRequest(explanation=msg,
                                            request=req,
                                            content_type='text/plain')
示例#4
0
 def update_store_acls(self, req, image_id, location_uri, public=False):
     if location_uri:
         try:
             read_tenants = []
             write_tenants = []
             members = registry.get_image_members(req.context, image_id)
             if members:
                 for member in members:
                     if member['can_share']:
                         write_tenants.append(member['member_id'])
                     else:
                         read_tenants.append(member['member_id'])
             store.set_acls(req.context, location_uri, public=public,
                            read_tenants=read_tenants,
                            write_tenants=write_tenants)
         except exception.UnknownScheme:
             msg = _("Store for image_id not found: %s") % image_id
             raise webob.exc.HTTPBadRequest(explanation=msg,
                                            request=req,
                                            content_type='text/plain')