Example #1
0
def setup_app(config=None):
    if not config:
        config = get_pecan_config()
    m_config.set_config_defaults()

    app_conf = dict(config.app)

    db_api_v2.setup_db()

    periodic.setup()

    coordination.Service('api_group').register_membership()

    app = pecan.make_app(
        app_conf.pop('root'),
        hooks=lambda: [ctx.ContextHook(), ctx.AuthHook()],
        logging=getattr(config, 'logging', {}),
        **app_conf
    )

    # Set up access control.
    app = access_control.setup(app)

    # Create a CORS wrapper, and attach mistral-specific defaults that must be
    # included in all CORS responses.
    app = cors_middleware.CORS(app, cfg.CONF)

    return app
    def test_single_execution_with_multiple_processes(self, start_wf_mock):
        def stop_thread_groups():
            print('Killing cron trigger threads...')
            [tg.stop() for tg in self.trigger_threads]

        self.trigger_threads = [
            periodic.setup(),
            periodic.setup(),
            periodic.setup()
        ]
        self.addCleanup(stop_thread_groups)

        trigger_count = 5
        t_s.create_cron_trigger(
            'ct1',
            self.wf.name,
            {},
            {},
            '* * * * * */1',  # Every second
            None,
            trigger_count,
            datetime.datetime(2010, 8, 25))

        # Wait until there are 'trigger_count' executions.
        self._await(
            lambda: self._wait_for_single_execution_with_multiple_processes(
                trigger_count, start_wf_mock))

        # Wait some more and make sure there are no more than 'trigger_count'
        # executions.
        eventlet.sleep(5)

        self.assertEqual(trigger_count, start_wf_mock.call_count)
Example #3
0
def setup_app(config=None):
    if not config:
        config = get_pecan_config()

    m_config.set_config_defaults()

    app_conf = dict(config.app)

    db_api_v2.setup_db()

    if not app_conf.pop('disable_cron_trigger_thread', False):
        periodic.setup()

    coordination.Service('api_group').register_membership()

    app = pecan.make_app(
        app_conf.pop('root'),
        hooks=lambda: [ctx.ContextHook(), ctx.AuthHook()],
        logging=getattr(config, 'logging', {}),
        **app_conf)

    # Set up access control.
    app = access_control.setup(app)

    # Set up profiler.
    if cfg.CONF.profiler.enabled:
        app = osprofiler.web.WsgiMiddleware(
            app,
            hmac_keys=cfg.CONF.profiler.hmac_keys,
            enabled=cfg.CONF.profiler.enabled)

    # Create a CORS wrapper, and attach mistral-specific defaults that must be
    # included in all CORS responses.
    return cors_middleware.CORS(app, cfg.CONF)
    def test_single_execution_with_multiple_processes(self, start_wf_mock):
        def stop_thread_groups():
            [tg.stop() for tg in self.triggers]

        self.triggers = [periodic.setup(), periodic.setup(), periodic.setup()]
        self.addCleanup(stop_thread_groups)

        trigger_count = 5
        t_s.create_cron_trigger(
            'ct1',
            self.wf.name,
            {},
            {},
            '* * * * * */1',  # Every second
            None,
            trigger_count,
            datetime.datetime(2010, 8, 25)
        )

        # Wait until there are 'trigger_count' executions.
        self._await(
            lambda: self._wait_for_single_execution_with_multiple_processes(
                trigger_count,
                start_wf_mock
            )
        )

        # Wait some more and make sure there are no more than 'trigger_count'
        # executions.
        eventlet.sleep(5)

        self.assertEqual(trigger_count, start_wf_mock.call_count)
    def test_create_delete_trust_in_trigger(self, create_ctx, delete_trust):
        create_ctx.return_value = self.ctx
        cfg.CONF.set_default('auth_enable', True, group='pecan')
        trigger_thread = periodic.setup()
        self.addCleanup(trigger_thread.stop)
        self.addCleanup(
            cfg.CONF.set_default, 'auth_enable',
            False, group='pecan'
        )

        t_s.create_cron_trigger(
            'trigger-%s' % utils.generate_unicode_uuid(),
            self.wf.name,
            {},
            {},
            '* * * * * *',
            None,
            1,
            datetime.datetime(2010, 8, 25)
        )

        self._await(
            lambda: delete_trust.call_count == 1, timeout=10
        )
        self.assertEqual('my_trust_id', delete_trust.mock_calls[0][1][0])
