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:
Dantali0n
2019-03-21 15:17:44 +01:00
parent 92c94f61ca
commit bd8636f3f0
30 changed files with 234 additions and 126 deletions

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