Merge "Use init to configure plugins"
This commit is contained in:
commit
880f6d455a
@ -115,9 +115,7 @@ def intermediary_processor(plugin_type, **kwargs):
|
||||
|
||||
# Extract data from plugin data source
|
||||
LOG.info("Extract data from plugin data source")
|
||||
data_extractor = plugin_class(kwargs['site_name'])
|
||||
plugin_conf = data_extractor.get_plugin_conf(**kwargs)
|
||||
data_extractor.set_config_opts(plugin_conf)
|
||||
data_extractor = plugin_class(kwargs['site_name'], **kwargs)
|
||||
data_extractor.extract_data()
|
||||
|
||||
# Apply any additional_config provided by user
|
||||
|
@ -23,40 +23,12 @@ LOG = logging.getLogger(__name__)
|
||||
class BaseDataSourcePlugin(metaclass=abc.ABCMeta):
|
||||
"""Provide basic hooks for data source plugins"""
|
||||
|
||||
def __init__(self, region):
|
||||
def __init__(self, region, **kwargs):
|
||||
self.source_type = None
|
||||
self.source_name = None
|
||||
self.region = region
|
||||
self.site_data = None
|
||||
|
||||
@abc.abstractmethod
|
||||
def set_config_opts(self, conf):
|
||||
"""Placeholder to set configuration options specific to each plugin.
|
||||
|
||||
:param dict conf: Configuration options as dict
|
||||
|
||||
Example: conf = { 'excel_spec': 'spec1.yaml',
|
||||
'excel_path': 'excel.xls' }
|
||||
|
||||
Each plugin will have their own config opts.
|
||||
"""
|
||||
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_plugin_conf(self, kwargs):
|
||||
"""Validate and returns the plugin config parameters.
|
||||
|
||||
If validation fails, Spyglass exits.
|
||||
|
||||
:param char kwargs: Spyglass CLI parameters.
|
||||
:returns plugin conf if successfully validated.
|
||||
|
||||
Each plugin implements their own validation mechanism.
|
||||
"""
|
||||
|
||||
return {}
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_racks(self, region):
|
||||
"""Return list of racks in the region
|
||||
|
@ -57,7 +57,7 @@ def _get_intermediary_data():
|
||||
|
||||
|
||||
@mock.patch('spyglass.parser.engine.ProcessDataSource', autospec=True)
|
||||
@mock.patch('spyglass_plugin_xls.excel.ExcelPlugin', autospec=True)
|
||||
@mock.patch('spyglass_plugin_xls.excel.ExcelPlugin', autospec=False)
|
||||
def test_intermediary_processor(mock_excel_plugin, mock_process_data_source):
|
||||
"""Tests that the intermediary processor produces expected results"""
|
||||
plugin_name = 'excel'
|
||||
|
Loading…
x
Reference in New Issue
Block a user