Browse Source

Includes missing configuration options

Includes missing configuration options for notifiers
in generated config file.

Change-Id: I06e6d51bca3b180768bc8c71ff10c9f6e69c5e8b
Story: #2003793
Task: #26506
tags/1.16.0
Charana Nandasena 1 year ago
parent
commit
00cc2527e3

+ 10
- 0
monasca_notification/conf/__init__.py View File

@@ -29,6 +29,12 @@ from monasca_notification.conf import queues
29 29
 from monasca_notification.conf import retry
30 30
 from monasca_notification.conf import statsd
31 31
 from monasca_notification.conf import zookeeper
32
+from monasca_notification.plugins import email_notifier
33
+from monasca_notification.plugins import hipchat_notifier
34
+from monasca_notification.plugins import jira_notifier
35
+from monasca_notification.plugins import pagerduty_notifier
36
+from monasca_notification.plugins import slack_notifier
37
+from monasca_notification.plugins import webhook_notifier
32 38
 
33 39
 LOG = log.getLogger(__name__)
34 40
 CONF = cfg.CONF
@@ -63,6 +69,10 @@ def register_enabled_plugin_opts(conf=None):
63 69
 
64 70
 
65 71
 def list_opts():
72
+    PLUGIN_CONF_OPTS = [slack_notifier, jira_notifier,
73
+                        hipchat_notifier, email_notifier,
74
+                        webhook_notifier, pagerduty_notifier]
75
+    CONF_OPTS.extend(PLUGIN_CONF_OPTS)
66 76
     opts = collections.defaultdict(list)
67 77
     for m in CONF_OPTS:
68 78
         configs = copy.deepcopy(m.list_opts())

+ 22
- 16
monasca_notification/plugins/email_notifier.py View File

