Allow for global datasources preference from config
Allows to define a global preference for metric datasources with the ability for strategy specific overrides. In addition, strategies which do not require datasources have the config options removed this is done to prevent confusion. Some documentation that details the inner workings of selecting datasources is updated. Imports for some files in watcher/common have been changed to resolve circular dependencies and now match the overall method to import configuration. Addtional datasources will be retrieved by the manager if the datasource throws an error. Implements: blueprint global-datasource-preference Change-Id: I6fc455b288e338c20d2c4cfec5a0c95350bebc36
This commit is contained in:
@@ -25,6 +25,7 @@ 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 datasources
|
||||
from watcher.conf import db
|
||||
from watcher.conf import decision_engine
|
||||
from watcher.conf import exception
|
||||
@@ -44,6 +45,7 @@ service.register_opts(CONF)
|
||||
api.register_opts(CONF)
|
||||
paths.register_opts(CONF)
|
||||
exception.register_opts(CONF)
|
||||
datasources.register_opts(CONF)
|
||||
db.register_opts(CONF)
|
||||
planner.register_opts(CONF)
|
||||
applier.register_opts(CONF)
|
||||
|
||||
47
watcher/conf/datasources.py
Normal file
47
watcher/conf/datasources.py
Normal file
@@ -0,0 +1,47 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
# Copyright (c) 2019 European Organization for Nuclear Research (CERN)
|
||||
#
|
||||
# Authors: Corne Lukken <info@dantalion.nl>
|
||||
#
|
||||
# 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
|
||||
|
||||
from watcher.datasources import manager
|
||||
|
||||
datasources = cfg.OptGroup(name='watcher_datasources',
|
||||
title='Configuration Options for watcher'
|
||||
' datasources')
|
||||
|
||||
possible_datasources = list(manager.DataSourceManager.metric_map.keys())
|
||||
|
||||
DATASOURCES_OPTS = [
|
||||
cfg.ListOpt("datasources",
|
||||
help="Datasources to use in order to query the needed metrics."
|
||||
" If one of strategy metric is not available in the first"
|
||||
" datasource, the next datasource will be chosen. This is"
|
||||
" the default for all strategies unless a strategy has a"
|
||||
" specific override.",
|
||||
item_type=cfg.types.String(choices=possible_datasources),
|
||||
default=possible_datasources)
|
||||
]
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_group(datasources)
|
||||
conf.register_opts(DATASOURCES_OPTS, group=datasources)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return [('watcher_datasources', DATASOURCES_OPTS)]
|
||||
Reference in New Issue
Block a user