Merge "Add API header config to JSON ingester"
This commit is contained in:
commit
b0163a8d9d
|
@ -160,7 +160,7 @@ def inspect_methods(client, api_prefix):
|
|||
|
||||
|
||||
# Note (thread-safety): blocking function
|
||||
def get_keystone_session(creds):
|
||||
def get_keystone_session(creds, headers=None):
|
||||
|
||||
auth_details = {}
|
||||
auth_details['auth_url'] = creds['auth_url']
|
||||
|
@ -174,6 +174,11 @@ def get_keystone_session(creds):
|
|||
'Default')
|
||||
loader = kaloading.get_plugin_loader('password')
|
||||
auth_plugin = loader.load_from_options(**auth_details)
|
||||
session = kaloading.session.Session().load_from_options(
|
||||
auth=auth_plugin)
|
||||
if headers is None:
|
||||
session = kaloading.session.Session().load_from_options(
|
||||
auth=auth_plugin)
|
||||
else:
|
||||
session = kaloading.session.Session().load_from_options(
|
||||
auth=auth_plugin, additional_headers=headers)
|
||||
|
||||
return session
|
||||
|
|
|
@ -51,7 +51,8 @@ class ExecApiManager(object):
|
|||
+ config.get('api_endpoint_path', '').lstrip('/'))
|
||||
self._exec_api_sessions[
|
||||
name] = datasource_utils.get_keystone_session(
|
||||
config['authentication']['config'])
|
||||
config['authentication']['config'],
|
||||
headers=config.get('api_default_headers', {}))
|
||||
|
||||
@lockutils.synchronized('congress_json_ingester_exec_api')
|
||||
def evaluate_and_execute_actions(self):
|
||||
|
|
|
@ -216,7 +216,8 @@ class JsonIngester(datasource_driver.PollingDataSourceDriver):
|
|||
def _initialize_session(self):
|
||||
if 'authentication' in self._config:
|
||||
self._session = datasource_utils.get_keystone_session(
|
||||
self._config['authentication']['config'])
|
||||
self._config['authentication']['config'],
|
||||
headers=self._config.get('api_default_headers', {}))
|
||||
|
||||
def _initialize_update_methods(self):
|
||||
for table_name in self._config['tables']:
|
||||
|
|
|
@ -4,6 +4,8 @@ allow_exec_api: true
|
|||
authentication: !ref keystone_admin_auth_config
|
||||
api_endpoint_host: !ref primary_host
|
||||
api_endpoint_path: compute/v2.1/
|
||||
api_default_headers:
|
||||
X-OpenStack-Nova-API-Version: "2.26"
|
||||
tables:
|
||||
flavors:
|
||||
poll:
|
||||
|
|
Loading…
Reference in New Issue