Email configuration.

This patch adds the configuration options that will allow us to
specify the smtp server which we are connecting to. These options are
drawn directly from smtplib, and will be used in subsequent patches
to generate a context-aware smtp sender.

Change-Id: I6fff2575d12e00f54b5733f990b1535649c8280d
This commit is contained in:
Michael Krotscheck 2015-02-01 12:48:20 -08:00 committed by Thierry Carrez
parent e984d5c5c1
commit 1e3b87448c
3 changed files with 138 additions and 1 deletions

View File

@ -150,4 +150,41 @@ lock_path = $state_path/lock
[plugin_token_cleaner]
# Enable/Disable the token cleaning cron plugin. This requires cron
# management to be enabled.
# enable = True
# enable = True
[plugin_email]
# Enable, or disable, the notification email plugin.
# enable = True
# The email address from which storyboard will send its messages.
# sender = StoryBoard (Do Not Reply) <do_not_reply@storyboard.openstack.org>
# The email address of the Reply-To header (optional).
# reply_to =
# The SMTP server to use.
# smtp_host = localhost
# The SMTP Server Port to connect to (default 25).
# smtp_port = 25
# The SMTP socket timeout, in seconds
# smtp_timeout = 10
# The FQDN of the sending host when identifying itself to the SMTP server
# (optional).
# smtp_local_hostname =
# Path to the SSL Keyfile, when using ESMTP. Please make sure the storyboard
# client can read this file.
# smtp_ssl_keyfile =
# Path to the SSL Certificate, when using ESMTP. Please make sure the
# storyboard client can read this file.
# smtp_ssl_certfile =
# Username/login for the SMTP server.
# smtp_user =
# Password for the SMTP server.
# smtp_password =

View File

@ -0,0 +1,64 @@
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing permissions and
# limitations under the License.
from oslo.config import cfg
from oslo_log import log
CONF = cfg.CONF
LOG = log.getLogger(__name__)
PLUGIN_OPTS = [
cfg.BoolOpt("enable",
default=False,
help="Enable, or disable, the notification email plugin."),
cfg.StrOpt("sender",
default='StoryBoard (Do Not Reply)'
'<do_not_reply@storyboard.openstack.org>',
help="The email address from which storyboard will send its "
"messages."),
cfg.StrOpt("reply_to",
default=None,
help="The email address of the Reply-To header (optional)."),
cfg.StrOpt("smtp_host",
default='localhost',
help="The SMTP server to use."),
cfg.IntOpt("smtp_port",
default=25,
help="The SMTP Server Port to connect to (default 25)."),
cfg.IntOpt("smtp_timeout",
default=10,
help="Timeout, in seconds, to wait for the SMTP connection to "
"fail"),
cfg.StrOpt("smtp_local_hostname",
default=None,
help="The FQDN of the sending host when identifying itself "
"to the SMTP server (optional)."),
cfg.StrOpt("smtp_ssl_keyfile",
default=None,
help="Path to the SSL Keyfile, when using ESMTP. Please make "
"sure the storyboard client can read this file."),
cfg.StrOpt("smtp_ssl_certfile",
default=None,
help="Path to the SSL Certificate, when using ESMTP "
"(optional). Please make sure the storyboard client can "
"read this file."),
cfg.StrOpt("smtp_user",
default=None,
help="Username/login for the SMTP server."),
cfg.StrOpt("smtp_password",
default=None,
help="Password for the SMTP server.")
]
CONF.register_opts(PLUGIN_OPTS, "plugin_email")

View File

@ -0,0 +1,36 @@
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing permissions and
# limitations under the License.
from oslo.config import cfg
from storyboard.tests import base
CONF = cfg.CONF
class TestConfiguration(base.TestCase):
def test_configuration_defaults(self):
self.assertIsNotNone(CONF.plugin_email)
conf = CONF.plugin_email
self.assertEqual('localhost', conf.smtp_host)
self.assertEqual(25, conf.smtp_port)
self.assertEqual(10, conf.smtp_timeout)
self.assertEqual(None, conf.smtp_local_hostname)
self.assertEqual(None, conf.smtp_ssl_keyfile)
self.assertEqual(None, conf.smtp_ssl_certfile)
self.assertEqual(None, conf.smtp_user)
self.assertEqual(None, conf.smtp_password)