Allow using file to override metric map
Override the metric map of each datasource as soon as it is created by the manager. This override comes from a file whose path is provided by a setting in config file. Loading at creation time allows the correct datasource be used when get_backend is called, this allows loading a datasource whose metric names get updated outside the watcher's codebase. The function 'load_metric_map' returns empty-dict in any error case. Also in case the file is empty where safe_load is unable finds any yaml documents, it will return None. [1] Some minor refactoring in the test_manager file for readability and added tests for file load and metric override. 1 - https://pyyaml.org/wiki/PyYAMLDocumentation Change-Id: I1df16245f4c7dfd34066f3ab0553cd67154faa58 Implements: blueprint file-based-metric-map
This commit is contained in:
@@ -55,8 +55,20 @@ WATCHER_DECISION_ENGINE_OPTS = [
|
||||
cfg.IntOpt('check_periodic_interval',
|
||||
default=30 * 60,
|
||||
mutable=True,
|
||||
help='Interval (in seconds) for checking action plan expiry.')
|
||||
]
|
||||
help='Interval (in seconds) for checking action plan expiry.'),
|
||||
cfg.StrOpt('metric_map_path',
|
||||
default='/etc/watcher/metric_map.yaml',
|
||||
help='Path to metric map yaml formatted file. '
|
||||
' '
|
||||
'The file contains a map per datasource whose keys '
|
||||
'are the metric names as recognized by watcher and the '
|
||||
'value is the real name of the metric in the datasource. '
|
||||
'For example:: \n\n'
|
||||
' monasca:\n'
|
||||
' instance_cpu_usage: VM_CPU\n'
|
||||
' gnocchi:\n'
|
||||
' instance_cpu_usage: cpu_vm_util\n\n'
|
||||
'This file is optional.')]
|
||||
|
||||
WATCHER_CONTINUOUS_OPTS = [
|
||||
cfg.IntOpt('continuous_audit_interval',
|
||||
|
||||
Reference in New Issue
Block a user