Example #1
0
    def test_add_access(self):
        project_id = '456'
        vtype = volume_types.create(self.ctxt, 'type1')
        vtype_id = vtype.get('id')

        volume_types.add_volume_type_access(self.ctxt, vtype_id, project_id)
        vtype_access = db.volume_type_access_get_all(self.ctxt, vtype_id)
        self.assertIn(project_id, [a.project_id for a in vtype_access])
    def test_add_access(self):
        project_id = '456'
        vtype = volume_types.create(self.ctxt, 'type1', is_public=False)
        vtype_id = vtype.get('id')

        volume_types.add_volume_type_access(self.ctxt, vtype_id, project_id)
        vtype_access = db.volume_type_access_get_all(self.ctxt, vtype_id)
        self.assertIn(project_id, [a.project_id for a in vtype_access])
    def test_add_access(self):
        project_id = fake.PROJECT_ID
        vtype = volume_types.create(self.ctxt, 'type1', is_public=False)
        vtype_id = vtype.get('id')

        volume_types.add_volume_type_access(self.ctxt, vtype_id, project_id)
        vtype_access = db.volume_type_access_get_all(self.ctxt, vtype_id)
        self.assertIn(project_id, [a.project_id for a in vtype_access])
Example #4
0
    def test_add_access(self):
        project_id = "456"
        vtype = volume_types.create(self.ctxt, "type1", is_public=False)
        vtype_id = vtype.get("id")

        volume_types.add_volume_type_access(self.ctxt, vtype_id, project_id)
        vtype_access = db.volume_type_access_get_all(self.ctxt, vtype_id)
        self.assertIn(project_id, [a.project_id for a in vtype_access])
Example #5
0
    def test_add_access_with_non_admin(self):
        self.ctxt = context.RequestContext("fake", "fake", is_admin=False)
        project_id = fake.PROJECT_ID
        vtype = volume_types.create(self.ctxt, "type1", is_public=False)
        vtype_id = vtype.get("id")

        volume_types.add_volume_type_access(self.ctxt, vtype_id, project_id)
        vtype_access = db.volume_type_access_get_all(self.ctxt.elevated(), vtype_id)
        self.assertIn(project_id, [a.project_id for a in vtype_access])
Example #6
0
    def test_add_access_with_non_admin(self):
        self.ctxt = context.RequestContext('fake', 'fake', is_admin=False)
        project_id = fake.PROJECT_ID
        vtype = volume_types.create(self.ctxt, 'type1', is_public=False)
        vtype_id = vtype.get('id')

        volume_types.add_volume_type_access(self.ctxt, vtype_id, project_id)
        vtype_access = db.volume_type_access_get_all(self.ctxt.elevated(),
                                                     vtype_id)
        self.assertIn(project_id, [a.project_id for a in vtype_access])
Example #7
0
    def test_add_access_with_non_admin(self):
        self.ctxt = context.RequestContext('fake', 'fake', is_admin=False)
        project_id = '456'
        vtype = volume_types.create(self.ctxt, 'type1', is_public=False)
        vtype_id = vtype.get('id')

        volume_types.add_volume_type_access(self.ctxt, vtype_id, project_id)
        vtype_access = db.volume_type_access_get_all(self.ctxt.elevated(),
                                                     vtype_id)
        self.assertIn(project_id, [a.project_id for a in vtype_access])
Example #8
0
    def _addProjectAccess(self, req, id, body):
        context = req.environ['cinder.context']
        context.authorize(policy.ADD_PROJECT_POLICY)
        project = body['addProjectAccess']['project']

        try:
            volume_types.add_volume_type_access(context, id, project)
        # Not found exception will be handled at the wsgi level
        except exception.VolumeTypeAccessExists as err:
            raise webob.exc.HTTPConflict(explanation=six.text_type(err))
        return webob.Response(status_int=http_client.ACCEPTED)
Example #9
0
    def _addProjectAccess(self, req, id, body):
        context = req.environ['cinder.context']
        context.authorize(policy.ADD_PROJECT_POLICY)
        project = body['addProjectAccess']['project']

        try:
            volume_types.add_volume_type_access(context, id, project)
        # Not found exception will be handled at the wsgi level
        except exception.VolumeTypeAccessExists as err:
            raise webob.exc.HTTPConflict(explanation=six.text_type(err))
        return webob.Response(status_int=http_client.ACCEPTED)
Example #10
0
    def _addProjectAccess(self, req, id, body):
        context = req.environ['cinder.context']
        authorize(context, action="addProjectAccess")
        self._check_body(body, 'addProjectAccess')
        project = body['addProjectAccess']['project']

        try:
            volume_types.add_volume_type_access(context, id, project)
        # Not found exception will be handled at the wsgi level
        except exception.VolumeTypeAccessExists as err:
            raise webob.exc.HTTPConflict(explanation=six.text_type(err))
        return webob.Response(status_int=202)
Example #11
0
    def _addProjectAccess(self, req, id, body):
        context = req.environ['cinder.context']
        authorize(context, action="addProjectAccess")
        self._check_body(body, 'addProjectAccess')
        project = body['addProjectAccess']['project']

        try:
            volume_types.add_volume_type_access(context, id, project)
        # Not found exception will be handled at the wsgi level
        except exception.VolumeTypeAccessExists as err:
            raise webob.exc.HTTPConflict(explanation=six.text_type(err))
        return webob.Response(status_int=202)
Example #12
0
    def _addProjectAccess(self, req, id, body):
        context = req.environ["cinder.context"]
        authorize(context, action="addProjectAccess")
        self._check_body(body, "addProjectAccess")
        project = body["addProjectAccess"]["project"]

        try:
            volume_types.add_volume_type_access(context, id, project)
        except exception.VolumeTypeAccessExists as err:
            raise webob.exc.HTTPConflict(explanation=six.text_type(err))
        except exception.VolumeTypeNotFound as err:
            raise webob.exc.HTTPNotFound(explanation=six.text_type(err))
        return webob.Response(status_int=202)