Esempio n. 1
0
def setup_app(pecan_config=None, extra_hooks=None):

    app_conf = get_pecan_config()

    client = rpc.get_client()

    storage_backend = storage.get_storage()

    app_hooks = [
        hooks.RPCHook(client),
        hooks.StorageHook(storage_backend),
    ]

    if CONF.auth_strategy == 'keystone':
        app_hooks.append(hooks.ContextHook())

    app = pecan.make_app(app_conf.app.root,
                         static_root=app_conf.app.static_root,
                         template_path=app_conf.app.template_path,
                         debug=CONF.api.pecan_debug,
                         force_canonical=getattr(app_conf.app,
                                                 'force_canonical', True),
                         hooks=app_hooks,
                         guess_content_type_from_ext=False)

    return app
Esempio n. 2
0
def setup_app(pecan_config=None, extra_hooks=None):

    app_conf = get_pecan_config()

    client = rpc.get_client()

    storage_backend = storage.get_storage()

    app_hooks = [
        hooks.RPCHook(client),
        hooks.StorageHook(storage_backend),
    ]

    if CONF.auth_strategy == 'keystone':
        app_hooks.append(hooks.ContextHook())

    app = pecan.make_app(
        app_conf.app.root,
        static_root=app_conf.app.static_root,
        template_path=app_conf.app.template_path,
        debug=CONF.api.pecan_debug,
        force_canonical=getattr(app_conf.app, 'force_canonical', True),
        hooks=app_hooks,
        guess_content_type_from_ext=False
    )

    if CONF.auth_strategy == 'keystone':
        return middleware.AuthTokenMiddleware(app, dict(CONF),
                                              app_conf.app.acl_public_routes)
    else:
        return app
Esempio n. 3
0
    def set_state(self, enabled):
        """Enable or disable a module.

        :param enabled: (bool) The state to put the module in.
        :return:  bool
        """
        api = db_api.get_instance()
        module_db = api.get_module_info()
        client = rpc.get_client().prepare(namespace='rating', fanout=True)
        if enabled:
            operation = 'enable_module'
        else:
            operation = 'disable_module'
        client.cast({}, operation, name=self.module_name)
        return module_db.set_state(self.module_name, enabled)
Esempio n. 4
0
    def set_state(self, enabled):
        """Enable or disable a module.

        :param enabled: (bool) The state to put the module in.
        :return:  bool
        """
        api = db_api.get_instance()
        module_db = api.get_module_info()
        client = rpc.get_client().prepare(namespace='rating',
                                          fanout=True)
        if enabled:
            operation = 'enable_module'
        else:
            operation = 'disable_module'
        client.cast({}, operation, name=self.module_name)
        return module_db.set_state(self.module_name, enabled)
Esempio n. 5
0
 def notify_reload(self):
     client = rpc.get_client().prepare(namespace='rating', fanout=True)
     client.cast({}, 'reload_module', name=self.module_name)
Esempio n. 6
0
 def notify_reload(self):
     client = rpc.get_client().prepare(namespace='rating', fanout=True)
     client.cast({}, 'reload_module', name=self.module_name)