Merge "Support making unauthenticated APIs requests by JSON ingester"
This commit is contained in:
commit
b1da280cb0
|
@ -25,8 +25,10 @@ from oslo_config import cfg
|
|||
from oslo_log import log as logging
|
||||
import psycopg2
|
||||
from psycopg2 import sql
|
||||
import requests
|
||||
|
||||
from congress.datasources import datasource_utils
|
||||
from congress import exception
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -45,14 +47,28 @@ class ExecApiManager(object):
|
|||
for config in configs:
|
||||
# FIXME(json_ingester): validate config
|
||||
if config.get('allow_exec_api', False) is True:
|
||||
auth_config = config.get('authentication')
|
||||
if auth_config is None:
|
||||
session = requests.Session()
|
||||
session.headers.update(
|
||||
config.get('api_default_headers', {}))
|
||||
else:
|
||||
if auth_config['type'] == 'keystone':
|
||||
session = datasource_utils.get_keystone_session(
|
||||
config['authentication']['config'],
|
||||
headers=config.get('api_default_headers', {}))
|
||||
else:
|
||||
LOG.error('authentication type %s not supported.',
|
||||
auth_config.get['type'])
|
||||
raise exception.BadConfig(
|
||||
'authentication type {} not '
|
||||
'supported.'.auth_config['type'])
|
||||
|
||||
name = config['name']
|
||||
self._exec_api_endpoints[name] = (
|
||||
config.get('api_endpoint_host', '').rstrip('/') + '/'
|
||||
+ config.get('api_endpoint_path', '').lstrip('/'))
|
||||
self._exec_api_sessions[
|
||||
name] = datasource_utils.get_keystone_session(
|
||||
config['authentication']['config'],
|
||||
headers=config.get('api_default_headers', {}))
|
||||
self._exec_api_sessions[name] = session
|
||||
|
||||
@lockutils.synchronized('congress_json_ingester_exec_api')
|
||||
def evaluate_and_execute_actions(self):
|
||||
|
|
|
@ -26,6 +26,7 @@ from oslo_config import cfg
|
|||
from oslo_log import log as logging
|
||||
import psycopg2
|
||||
from psycopg2 import sql
|
||||
import requests
|
||||
|
||||
from congress.api import base as api_base
|
||||
from congress.datasources import datasource_driver
|
||||
|
@ -214,10 +215,21 @@ class JsonIngester(datasource_driver.PollingDataSourceDriver):
|
|||
self.update_methods[table_name] = method
|
||||
|
||||
def _initialize_session(self):
|
||||
if 'authentication' in self._config:
|
||||
self._session = datasource_utils.get_keystone_session(
|
||||
self._config['authentication']['config'],
|
||||
headers=self._config.get('api_default_headers', {}))
|
||||
auth_config = self._config.get('authentication')
|
||||
if auth_config is None:
|
||||
self._session = requests.Session()
|
||||
self._session.headers.update(
|
||||
self._config.get('api_default_headers', {}))
|
||||
else:
|
||||
if auth_config['type'] == 'keystone':
|
||||
self._session = datasource_utils.get_keystone_session(
|
||||
self._config['authentication']['config'],
|
||||
headers=self._config.get('api_default_headers', {}))
|
||||
else:
|
||||
LOG.error('authentication type %s not supported.',
|
||||
auth_config.get['type'])
|
||||
raise exception.BadConfig('authentication type {} not '
|
||||
'supported.'.auth_config['type'])
|
||||
|
||||
def _initialize_update_methods(self):
|
||||
for table_name in self._config['tables']:
|
||||
|
|
|
@ -115,7 +115,7 @@ PyYAML==3.10.0
|
|||
reno==2.5.0
|
||||
repoze.lru==0.7
|
||||
requests-mock==1.2.0
|
||||
requests==2.18.4
|
||||
requests==2.14.2
|
||||
requestsexceptions==1.4.0
|
||||
rfc3986==1.1.0
|
||||
Routes==2.3.1
|
||||
|
|
|
@ -29,6 +29,7 @@ jsonpath-rw<2.0,>=1.2.0 # Apache-2.0
|
|||
psycopg2>=2.7 # LGPL/ZPL
|
||||
python-dateutil>=2.5.3 # BSD
|
||||
python-glanceclient>=2.8.0 # Apache-2.0
|
||||
requests>=2.14.2,!=2.20.0 # Apache-2.0
|
||||
Routes>=2.3.1 # MIT
|
||||
six>=1.10.0 # MIT
|
||||
tenacity>=4.4.0 # Apache-2.0
|
||||
|
|
Loading…
Reference in New Issue