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_register_membership(self, mock_get_identifier): cfg.CONF.set_default('backend_url', 'zake://', 'coordination') srv = coordination.Service('fake_group') srv.register_membership() self.addCleanup(srv.stop) srv_coordinator = coordination.get_service_coordinator() self.assertIsNotNone(srv_coordinator) self.assertTrue(srv_coordinator.is_active()) members = srv_coordinator.get_members('fake_group') mock_get_identifier.assert_called_once_with() self.assertEqual(set([six.b('fake_id')]), members)
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