summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-02-12 23:14:40 +0000
committerGerrit Code Review <review@openstack.org>2019-02-12 23:14:40 +0000
commit93574c6bf1c3c9489d890df4c4bc4d1d93ac832f (patch)
tree20119429a1fc49e7d49324fd0dc172de35a43e19
parent7d43228214badcd2ae101e5455f6fffcc37d6f1a (diff)
parent00cc2527e3ebed70ab4c1b3573964b423baa2178 (diff)
Merge "Includes missing configuration options"
-rw-r--r--monasca_notification/conf/__init__.py10
-rw-r--r--monasca_notification/plugins/email_notifier.py38
-rw-r--r--monasca_notification/plugins/hipchat_notifier.py32
-rw-r--r--monasca_notification/plugins/jira_notifier.py34
-rw-r--r--monasca_notification/plugins/pagerduty_notifier.py33
-rw-r--r--monasca_notification/plugins/slack_notifier.py32
-rw-r--r--monasca_notification/plugins/webhook_notifier.py26
7 files changed, 126 insertions, 79 deletions
diff --git a/monasca_notification/conf/__init__.py b/monasca_notification/conf/__init__.py
index 8928743..6da575f 100644
--- a/monasca_notification/conf/__init__.py
+++ b/monasca_notification/conf/__init__.py
@@ -29,6 +29,12 @@ from monasca_notification.conf import queues
29from monasca_notification.conf import retry 29from monasca_notification.conf import retry
30from monasca_notification.conf import statsd 30from monasca_notification.conf import statsd
31from monasca_notification.conf import zookeeper 31from monasca_notification.conf import zookeeper
32from monasca_notification.plugins import email_notifier
33from monasca_notification.plugins import hipchat_notifier
34from monasca_notification.plugins import jira_notifier
35from monasca_notification.plugins import pagerduty_notifier
36from monasca_notification.plugins import slack_notifier
37from monasca_notification.plugins import webhook_notifier
32 38
33LOG = log.getLogger(__name__) 39LOG = log.getLogger(__name__)
34CONF = cfg.CONF 40CONF = cfg.CONF
@@ -63,6 +69,10 @@ def register_enabled_plugin_opts(conf=None):
63 69
64 70
65def list_opts(): 71def 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 opts = collections.defaultdict(list) 76 opts = collections.defaultdict(list)
67 for m in CONF_OPTS: 77 for m in CONF_OPTS:
68 configs = copy.deepcopy(m.list_opts()) 78 configs = copy.deepcopy(m.list_opts())
diff --git a/monasca_notification/plugins/email_notifier.py b/monasca_notification/plugins/email_notifier.py
index acb499f..ff1d6dd 100644
--- a/monasca_notification/plugins/email_notifier.py
+++ b/monasca_notification/plugins/email_notifier.py
@@ -65,22 +65,6 @@ With dimensions
65{metric_dimensions}''' 65{metric_dimensions}'''
66 66
67 67
68def 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
84class EmailNotifier(abstract_notifier.AbstractNotifier): 68class EmailNotifier(abstract_notifier.AbstractNotifier):
85 69
86 type = 'email' 70 type = 'email'
@@ -306,3 +290,25 @@ def _format_dimensions(notification):
306 dimensions = u'[\n' + u',\n'.join(dim_set_strings) + u' \n]' 290 dimensions = u'[\n' + u',\n'.join(dim_set_strings) + u' \n]'
307 291
308 return dimensions 292 return dimensions
293
294email_notifier_group = cfg.OptGroup(name='%s_notifier' % EmailNotifier.type)
295email_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
306def register_opts(conf):
307 conf.register_group(email_notifier_group)
308 conf.register_opts(email_notifier_opts, group=email_notifier_group)
309
310
311def list_opts():
312 return {
313 email_notifier_group: email_notifier_opts
314 }
diff --git a/monasca_notification/plugins/hipchat_notifier.py b/monasca_notification/plugins/hipchat_notifier.py
index a901bfb..1acbd16 100644
--- a/monasca_notification/plugins/hipchat_notifier.py
+++ b/monasca_notification/plugins/hipchat_notifier.py
@@ -48,19 +48,6 @@ SEVERITY_COLORS = {"low": 'green',
48 'critical': 'red'} 48 'critical': 'red'}
49 49
50 50
51def 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
64class HipChatNotifier(abstract_notifier.AbstractNotifier): 51class HipChatNotifier(abstract_notifier.AbstractNotifier):
65 52
66 type = 'hipchat' 53 type = 'hipchat'
@@ -153,3 +140,22 @@ class HipChatNotifier(abstract_notifier.AbstractNotifier):
153 except Exception: 140 except Exception:
154 self._log.exception("Error trying to send to hipchat on URL {}".format(url)) 141 self._log.exception("Error trying to send to hipchat on URL {}".format(url))
155 return False 142 return False
143
144hipchat_notifier_group = cfg.OptGroup(name='%s_notifier' % HipChatNotifier.type)
145hipchat_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
153def register_opts(conf):
154 conf.register_group(hipchat_notifier_group)
155 conf.register_opts(hipchat_notifier_opts, group=hipchat_notifier_group)
156
157
158def list_opts():
159 return {
160 hipchat_notifier_group: hipchat_notifier_opts
161 }
diff --git a/monasca_notification/plugins/jira_notifier.py b/monasca_notification/plugins/jira_notifier.py
index bc927b1..1f2855c 100644
--- a/monasca_notification/plugins/jira_notifier.py
+++ b/monasca_notification/plugins/jira_notifier.py
@@ -58,20 +58,6 @@ from monasca_notification.plugins.abstract_notifier import AbstractNotifier
58CONF = cfg.CONF 58CONF = cfg.CONF
59 59
60 60
61def 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
75class JiraNotifier(AbstractNotifier): 61class JiraNotifier(AbstractNotifier):
76 62
77 type = 'jira' 63 type = 'jira'
@@ -242,3 +228,23 @@ class JiraNotifier(AbstractNotifier):
242 jira_comment_message = jira_fields.get("comments") 228 jira_comment_message = jira_fields.get("comments")
243 if jira_comment_message: 229 if jira_comment_message:
244 jira_obj.add_comment(issue, jira_comment_message) 230 jira_obj.add_comment(issue, jira_comment_message)
231
232jira_notifier_group = cfg.OptGroup(name='%s_notifier' % JiraNotifier.type)
233jira_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
242def register_opts(conf):
243 conf.register_group(jira_notifier_group)
244 conf.register_opts(jira_notifier_opts, group=jira_notifier_group)
245
246
247def list_opts():
248 return {
249 jira_notifier_group: jira_notifier_opts
250 }
diff --git a/monasca_notification/plugins/pagerduty_notifier.py b/monasca_notification/plugins/pagerduty_notifier.py
index 51fa738..3a5ee80 100644
--- a/monasca_notification/plugins/pagerduty_notifier.py
+++ b/monasca_notification/plugins/pagerduty_notifier.py
@@ -27,19 +27,6 @@ CONF = cfg.CONF
27VALID_HTTP_CODES = [200, 201, 204] 27VALID_HTTP_CODES = [200, 201, 204]
28 28
29 29
30def 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
43class PagerdutyNotifier(abstract_notifier.AbstractNotifier): 30class PagerdutyNotifier(abstract_notifier.AbstractNotifier):
44 31
45 type = 'pagerduty' 32 type = 'pagerduty'
@@ -92,3 +79,23 @@ class PagerdutyNotifier(abstract_notifier.AbstractNotifier):
92 self._log.exception("Exception on pagerduty request. key=<{}>" 79 self._log.exception("Exception on pagerduty request. key=<{}>"
93 .format(notification.address)) 80 .format(notification.address))
94 return False 81 return False
82
83
84pagerduty_notifier_group = cfg.OptGroup(name='%s_notifier' % PagerdutyNotifier.type)
85pagerduty_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
93def register_opts(conf):
94 conf.register_group(pagerduty_notifier_group)
95 conf.register_opts(pagerduty_notifier_opts, group=pagerduty_notifier_group)
96
97
98def list_opts():
99 return {
100 pagerduty_notifier_group: pagerduty_notifier_opts
101 }
diff --git a/monasca_notification/plugins/slack_notifier.py b/monasca_notification/plugins/slack_notifier.py
index 8173121..f972627 100644
--- a/monasca_notification/plugins/slack_notifier.py
+++ b/monasca_notification/plugins/slack_notifier.py
@@ -26,19 +26,6 @@ from monasca_notification.plugins import abstract_notifier
26CONF = cfg.CONF 26CONF = cfg.CONF
27 27
28 28
29def 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
42class SlackNotifier(abstract_notifier.AbstractNotifier): 29class SlackNotifier(abstract_notifier.AbstractNotifier):
43 """This module is a notification plugin to integrate with Slack. 30 """This module is a notification plugin to integrate with Slack.
44 31
@@ -199,3 +186,22 @@ class SlackNotifier(abstract_notifier.AbstractNotifier):
199 self._log.info('Failed to send message to {} as {}' 186 self._log.info('Failed to send message to {} as {}'
200 .format(url, data_format)) 187 .format(url, data_format))
201 return False 188 return False
189
190slack_notifier_group = cfg.OptGroup(name='%s_notifier' % SlackNotifier.type)
191slack_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
199def register_opts(conf):
200 conf.register_group(slack_notifier_group)
201 conf.register_opts(slack_notifier_opts, group=slack_notifier_group)
202
203
204def list_opts():
205 return {
206 slack_notifier_group: slack_notifier_opts
207 }
diff --git a/monasca_notification/plugins/webhook_notifier.py b/monasca_notification/plugins/webhook_notifier.py
index 7f22619..1c5551d 100644
--- a/monasca_notification/plugins/webhook_notifier.py
+++ b/monasca_notification/plugins/webhook_notifier.py
@@ -26,16 +26,6 @@ from monasca_notification.plugins import abstract_notifier
26CONF = cfg.CONF 26CONF = cfg.CONF
27 27
28 28
29def 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
39class WebhookNotifier(abstract_notifier.AbstractNotifier): 29class WebhookNotifier(abstract_notifier.AbstractNotifier):
40 30
41 type = 'webhook' 31 type = 'webhook'
@@ -100,3 +90,19 @@ class WebhookNotifier(abstract_notifier.AbstractNotifier):
100 except Exception: 90 except Exception:
101 self._log.exception("Error trying to post on URL {}".format(url)) 91 self._log.exception("Error trying to post on URL {}".format(url))
102 return False 92 return False
93
94webhook_notifier_group = cfg.OptGroup(name='%s_notifier' % WebhookNotifier.type)
95webhook_notifier_opts = [
96 cfg.IntOpt(name='timeout', default=5, min=1)
97]
98
99
100def register_opts(conf):
101 conf.register_group(webhook_notifier_group)
102 conf.register_opts(webhook_notifier_opts, group=webhook_notifier_group)
103
104
105def list_opts():
106 return {
107 webhook_notifier_group: webhook_notifier_opts
108 }