def test_add_access(self):
        project_id = "456"
        extra_specs = {constants.ExtraSpecs.DRIVER_HANDLES_SHARE_SERVERS: "true"}
        share_type = share_types.create(self.context, "type1", extra_specs)
        share_type_id = share_type.get("id")

        share_types.add_share_type_access(self.context, share_type_id, project_id)
        stype_access = db.share_type_access_get_all(self.context, share_type_id)
        self.assertIn(project_id, [a.project_id for a in stype_access])
Beispiel #2
0
    def _add_project_access(self, req, id, body):
        context = req.environ['manila.context']
        self._check_body(body, 'addProjectAccess')
        project = body['addProjectAccess']['project']

        self._verify_if_non_public_share_type(context, id)

        try:
            share_types.add_share_type_access(context, id, project)
        except exception.ShareTypeAccessExists as err:
            raise webob.exc.HTTPConflict(explanation=six.text_type(err))

        return webob.Response(status_int=202)
Beispiel #3
0
    def _add_project_access(self, req, id, body):
        context = req.environ['manila.context']
        self._check_body(body, 'addProjectAccess')
        project = body['addProjectAccess']['project']

        self._verify_if_non_public_share_type(context, id)

        try:
            share_types.add_share_type_access(context, id, project)
        except exception.ShareTypeAccessExists as err:
            raise webob.exc.HTTPConflict(explanation=six.text_type(err))

        return webob.Response(status_int=http_client.ACCEPTED)
Beispiel #4
0
    def test_add_access(self):
        project_id = '456'
        extra_specs = {
            constants.ExtraSpecs.DRIVER_HANDLES_SHARE_SERVERS: 'true'
        }
        share_type = share_types.create(self.context, 'type1', extra_specs)
        share_type_id = share_type.get('id')

        share_types.add_share_type_access(self.context, share_type_id,
                                          project_id)
        stype_access = db.share_type_access_get_all(self.context,
                                                    share_type_id)
        self.assertIn(project_id, [a.project_id for a in stype_access])
Beispiel #5
0
    def _addProjectAccess(self, req, id, body):
        context = req.environ['manila.context']
        authorize(context, action="addProjectAccess")
        self._check_body(body, 'addProjectAccess')
        project = body['addProjectAccess']['project']

        try:
            share_type = share_types.get_share_type(context, id)

            if share_type['is_public']:
                msg = _("You cannot add project to public share_type.")
                raise webob.exc.HTTPForbidden(explanation=msg)

        except exception.ShareTypeNotFound as err:
            raise webob.exc.HTTPNotFound(explanation=six.text_type(err))

        try:
            share_types.add_share_type_access(context, id, project)
        except exception.ShareTypeAccessExists as err:
            raise webob.exc.HTTPConflict(explanation=six.text_type(err))

        return webob.Response(status_int=202)