@@ -65,22 +65,6 @@ With dimensions
65 65
 {metric_dimensions}'''
66 66
 
67 67
 
68
-def register_opts(conf):
69
-    gr = cfg.OptGroup(name='%s_notifier' % EmailNotifier.type)
70
-    opts = [
71
-        cfg.StrOpt(name='from_addr'),
72
-        cfg.HostAddressOpt(name='server'),
73
-        cfg.PortOpt(name='port', default=25),
74
-        cfg.IntOpt(name='timeout', default=5, min=1),
75
-        cfg.StrOpt(name='user', default=None),
76
-        cfg.StrOpt(name='password', default=None, secret=True),
77
-        cfg.StrOpt(name='grafana_url', default=None)
78
-    ]
79
-
80
-    conf.register_group(gr)
81
-    conf.register_opts(opts, group=gr)
82
-
83
-
84 68
 class EmailNotifier(abstract_notifier.AbstractNotifier):
85 69
 
86 70
     type = 'email'
@@ -306,3 +290,25 @@ def _format_dimensions(notification):
306 290
     dimensions = u'[\n' + u',\n'.join(dim_set_strings) + u' \n]'
307 291
 
308 292
     return dimensions
293
+
294
+email_notifier_group = cfg.OptGroup(name='%s_notifier' % EmailNotifier.type)
295
+email_notifier_opts = [
296
+    cfg.StrOpt(name='from_addr'),
297
+    cfg.HostAddressOpt(name='server'),
298
+    cfg.PortOpt(name='port', default=25),
299
+    cfg.IntOpt(name='timeout', default=5, min=1),
300
+    cfg.StrOpt(name='user', default=None),
301
+    cfg.StrOpt(name='password', default=None, secret=True),
302
+    cfg.StrOpt(name='grafana_url', default=None)
303
+]
304
+
305
+
306
+def register_opts(conf):
307
+    conf.register_group(email_notifier_group)
308
+    conf.register_opts(email_notifier_opts, group=email_notifier_group)
309
+
310
+
311
+def list_opts():
312
+    return {
313
+        email_notifier_group: email_notifier_opts
314
+    }

+ 19
- 13
monasca_notification/plugins/hipchat_notifier.py View File

@@ -48,19 +48,6 @@ SEVERITY_COLORS = {"low": 'green',
48 48
                    'critical': 'red'}
49 49
 
50 50
 
51
-def register_opts(conf):
52
-    gr = cfg.OptGroup(name='%s_notifier' % HipChatNotifier.type)
53
-    opts = [
54
-        cfg.IntOpt(name='timeout', default=5, min=1),
55
-        cfg.BoolOpt(name='insecure', default=True),
56
-        cfg.StrOpt(name='ca_certs', default=None),
57
-        cfg.StrOpt(name='proxy', default=None)
58
-    ]
59
-
60
-    conf.register_group(gr)
61
-    conf.register_opts(opts, group=gr)
62
-
63
-
64 51
 class HipChatNotifier(abstract_notifier.AbstractNotifier):
65 52
 
66 53
     type = 'hipchat'
@@ -153,3 +140,22 @@ class HipChatNotifier(abstract_notifier.AbstractNotifier):
153 140
         except Exception:
154 141
             self._log.exception("Error trying to send to hipchat on URL {}".format(url))
155 142
             return False
143
+
144
+hipchat_notifier_group = cfg.OptGroup(name='%s_notifier' % HipChatNotifier.type)
145
+hipchat_notifier_opts = [
146
+    cfg.IntOpt(name='timeout', default=5, min=1),
147
+    cfg.BoolOpt(name='insecure', default=True),
148
+    cfg.StrOpt(name='ca_certs', default=None),
149
+    cfg.StrOpt(name='proxy', default=None)
150
+]
151
+
152
+
153
+def register_opts(conf):
154
+    conf.register_group(hipchat_notifier_group)
155
+    conf.register_opts(hipchat_notifier_opts, group=hipchat_notifier_group)
156
+
157
+
158
+def list_opts():
159
+    return {
160
+        hipchat_notifier_group: hipchat_notifier_opts
161
+    }

+ 20
- 14
monasca_notification/plugins/jira_notifier.py View File

@@ -58,20 +58,6 @@ from monasca_notification.plugins.abstract_notifier import AbstractNotifier
58 58
 CONF = cfg.CONF
59 59
 
60 60
 
61
-def register_opts(conf):
62
-    gr = cfg.OptGroup(name='%s_notifier' % JiraNotifier.type)
63
-    opts = [
64
-        cfg.IntOpt(name='timeout', default=5, min=1),
65
-        cfg.StrOpt(name='user', required=False),
66
-        cfg.StrOpt(name='password', required=False, secret=True),
67
-        cfg.StrOpt(name='custom_formatter', default=None),
68
-        cfg.StrOpt(name='proxy', default=None)
69
-    ]
70
-
71
-    conf.register_group(gr)
72
-    conf.register_opts(opts, group=gr)
73
-
74
-
75 61
 class JiraNotifier(AbstractNotifier):
76 62
 
77 63
     type = 'jira'
@@ -242,3 +228,23 @@ class JiraNotifier(AbstractNotifier):
242 228
         jira_comment_message = jira_fields.get("comments")
243 229
         if jira_comment_message:
244 230
             jira_obj.add_comment(issue, jira_comment_message)
231
+
232
+jira_notifier_group = cfg.OptGroup(name='%s_notifier' % JiraNotifier.type)
233
+jira_notifier_opts = [
234
+    cfg.IntOpt(name='timeout', default=5, min=1),
235
+    cfg.StrOpt(name='user', required=False),
236
+    cfg.StrOpt(name='password', required=False, secret=True),
237
+    cfg.StrOpt(name='custom_formatter', default=None),
238
+    cfg.StrOpt(name='proxy', default=None)
239
+]
240
+
241
+
242
+def register_opts(conf):
243
+    conf.register_group(jira_notifier_group)
244
+    conf.register_opts(jira_notifier_opts, group=jira_notifier_group)
245
+
246
+
247
+def list_opts():
248
+    return {
249
+        jira_notifier_group: jira_notifier_opts
250
+    }

+ 20
- 13
monasca_notification/plugins/pagerduty_notifier.py View File

@@ -27,19 +27,6 @@ CONF = cfg.CONF
27 27
 VALID_HTTP_CODES = [200, 201, 204]
28 28
 
29 29
 
30
-def register_opts(conf):
31
-    gr = cfg.OptGroup(name='%s_notifier' % PagerdutyNotifier.type)
32
-    opts = [
33
-        cfg.IntOpt(name='timeout', default=5, min=1),
34
-        cfg.StrOpt(name='url',
35
-                   default='https://events.pagerduty.com/'
36
-                           'generic/2010-04-15/create_event.json')
37
-    ]
38
-
39
-    conf.register_group(gr)
40
-    conf.register_opts(opts, group=gr)
41
-
42
-
43 30
 class PagerdutyNotifier(abstract_notifier.AbstractNotifier):
44 31
 
45 32
     type = 'pagerduty'
@@ -92,3 +79,23 @@ class PagerdutyNotifier(abstract_notifier.AbstractNotifier):
92 79
             self._log.exception("Exception on pagerduty request. key=<{}>"
93 80
                                 .format(notification.address))
94 81
             return False
82
+
83
+
84
+pagerduty_notifier_group = cfg.OptGroup(name='%s_notifier' % PagerdutyNotifier.type)
85
+pagerduty_notifier_opts = [
86
+    cfg.IntOpt(name='timeout', default=5, min=1),
87
+    cfg.StrOpt(name='url',
88
+               default='https://events.pagerduty.com/'
89
+                       'generic/2010-04-15/create_event.json')
90
+]
91
+
92
+
93
+def register_opts(conf):
94
+    conf.register_group(pagerduty_notifier_group)
95
+    conf.register_opts(pagerduty_notifier_opts, group=pagerduty_notifier_group)
96
+
97
+
98
+def list_opts():
99
+    return {
100
+        pagerduty_notifier_group: pagerduty_notifier_opts
101
+    }

+ 19
- 13
monasca_notification/plugins/slack_notifier.py View File

@@ -26,19 +26,6 @@ from monasca_notification.plugins import abstract_notifier
26 26
 CONF = cfg.CONF
27 27
 
28 28
 
29
-def register_opts(conf):
30
-    gr = cfg.OptGroup(name='%s_notifier' % SlackNotifier.type)
31
-    opts = [
32
-        cfg.IntOpt(name='timeout', default=5, min=1),
33
-        cfg.BoolOpt(name='insecure', default=True),
34
-        cfg.StrOpt(name='ca_certs', default=None),
35
-        cfg.StrOpt(name='proxy', default=None)
36
-    ]
37
-
38
-    conf.register_group(gr)
39
-    conf.register_opts(opts, group=gr)
40
-
41
-
42 29
 class SlackNotifier(abstract_notifier.AbstractNotifier):
43 30
     """This module is a notification plugin to integrate with Slack.
44 31
 
@@ -199,3 +186,22 @@ class SlackNotifier(abstract_notifier.AbstractNotifier):
199 186
             self._log.info('Failed to send message to {} as {}'
200 187
                            .format(url, data_format))
201 188
         return False
189
+
190
+slack_notifier_group = cfg.OptGroup(name='%s_notifier' % SlackNotifier.type)
191
+slack_notifier_opts = [
192
+    cfg.IntOpt(name='timeout', default=5, min=1),
193
+    cfg.BoolOpt(name='insecure', default=True),
194
+    cfg.StrOpt(name='ca_certs', default=None),
195
+    cfg.StrOpt(name='proxy', default=None)
196
+]
197
+
198
+
199
+def register_opts(conf):
200
+    conf.register_group(slack_notifier_group)
201
+    conf.register_opts(slack_notifier_opts, group=slack_notifier_group)
202
+
203
+
204
+def list_opts():
205
+    return {
206
+        slack_notifier_group: slack_notifier_opts
207
+    }

+ 16
- 10
monasca_notification/plugins/webhook_notifier.py View File

@@ -26,16 +26,6 @@ from monasca_notification.plugins import abstract_notifier
26 26
 CONF = cfg.CONF
27 27
 
28 28
 
29
-def register_opts(conf):
30
-    gr = cfg.OptGroup(name='%s_notifier' % WebhookNotifier.type)
31
-    opts = [
32
-        cfg.IntOpt(name='timeout', default=5, min=1)
33
-    ]
34
-
35
-    conf.register_group(gr)
36
-    conf.register_opts(opts, group=gr)
37
-
38
-
39 29
 class WebhookNotifier(abstract_notifier.AbstractNotifier):
40 30
 
41 31
     type = 'webhook'
@@ -100,3 +90,19 @@ class WebhookNotifier(abstract_notifier.AbstractNotifier):
100 90
         except Exception:
101 91
             self._log.exception("Error trying to post on URL {}".format(url))
102 92
             return False
93
+
94
+webhook_notifier_group = cfg.OptGroup(name='%s_notifier' % WebhookNotifier.type)
95
+webhook_notifier_opts = [
96
+    cfg.IntOpt(name='timeout', default=5, min=1)
97
+]
98
+
99
+
100
+def register_opts(conf):
101
+    conf.register_group(webhook_notifier_group)
102
+    conf.register_opts(webhook_notifier_opts, group=webhook_notifier_group)
103
+
104
+
105
+def list_opts():
106
+    return {
107
+        webhook_notifier_group: webhook_notifier_opts
108
+    }

Loading…
Cancel
Save