Example #6
0
def setup_app(config=None):
    if not config:
        config = get_pecan_config()

    m_config.set_config_defaults()

    app_conf = dict(config.app)

    db_api_v2.setup_db()

    # TODO(rakhmerov): Why do we run cron triggers in the API layer?
    # Should we move it to engine?s
    if cfg.CONF.cron_trigger.enabled:
        periodic.setup()

    coordination.Service('api_group').register_membership()

    app = pecan.make_app(
        app_conf.pop('root'),
        hooks=lambda: [ctx.AuthHook(), ctx.ContextHook()],
        logging=getattr(config, 'logging', {}),
        **app_conf
    )

    # Set up access control.
    app = access_control.setup(app)

    # TODO(rakhmerov): need to get rid of this call.
    # Set up RPC related flags in config
    rpc.get_transport()

    # Set up profiler.
    if cfg.CONF.profiler.enabled:
        app = osprofiler.web.WsgiMiddleware(
            app,
            hmac_keys=cfg.CONF.profiler.hmac_keys,
            enabled=cfg.CONF.profiler.enabled
        )

    # Create HTTPProxyToWSGI wrapper
    app = http_proxy_to_wsgi_middleware.HTTPProxyToWSGI(app, cfg.CONF)

    # Create a CORS wrapper, and attach mistral-specific defaults that must be
    # included in all CORS responses.
    return cors_middleware.CORS(app, cfg.CONF)
Example #7
0
def setup_app(config=None):
    if not config:
        config = get_pecan_config()

    m_config.set_config_defaults()

    app_conf = dict(config.app)

    db_api_v2.setup_db()

    # TODO(rakhmerov): Why do we run cron triggers in the API layer?
    # Should we move it to engine?s
    if cfg.CONF.cron_trigger.enabled:
        periodic.setup()

    coordination.Service('api_group').register_membership()

    app = pecan.make_app(
        app_conf.pop('root'),
        hooks=lambda: [ctx.AuthHook(), ctx.ContextHook()],
        logging=getattr(config, 'logging', {}),
        **app_conf)

    # Set up access control.
    app = access_control.setup(app)

    # TODO(rakhmerov): need to get rid of this call.
    # Set up RPC related flags in config
    rpc.get_transport()

    # Set up profiler.
    if cfg.CONF.profiler.enabled:
        app = osprofiler.web.WsgiMiddleware(
            app,
            hmac_keys=cfg.CONF.profiler.hmac_keys,
            enabled=cfg.CONF.profiler.enabled)

    # Create HTTPProxyToWSGI wrapper
    app = http_proxy_to_wsgi_middleware.HTTPProxyToWSGI(app, cfg.CONF)

    # Create a CORS wrapper, and attach mistral-specific defaults that must be
    # included in all CORS responses.
    return cors_middleware.CORS(app, cfg.CONF)
Example #8
0
def setup_app(config=None):
    if not config:
        config = get_pecan_config()

    app_conf = dict(config.app)

    db_api_v2.setup_db()

    periodic.setup()

    app = pecan.make_app(
        app_conf.pop('root'),
        hooks=lambda: [ctx.ContextHook(), ctx.AuthHook()],
        logging=getattr(config, 'logging', {}),
        **app_conf)

    # Set up access control.
    app = access_control.setup(app)

    return app
Example #9
0
def setup_app(config=None):
    if not config:
        config = get_pecan_config()

    app_conf = dict(config.app)

    db_api_v2.setup_db()

    periodic.setup()

    app = pecan.make_app(
        app_conf.pop('root'),
        hooks=lambda: [ctx.ContextHook(), ctx.AuthHook()],
        logging=getattr(config, 'logging', {}),
        **app_conf
    )

    # Set up access control.
    app = access_control.setup(app)

    return app
Example #10
0
def setup_app(config=None):
    if not config:
        config = get_pecan_config()

    m_config.set_config_defaults()

    app_conf = dict(config.app)

    db_api_v2.setup_db()

    if not app_conf.pop('disable_cron_trigger_thread', False):
        periodic.setup()

    coordination.Service('api_group').register_membership()

    app = pecan.make_app(
        app_conf.pop('root'),
        hooks=lambda: [ctx.ContextHook(), ctx.AuthHook()],
        logging=getattr(config, 'logging', {}),
        **app_conf
    )

    # Set up access control.
    app = access_control.setup(app)

    # Set up RPC related flags in config
    rpc.get_transport()

    # Set up profiler.
    if cfg.CONF.profiler.enabled:
        app = osprofiler.web.WsgiMiddleware(
            app,
            hmac_keys=cfg.CONF.profiler.hmac_keys,
            enabled=cfg.CONF.profiler.enabled
        )

    # Create a CORS wrapper, and attach mistral-specific defaults that must be
    # included in all CORS responses.
    return cors_middleware.CORS(app, cfg.CONF)
