def add_source(self, name, config, auth_config):
        LOG.info(config)
        rest_config = Configuration()
        rest_config.url_base = config.get('url', None)
        rest_config.accept = config.get('data_type', 'application/json')
        if config.auth == 'noauth':
            rest_config.auth_handler = 'None'
        else:
            auth = auth_config[config.auth]
            rest_config.auth_handler = auth.auth_handler
            rest_config.auth_handler_conf = Configuration(
                auth.get('auth_handler_conf', {}))

        content_type = getattr(WebReplicaLock, config.content_type)
        site_pattern = config.get('sites', None)
        lock_url = config.get('lock_url', None)

        if rest_config.url_base is not None:
            self._sources[name] = (webservice.RESTService(rest_config),
                                   content_type, site_pattern, lock_url)

        if config.get('oracledb', None) is not None:
            oracle_config = Configuration()
            oracle_config.db = config.oracledb.db
            oracle_config.pw = config.oracledb.password
            oracle_config.host = config.oracledb.host
            self._sources[name] = (webservice.OracleService(oracle_config),
                                   content_type, site_pattern,
                                   (config.oracledb.lockoflock,
                                    config.oracledb.locks))
Exemple #2
0
    def add_source(self, name, config, auth_config):
        rest_config = Configuration()
        rest_config.url_base = config.url
        rest_config.accept = config.get('data_type', 'application/json')
        if config.auth == 'noauth':
            rest_config.auth_handler = 'None'
        else:
            auth = auth_config[config.auth]
            rest_config.auth_handler = auth.auth_handler
            rest_config.auth_handler_conf = Configuration(
                auth.get('auth_handler_conf', {}))

        content_type = getattr(WebReplicaLock, config.content_type)
        site_pattern = config.get('sites', None)
        lock_url = config.get('lock_url', None)

        self._sources[name] = (webservice.RESTService(rest_config),
                               content_type, site_pattern, lock_url)