Exemplo n.º 1
0
 def _create_security_service(share_network_id=None):
     service = {}
     service['type'] = "FAKE"
     service['project_id'] = 'fake-project-id'
     service_ref = db.security_service_create(
         context.get_admin_context(), service)
     db.share_network_add_security_service(context.get_admin_context(),
                                           share_network_id,
                                           service_ref['id'])
     return service_ref
Exemplo n.º 2
0
 def _create_security_service(share_network_id=None):
     service = {}
     service['type'] = "FAKE"
     service['project_id'] = 'fake-project-id'
     service_ref = db.security_service_create(context.get_admin_context(),
                                              service)
     db.share_network_add_security_service(context.get_admin_context(),
                                           share_network_id,
                                           service_ref['id'])
     return service_ref
Exemplo n.º 3
0
    def create(self, req, body):
        """Creates a new security service."""
        context = req.environ['manila.context']
        policy.check_policy(context, RESOURCE_NAME, 'create')

        if not self.is_valid_body(body, 'security_service'):
            raise exc.HTTPUnprocessableEntity()

        security_service_args = body['security_service']
        security_srv_type = security_service_args.get('type')
        allowed_types = constants.SECURITY_SERVICES_ALLOWED_TYPES
        if security_srv_type not in allowed_types:
            raise exception.InvalidInput(
                reason=(_("Invalid type %(type)s specified for security "
                          "service. Valid types are %(types)s") %
                        {'type': security_srv_type,
                         'types': ','.join(allowed_types)}))
        security_service_args['project_id'] = context.project_id
        security_service = db.security_service_create(
            context, security_service_args)

        return self._view_builder.detail(req, security_service)