Example #11
0
def setup_app(config=None):
    if not config:
        config = get_pecan_config()

    app_conf = dict(config.app)

    db_api.setup_db()
    engine.load_engine()
    ##TODO(akuznetsov) move this to trigger scheduling to separate process
    periodic.setup()

    app = pecan.make_app(
        app_conf.pop('root'),
        hooks=lambda: [ctx.ContextHook()],
        logging=getattr(config, 'logging', {}),
        **app_conf
    )

    # Set up access control.
    app = access_control.setup(app)

    return app
Example #12
0
def setup_app(config=None, transport=None):
    if not config:
        config = get_pecan_config()

    app_conf = dict(config.app)

    db_api.setup_db()

    ##TODO(akuznetsov) move this to trigger scheduling to separate process
    periodic.setup(transport)

    app = pecan.make_app(
        app_conf.pop('root'),
        hooks=lambda:
        [ctx.ContextHook(),
         engine.EngineHook(transport=transport)],
        logging=getattr(config, 'logging', {}),
        **app_conf)

    # Set up access control.
    app = access_control.setup(app)

    return app
Example #13
0
def setup_app(config=None):
    if not config:
        config = get_pecan_config()

    app_conf = dict(config.app)

    db_api_v2.setup_db()

    periodic.setup()

    coordination.Service('api_group').register_membership()

    app = pecan.make_app(
        app_conf.pop('root'),
        hooks=lambda: [ctx.ContextHook(), ctx.AuthHook()],
        logging=getattr(config, 'logging', {}),
        **app_conf
    )

    # Set up access control.
    app = access_control.setup(app)

    # Create a CORS wrapper, and attach mistral-specific defaults that must be
    # included in all CORS responses.
    app = cors_middleware.CORS(app, cfg.CONF)
    app.set_latent(
        allow_headers=['X-Auth-Token', 'X-Identity-Status', 'X-Roles',
                       'X-Service-Catalog', 'X-User-Id', 'X-Tenant-Id'
                       'X-Project-Id', 'X-User-Name', 'X-Project-Name'],
        allow_methods=['GET', 'PUT', 'POST', 'DELETE', 'PATCH'],
        expose_headers=['X-Auth-Token', 'X-Subject-Token',
                        'X-Service-Token', 'X-Project-Id', 'X-User-Name',
                        'X-Project-Name']
    )

    return app
Example #14
0
def setup_app(config=None):
    if not config:
        config = get_pecan_config()

    app_conf = dict(config.app)

    db_api_v2.setup_db()

    periodic.setup()

    coordination.Service('api_group').register_membership()

    app = pecan.make_app(
        app_conf.pop('root'),
        hooks=lambda: [ctx.ContextHook(), ctx.AuthHook()],
        logging=getattr(config, 'logging', {}),
        **app_conf)

    # Set up access control.
    app = access_control.setup(app)

    # Create a CORS wrapper, and attach mistral-specific defaults that must be
    # included in all CORS responses.
    app = cors_middleware.CORS(app, cfg.CONF)
    app.set_latent(allow_headers=[
        'X-Auth-Token', 'X-Identity-Status', 'X-Roles', 'X-Service-Catalog',
        'X-User-Id', 'X-Tenant-Id'
        'X-Project-Id', 'X-User-Name', 'X-Project-Name'
    ],
                   allow_methods=['GET', 'PUT', 'POST', 'DELETE', 'PATCH'],
                   expose_headers=[
                       'X-Auth-Token', 'X-Subject-Token', 'X-Service-Token',
                       'X-Project-Id', 'X-User-Name', 'X-Project-Name'
                   ])

    return app
    def test_create_delete_trust_in_trigger(self, delete_trust, create_ctx):
        create_ctx.return_value = self.ctx
        cfg.CONF.set_default('auth_enable', True, group='pecan')
        trigger_thread = periodic.setup()
        self.addCleanup(trigger_thread.stop)
        self.addCleanup(cfg.CONF.set_default,
                        'auth_enable',
                        False,
                        group='pecan')

        t_s.create_cron_trigger('trigger-%s' % utils.generate_unicode_uuid(),
                                self.wf.name, {}, {}, '* * * * * *', None, 1,
                                datetime.datetime(2010, 8, 25))

        eventlet.sleep(1)
        self.assertEqual(0, delete_trust.call_count)