From 47b807eeb85ab3648075a8d84444fc4edb2b95c3 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: Fri, 25 Jan 2019 09:52:46 +0100 Subject: [PATCH] Replace notification.conf with monasca-notification.conf notification.conf is the deprecated path for the configuration file. The new path is /etc/monasca/monasca-notification.conf . Note: devstack is still using the deprecated configuration file. This will be change in another changeset (against openstack/monasca-api). Change-Id: I9ef1d7149308893544ad4d6fef4f3281da676171 Story: 2004862 Task: 29103 --- monasca_notification/config.py | 24 ++++++++++++++++++- ...ard-config-file-path-f3da49d0d655377c.yaml | 7 ++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/use-standard-config-file-path-f3da49d0d655377c.yaml diff --git a/monasca_notification/config.py b/monasca_notification/config.py index 2654544..2d7d5df 100644 --- a/monasca_notification/config.py +++ b/monasca_notification/config.py @@ -12,7 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_config import cfg from oslo_log import log +import sys import yaml from monasca_notification import conf @@ -39,8 +41,9 @@ def parse_args(argv, no_yaml=False): CONF(args=argv, project='monasca', - prog='notification', + prog=sys.argv[1:], version=version.version_string, + default_config_files=_get_config_files(), description=''' monasca-notification is an engine responsible for transforming alarm transitions into proper notifications @@ -60,6 +63,25 @@ def parse_args(argv, no_yaml=False): _CONF_LOADED = True +def _get_config_files(): + """Get the possible configuration files accepted by oslo.config + + This also includes the deprecated ones + """ + # default files + conf_files = cfg.find_config_files(project='monasca', + prog='monasca-notification') + # deprecated config files (only used if standard config files are not there) + if len(conf_files) == 0: + old_conf_files = cfg.find_config_files(project='monasca', + prog='notification') + if len(old_conf_files) > 0: + LOG.warning('Found deprecated old location "{}" ' + 'of main configuration file'.format(old_conf_files)) + conf_files += old_conf_files + return conf_files + + def set_from_yaml(): if CONF.yaml_config: LOG.info('Detected usage of deprecated YAML configuration') diff --git a/releasenotes/notes/use-standard-config-file-path-f3da49d0d655377c.yaml b/releasenotes/notes/use-standard-config-file-path-f3da49d0d655377c.yaml new file mode 100644 index 0000000..ed92de8 --- /dev/null +++ b/releasenotes/notes/use-standard-config-file-path-f3da49d0d655377c.yaml @@ -0,0 +1,7 @@ +--- +deprecations: + - | + Configuration file path /etc/monasca/notification.conf is deprecated. + Use the standard path /etc/monasca/monasca-notification.conf or the + configuration dir (supported via oslo.config) + /etc/monasca/monasca-notification.conf.d/any_config_name.conf