Ejemplo n.º 1
0
    def members(self, req, image_id):
        """
        Return a list of dictionaries indicating the members of the
        image, i.e., those tenants the image is shared with.

        :param req: the Request object coming from the wsgi layer
        :param image_id: The opaque image identifier
        :retval The response body is a mapping of the following form::

            {'members': [
                {'member_id': <MEMBER>,
                 'can_share': <SHARE_PERMISSION>, ...}, ...
            ]}
        """
        try:
            members = registry.get_image_members(self.options, req.context,
                                                 image_id)
        except exception.NotFound:
            msg = _("Image with identifier %s not found") % image_id
            logger.debug(msg)
            raise HTTPNotFound(msg, request=req, content_type='text/plain')
        except exception.NotAuthorized:
            msg = _("Unauthorized image access")
            logger.debug(msg)
            raise HTTPForbidden(msg, request=req, content_type='text/plain')
        return dict(members=members)
Ejemplo n.º 2
0
    def index(self, req, image_id):
        """
        Return a list of dictionaries indicating the members of the
        image, i.e., those tenants the image is shared with.

        :param req: the Request object coming from the wsgi layer
        :param image_id: The opaque image identifier
        :retval The response body is a mapping of the following form::

            {'members': [
                {'member_id': <MEMBER>,
                 'can_share': <SHARE_PERMISSION>, ...}, ...
            ]}
        """
        try:
            members = registry.get_image_members(req.context, image_id)
        except exception.NotFound:
            msg = _("Image with identifier %s not found") % image_id
            LOG.debug(msg)
            raise webob.exc.HTTPNotFound(msg)
        except exception.Forbidden:
            msg = _("Unauthorized image access")
            LOG.debug(msg)
            raise webob.exc.HTTPForbidden(msg)
        return dict(members=members)
Ejemplo n.º 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 HTTPBadRequest(explanation=msg,
                                  request=req,
                                  content_type='text/plain')
Ejemplo n.º 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')