Browse Source

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
tags/1.16.0
Thomas Bechtold 6 months ago
parent
commit
47b807eeb8

+ 23
- 1
monasca_notification/config.py View File

@@ -12,7 +12,9 @@
12 12
 # License for the specific language governing permissions and limitations
13 13
 # under the License.
14 14
 
15
+from oslo_config import cfg
15 16
 from oslo_log import log
17
+import sys
16 18
 import yaml
17 19
 
18 20
 from monasca_notification import conf
@@ -39,8 +41,9 @@ def parse_args(argv, no_yaml=False):
39 41
 
40 42
     CONF(args=argv,
41 43
          project='monasca',
42
-         prog='notification',
44
+         prog=sys.argv[1:],
43 45
          version=version.version_string,
46
+         default_config_files=_get_config_files(),
44 47
          description='''
45 48
          monasca-notification is an engine responsible for
46 49
          transforming alarm transitions into proper notifications
@@ -60,6 +63,25 @@ def parse_args(argv, no_yaml=False):
60 63
     _CONF_LOADED = True
61 64
 
62 65
 
66
+def _get_config_files():
67
+    """Get the possible configuration files accepted by oslo.config
68
+
69
+    This also includes the deprecated ones
70
+    """
71
+    # default files
72
+    conf_files = cfg.find_config_files(project='monasca',
73
+                                       prog='monasca-notification')
74
+    # deprecated config files (only used if standard config files are not there)
75
+    if len(conf_files) == 0:
76
+        old_conf_files = cfg.find_config_files(project='monasca',
77
+                                               prog='notification')
78
+        if len(old_conf_files) > 0:
79
+            LOG.warning('Found deprecated old location "{}" '
80
+                        'of main configuration file'.format(old_conf_files))
81
+            conf_files += old_conf_files
82
+    return conf_files
83
+
84
+
63 85
 def set_from_yaml():
64 86
     if CONF.yaml_config:
65 87
         LOG.info('Detected usage of deprecated YAML configuration')

+ 7
- 0
releasenotes/notes/use-standard-config-file-path-f3da49d0d655377c.yaml View File

@@ -0,0 +1,7 @@
1
+---
2
+deprecations:
3
+  - |
4
+    Configuration file path /etc/monasca/notification.conf is deprecated.
5
+    Use the standard path /etc/monasca/monasca-notification.conf or the
6
+    configuration dir (supported via oslo.config)
7
+    /etc/monasca/monasca-notification.conf.d/any_config_name.conf

Loading…
Cancel
Save