Merge "Fix failure to load storage plugin"

This commit is contained in:
Jenkins 2017-08-10 12:41:52 +00:00 committed by Gerrit Code Review
commit eaa09a4cfc
4 changed files with 44 additions and 3 deletions

View File

@ -24,6 +24,7 @@ from watcher.conf import applier
from watcher.conf import ceilometer_client from watcher.conf import ceilometer_client
from watcher.conf import cinder_client from watcher.conf import cinder_client
from watcher.conf import clients_auth from watcher.conf import clients_auth
from watcher.conf import collector
from watcher.conf import db from watcher.conf import db
from watcher.conf import decision_engine from watcher.conf import decision_engine
from watcher.conf import exception from watcher.conf import exception
@ -58,3 +59,4 @@ ceilometer_client.register_opts(CONF)
neutron_client.register_opts(CONF) neutron_client.register_opts(CONF)
clients_auth.register_opts(CONF) clients_auth.register_opts(CONF)
ironic_client.register_opts(CONF) ironic_client.register_opts(CONF)
collector.register_opts(CONF)

37
watcher/conf/collector.py Normal file
View File

@ -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)]

View File

@ -17,6 +17,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from oslo_config import cfg
from watcher.common import utils from watcher.common import utils
from watcher.decision_engine.loading import default from watcher.decision_engine.loading import default
@ -31,8 +33,8 @@ class CollectorManager(object):
def get_collectors(self): def get_collectors(self):
if self._collectors is None: if self._collectors is None:
collectors = utils.Struct() collectors = utils.Struct()
available_collectors = self.collector_loader.list_available() collector_plugins = cfg.CONF.collector.collector_plugins
for collector_name in available_collectors: for collector_name in collector_plugins:
collector = self.collector_loader.load(collector_name) collector = self.collector_loader.load(collector_name)
collectors[collector_name] = collector collectors[collector_name] = collector
self._collectors = collectors self._collectors = collectors

View File

@ -32,7 +32,7 @@ class TestListOpts(base.TestCase):
'watcher_applier', 'watcher_planner', 'nova_client', 'watcher_applier', 'watcher_planner', 'nova_client',
'glance_client', 'gnocchi_client', 'cinder_client', 'glance_client', 'gnocchi_client', 'cinder_client',
'ceilometer_client', 'monasca_client', 'ironic_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()) self.opt_sections = list(dict(opts.list_opts()).keys())
def test_run_list_opts(self): def test_run_list_opts(self):