Includes missing configuration options
Includes missing configuration options for notifiers in generated config file. Change-Id: I06e6d51bca3b180768bc8c71ff10c9f6e69c5e8b Story: #2003793 Task: #26506
This commit is contained in:
parent
2bc16e7834
commit
00cc2527e3
@ -29,6 +29,12 @@ from monasca_notification.conf import queues
|
||||
from monasca_notification.conf import retry
|
||||
from monasca_notification.conf import statsd
|
||||
from monasca_notification.conf import zookeeper
|
||||
from monasca_notification.plugins import email_notifier
|
||||
from monasca_notification.plugins import hipchat_notifier
|
||||
from monasca_notification.plugins import jira_notifier
|
||||
from monasca_notification.plugins import pagerduty_notifier
|
||||
from monasca_notification.plugins import slack_notifier
|
||||
from monasca_notification.plugins import webhook_notifier
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
@ -63,6 +69,10 @@ def register_enabled_plugin_opts(conf=None):
|
||||
|
||||
|
||||
def list_opts():
|
||||
PLUGIN_CONF_OPTS = [slack_notifier, jira_notifier,
|
||||
hipchat_notifier, email_notifier,
|
||||
webhook_notifier, pagerduty_notifier]
|
||||
CONF_OPTS.extend(PLUGIN_CONF_OPTS)
|
||||
opts = collections.defaultdict(list)
|
||||
for m in CONF_OPTS:
|
||||
configs = copy.deepcopy(m.list_opts())
|
||||
|
@ -65,22 +65,6 @@ With dimensions
|
||||
{metric_dimensions}'''
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
gr = cfg.OptGroup(name='%s_notifier' % EmailNotifier.type)
|
||||
opts = [
|
||||
cfg.StrOpt(name='from_addr'),
|
||||
cfg.HostAddressOpt(name='server'),
|
||||
cfg.PortOpt(name='port', default=25),
|
||||
cfg.IntOpt(name='timeout', default=5, min=1),
|
||||
cfg.StrOpt(name='user', default=None),
|
||||
cfg.StrOpt(name='password', default=None, secret=True),
|
||||
cfg.StrOpt(name='grafana_url', default=None)
|
||||
]
|
||||
|
||||
conf.register_group(gr)
|
||||
conf.register_opts(opts, group=gr)
|
||||
|
||||
|
||||
class EmailNotifier(abstract_notifier.AbstractNotifier):
|
||||
|
||||
type = 'email'
|
||||
@ -306,3 +290,25 @@ def _format_dimensions(notification):
|
||||
dimensions = u'[\n' + u',\n'.join(dim_set_strings) + u' \n]'
|
||||
|
||||
return dimensions
|
||||
|
||||
email_notifier_group = cfg.OptGroup(name='%s_notifier' % EmailNotifier.type)
|
||||
email_notifier_opts = [
|
||||
cfg.StrOpt(name='from_addr'),
|
||||
cfg.HostAddressOpt(name='server'),
|
||||
cfg.PortOpt(name='port', default=25),
|
||||
cfg.IntOpt(name='timeout', default=5, min=1),
|
||||
cfg.StrOpt(name='user', default=None),
|
||||
cfg.StrOpt(name='password', default=None, secret=True),
|
||||
cfg.StrOpt(name='grafana_url', default=None)
|
||||
]
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_group(email_notifier_group)
|
||||
conf.register_opts(email_notifier_opts, group=email_notifier_group)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return {
|
||||
email_notifier_group: email_notifier_opts
|
||||
}
|
||||
|
@ -48,19 +48,6 @@ SEVERITY_COLORS = {"low": 'green',
|
||||
'critical': 'red'}
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
gr = cfg.OptGroup(name='%s_notifier' % HipChatNotifier.type)
|
||||
opts = [
|
||||
cfg.IntOpt(name='timeout', default=5, min=1),
|
||||
cfg.BoolOpt(name='insecure', default=True),
|
||||
cfg.StrOpt(name='ca_certs', default=None),
|
||||
cfg.StrOpt(name='proxy', default=None)
|
||||
]
|
||||
|
||||
conf.register_group(gr)
|
||||
conf.register_opts(opts, group=gr)
|
||||
|
||||
|
||||
class HipChatNotifier(abstract_notifier.AbstractNotifier):
|
||||
|
||||
type = 'hipchat'
|
||||
@ -153,3 +140,22 @@ class HipChatNotifier(abstract_notifier.AbstractNotifier):
|
||||
except Exception:
|
||||
self._log.exception("Error trying to send to hipchat on URL {}".format(url))
|
||||
return False
|
||||
|
||||
hipchat_notifier_group = cfg.OptGroup(name='%s_notifier' % HipChatNotifier.type)
|
||||
hipchat_notifier_opts = [
|
||||
cfg.IntOpt(name='timeout', default=5, min=1),
|
||||
cfg.BoolOpt(name='insecure', default=True),
|
||||
cfg.StrOpt(name='ca_certs', default=None),
|
||||
cfg.StrOpt(name='proxy', default=None)
|
||||
]
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_group(hipchat_notifier_group)
|
||||
conf.register_opts(hipchat_notifier_opts, group=hipchat_notifier_group)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return {
|
||||
hipchat_notifier_group: hipchat_notifier_opts
|
||||
}
|
||||
|
@ -58,20 +58,6 @@ from monasca_notification.plugins.abstract_notifier import AbstractNotifier
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
gr = cfg.OptGroup(name='%s_notifier' % JiraNotifier.type)
|
||||
opts = [
|
||||
cfg.IntOpt(name='timeout', default=5, min=1),
|
||||
cfg.StrOpt(name='user', required=False),
|
||||
cfg.StrOpt(name='password', required=False, secret=True),
|
||||
cfg.StrOpt(name='custom_formatter', default=None),
|
||||
cfg.StrOpt(name='proxy', default=None)
|
||||
]
|
||||
|
||||
conf.register_group(gr)
|
||||
conf.register_opts(opts, group=gr)
|
||||
|
||||
|
||||
class JiraNotifier(AbstractNotifier):
|
||||
|
||||
type = 'jira'
|
||||
@ -242,3 +228,23 @@ class JiraNotifier(AbstractNotifier):
|
||||
jira_comment_message = jira_fields.get("comments")
|
||||
if jira_comment_message:
|
||||
jira_obj.add_comment(issue, jira_comment_message)
|
||||
|
||||
jira_notifier_group = cfg.OptGroup(name='%s_notifier' % JiraNotifier.type)
|
||||
jira_notifier_opts = [
|
||||
cfg.IntOpt(name='timeout', default=5, min=1),
|
||||
cfg.StrOpt(name='user', required=False),
|
||||
cfg.StrOpt(name='password', required=False, secret=True),
|
||||
cfg.StrOpt(name='custom_formatter', default=None),
|
||||
cfg.StrOpt(name='proxy', default=None)
|
||||
]
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_group(jira_notifier_group)
|
||||
conf.register_opts(jira_notifier_opts, group=jira_notifier_group)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return {
|
||||
jira_notifier_group: jira_notifier_opts
|
||||
}
|
||||
|
@ -27,19 +27,6 @@ CONF = cfg.CONF
|
||||
VALID_HTTP_CODES = [200, 201, 204]
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
gr = cfg.OptGroup(name='%s_notifier' % PagerdutyNotifier.type)
|
||||
opts = [
|
||||
cfg.IntOpt(name='timeout', default=5, min=1),
|
||||
cfg.StrOpt(name='url',
|
||||
default='https://events.pagerduty.com/'
|
||||
'generic/2010-04-15/create_event.json')
|
||||
]
|
||||
|
||||
conf.register_group(gr)
|
||||
conf.register_opts(opts, group=gr)
|
||||
|
||||
|
||||
class PagerdutyNotifier(abstract_notifier.AbstractNotifier):
|
||||
|
||||
type = 'pagerduty'
|
||||
@ -92,3 +79,23 @@ class PagerdutyNotifier(abstract_notifier.AbstractNotifier):
|
||||
self._log.exception("Exception on pagerduty request. key=<{}>"
|
||||
.format(notification.address))
|
||||
return False
|
||||
|
||||
|
||||
pagerduty_notifier_group = cfg.OptGroup(name='%s_notifier' % PagerdutyNotifier.type)
|
||||
pagerduty_notifier_opts = [
|
||||
cfg.IntOpt(name='timeout', default=5, min=1),
|
||||
cfg.StrOpt(name='url',
|
||||
default='https://events.pagerduty.com/'
|
||||
'generic/2010-04-15/create_event.json')
|
||||
]
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_group(pagerduty_notifier_group)
|
||||
conf.register_opts(pagerduty_notifier_opts, group=pagerduty_notifier_group)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return {
|
||||
pagerduty_notifier_group: pagerduty_notifier_opts
|
||||
}
|
||||
|
@ -26,19 +26,6 @@ from monasca_notification.plugins import abstract_notifier
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
gr = cfg.OptGroup(name='%s_notifier' % SlackNotifier.type)
|
||||
opts = [
|
||||
cfg.IntOpt(name='timeout', default=5, min=1),
|
||||
cfg.BoolOpt(name='insecure', default=True),
|
||||
cfg.StrOpt(name='ca_certs', default=None),
|
||||
cfg.StrOpt(name='proxy', default=None)
|
||||
]
|
||||
|
||||
conf.register_group(gr)
|
||||
conf.register_opts(opts, group=gr)
|
||||
|
||||
|
||||
class SlackNotifier(abstract_notifier.AbstractNotifier):
|
||||
"""This module is a notification plugin to integrate with Slack.
|
||||
|
||||
@ -199,3 +186,22 @@ class SlackNotifier(abstract_notifier.AbstractNotifier):
|
||||
self._log.info('Failed to send message to {} as {}'
|
||||
.format(url, data_format))
|
||||
return False
|
||||
|
||||
slack_notifier_group = cfg.OptGroup(name='%s_notifier' % SlackNotifier.type)
|
||||
slack_notifier_opts = [
|
||||
cfg.IntOpt(name='timeout', default=5, min=1),
|
||||
cfg.BoolOpt(name='insecure', default=True),
|
||||
cfg.StrOpt(name='ca_certs', default=None),
|
||||
cfg.StrOpt(name='proxy', default=None)
|
||||
]
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_group(slack_notifier_group)
|
||||
conf.register_opts(slack_notifier_opts, group=slack_notifier_group)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return {
|
||||
slack_notifier_group: slack_notifier_opts
|
||||
}
|
||||
|
@ -26,16 +26,6 @@ from monasca_notification.plugins import abstract_notifier
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
gr = cfg.OptGroup(name='%s_notifier' % WebhookNotifier.type)
|
||||
opts = [
|
||||
cfg.IntOpt(name='timeout', default=5, min=1)
|
||||
]
|
||||
|
||||
conf.register_group(gr)
|
||||
conf.register_opts(opts, group=gr)
|
||||
|
||||
|
||||
class WebhookNotifier(abstract_notifier.AbstractNotifier):
|
||||
|
||||
type = 'webhook'
|
||||
@ -100,3 +90,19 @@ class WebhookNotifier(abstract_notifier.AbstractNotifier):
|
||||
except Exception:
|
||||
self._log.exception("Error trying to post on URL {}".format(url))
|
||||
return False
|
||||
|
||||
webhook_notifier_group = cfg.OptGroup(name='%s_notifier' % WebhookNotifier.type)
|
||||
webhook_notifier_opts = [
|
||||
cfg.IntOpt(name='timeout', default=5, min=1)
|
||||
]
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
conf.register_group(webhook_notifier_group)
|
||||
conf.register_opts(webhook_notifier_opts, group=webhook_notifier_group)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return {
|
||||
webhook_notifier_group: webhook_notifier_opts
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user