Example #1
0
    def delete(self, req, id):
        """
        Deletes an existing image with the registry.

        :param req: wsgi Request object
        :param id:  The opaque internal identifier for the image

        :retval Returns 200 if delete was successful, a fault if not.
        """
        if req.context.read_only:
            raise exc.HTTPForbidden()

        try:
            db_api.image_destroy(req.context, id)
        except exception.NotFound:
            return exc.HTTPNotFound()
        except exception.NotAuthorized:
            # If it's private and doesn't belong to them, don't let on
            # that it exists
            msg = _("Access by %(user)s to image %(id)s "
                    "denied") % ({
                        'user': req.context.user,
                        'id': id
                    })
            logger.info(msg)
            raise exc.HTTPNotFound()
Example #2
0
 def test_image_get_all_marker_deleted_showing_deleted(self):
     """Specify a deleted image as a marker if showing deleted images."""
     db_api.image_destroy(self.adm_context, UUID1)
     filters = {'deleted': True}
     images = db_api.image_get_all(self.context, marker=UUID1,
                                   filters=filters)
     self.assertEquals(len(images), 0)
Example #3
0
 def test_image_get_all_marker_deleted_showing_deleted(self):
     """Specify a deleted image as a marker if showing deleted images."""
     db_api.image_destroy(self.adm_context, UUID1)
     filters = {'deleted': True}
     images = db_api.image_get_all(self.context,
                                   marker=UUID1,
                                   filters=filters)
     self.assertEquals(len(images), 0)
Example #4
0
 def test_image_get_all_marker_deleted(self):
     """Cannot specify a deleted image as a marker."""
     db_api.image_destroy(self.adm_context, UUID1)
     filters = {'deleted': False}
     self.assertRaises(exception.NotFound,
                       db_api.image_get_all,
                       self.context,
                       marker=UUID1,
                       filters=filters)
Example #5
0
    def delete(self, req, id):
        """
        Deletes an existing image with the registry.

        :param req: wsgi Request object
        :param id:  The opaque internal identifier for the image

        :retval Returns 200 if delete was successful, a fault if not.
        """
        if req.context.read_only:
            raise exc.HTTPForbidden()

        try:
            db_api.image_destroy(req.context, id)
        except exception.NotFound:
            return exc.HTTPNotFound()
        except exception.NotAuthorized:
            # If it's private and doesn't belong to them, don't let on
            # that it exists
            msg = _("Access by %(user)s to image %(id)s "
                    "denied") % ({'user': req.context.user,
                    'id': id})
            logger.info(msg)
            raise exc.HTTPNotFound()
Example #6
0
 def test_image_get_all_marker_deleted_showing_deleted_as_admin(self):
     """Specify a deleted image as a marker if showing deleted images."""
     db_api.image_destroy(self.adm_context, UUID1)
     images = db_api.image_get_all(self.adm_context, marker=UUID1)
     self.assertEquals(len(images), 0)
Example #7
0
 def test_image_get_all_marker_deleted(self):
     """Cannot specify a deleted image as a marker."""
     db_api.image_destroy(self.adm_context, UUID1)
     filters = {'deleted': False}
     self.assertRaises(exception.NotFound, db_api.image_get_all,
                       self.context, marker=UUID1, filters=filters)
Example #8
0
 def test_image_get_force_allow_deleted(self):
     db_api.image_destroy(self.adm_context, UUID1)
     image = db_api.image_get(self.context, UUID1, force_show_deleted=True)
     self.assertEquals(image['id'], FIXTURES[0]['id'])
Example #9
0
 def test_image_get_disallow_deleted(self):
     db_api.image_destroy(self.adm_context, UUID1)
     self.assertRaises(exception.NotFound, db_api.image_get,
                       self.context, UUID1)
Example #10
0
 def test_image_get_all_marker_deleted_showing_deleted_as_admin(self):
     """Specify a deleted image as a marker if showing deleted images."""
     db_api.image_destroy(self.adm_context, UUID1)
     images = db_api.image_get_all(self.adm_context, marker=UUID1)
     self.assertEquals(len(images), 0)
Example #11
0
 def test_image_get_force_allow_deleted(self):
     db_api.image_destroy(self.adm_context, UUID1)
     image = db_api.image_get(self.context, UUID1, force_show_deleted=True)
     self.assertEquals(image['id'], FIXTURES[0]['id'])
Example #12
0
 def test_image_get_disallow_deleted(self):
     db_api.image_destroy(self.adm_context, UUID1)
     self.assertRaises(exception.NotFound, db_api.image_get, self.context,
                       UUID1)