diff --git a/watcher/conf/__init__.py b/watcher/conf/__init__.py index 625401b54..01a5eed9a 100755 --- a/watcher/conf/__init__.py +++ b/watcher/conf/__init__.py @@ -24,6 +24,7 @@ from watcher.conf import applier from watcher.conf import ceilometer_client from watcher.conf import cinder_client from watcher.conf import clients_auth +from watcher.conf import collector from watcher.conf import db from watcher.conf import decision_engine from watcher.conf import exception @@ -58,3 +59,4 @@ ceilometer_client.register_opts(CONF) neutron_client.register_opts(CONF) clients_auth.register_opts(CONF) ironic_client.register_opts(CONF) +collector.register_opts(CONF) diff --git a/watcher/conf/collector.py b/watcher/conf/collector.py new file mode 100644 index 000000000..75cdc6b59 --- /dev/null +++ b/watcher/conf/collector.py @@ -0,0 +1,37 @@ +# Copyright (c) 2017 NEC Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from oslo_config import cfg + + +collector = cfg.OptGroup(name='collector', + title='Defines the parameters of ' + 'the module model collectors') + +COLLECTOR_OPTS = [ + cfg.ListOpt('collector_plugins', + default=['compute'], + help='The cluster data model plugin names'), +] + + +def register_opts(conf): + conf.register_group(collector) + conf.register_opts(COLLECTOR_OPTS, + group=collector) + + +def list_opts(): + return [('collector', COLLECTOR_OPTS)] diff --git a/watcher/decision_engine/model/collector/manager.py b/watcher/decision_engine/model/collector/manager.py index 1191036fd..1c7e924ad 100644 --- a/watcher/decision_engine/model/collector/manager.py +++ b/watcher/decision_engine/model/collector/manager.py @@ -17,6 +17,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from oslo_config import cfg + from watcher.common import utils from watcher.decision_engine.loading import default @@ -31,8 +33,8 @@ class CollectorManager(object): def get_collectors(self): if self._collectors is None: collectors = utils.Struct() - available_collectors = self.collector_loader.list_available() - for collector_name in available_collectors: + collector_plugins = cfg.CONF.collector.collector_plugins + for collector_name in collector_plugins: collector = self.collector_loader.load(collector_name) collectors[collector_name] = collector self._collectors = collectors diff --git a/watcher/tests/conf/test_list_opts.py b/watcher/tests/conf/test_list_opts.py index ef7f4f1a6..8ecf0208a 100755 --- a/watcher/tests/conf/test_list_opts.py +++ b/watcher/tests/conf/test_list_opts.py @@ -32,7 +32,7 @@ class TestListOpts(base.TestCase): 'watcher_applier', 'watcher_planner', 'nova_client', 'glance_client', 'gnocchi_client', 'cinder_client', 'ceilometer_client', 'monasca_client', 'ironic_client', - 'neutron_client', 'watcher_clients_auth'] + 'neutron_client', 'watcher_clients_auth', 'collector'] self.opt_sections = list(dict(opts.list_opts()).keys()) def test_run_list_opts(self):