Browse Source

Merge "Includes missing configuration options"

tags/1.16.0
Zuul 1 year ago
parent
commit
93574c6bf1
7 changed files with 126 additions and 79 deletions
  1. +10
    -0
      monasca_notification/conf/__init__.py
  2. +22
    -16
      monasca_notification/plugins/email_notifier.py
  3. +19
    -13
      monasca_notification/plugins/hipchat_notifier.py
  4. +20
    -14
      monasca_notification/plugins/jira_notifier.py
  5. +20
    -13
      monasca_notification/plugins/pagerduty_notifier.py
  6. +19
    -13
      monasca_notification/plugins/slack_notifier.py
  7. +16
    -10
      monasca_notification/plugins/webhook_notifier.py

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

@@ -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())

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

@@ -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
}

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

@@ -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
}

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

@@ -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
}

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

@@ -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
}

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

@@ -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
}

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

@@ -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…
Cancel
Save