コード例 #1
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)
コード例 #2
0
ファイル: images.py プロジェクト: AsylumCorp/glance
    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.ForbiddenPublicImage:
            # If it's private and doesn't belong to them, don't let on
            # that it exists
            msg = _("Access by %(user)s to delete public image %(id)s denied")
            args = {'user': req.context.user, 'id': id}
            logger.info(msg % args)
            raise exc.HTTPForbidden()

        except exception.Forbidden:
            msg = _("Access by %(user)s to delete private image %(id)s denied")
            args = {'user': req.context.user, 'id': id}
            logger.info(msg % args)
            return exc.HTTPNotFound()

        except exception.NotFound:
            return exc.HTTPNotFound()
コード例 #3
0
ファイル: images.py プロジェクト: russellb/glance
    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()
コード例 #4
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)
コード例 #5
0
ファイル: test_db.py プロジェクト: russellb/glance
 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)
コード例 #6
0
ファイル: server.py プロジェクト: apowers/openstack-nova
    def delete(self, req, id):
        """
        Deletes an existing image with the registry.

        :param req: Request body.  Ignored.
        :param id:  The opaque internal identifier for the image

        :retval Returns 200 if delete was successful, a fault if not.

        """
        context = None
        try:
            db_api.image_destroy(context, id)
        except exception.NotFound:
            return exc.HTTPNotFound()
コード例 #7
0
ファイル: server.py プロジェクト: statik/glance
    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
            logger.info("Access by %s to image %s denied" %
                        (req.context.user, id))
            raise exc.HTTPNotFound()
コード例 #8
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)
コード例 #9
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)
コード例 #10
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'], self.fixtures[0]['id'])
コード例 #11
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)
コード例 #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)
コード例 #13
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)
コード例 #14
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'])
コード例 #15
0
ファイル: test_db.py プロジェクト: OpenStack-Kha/glance
 def test_image_get_allow_deleted(self):
     db_api.image_destroy(self.adm_context, UUID1)
     image = db_api.image_get(self.adm_context, UUID1)
     self.assertEquals(image['id'], FIXTURES[0]['id'])
コード例 #16
0
 def test_image_get_allow_deleted(self):
     db_api.image_destroy(self.adm_context, UUID1)
     image = db_api.image_get(self.adm_context, UUID1)
     self.assertEquals(image['id'], self.fixtures[0]['id'])