From 8cb4de9e6535310c6a43fe28f035db9ccb72b383 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Mon, 9 Mar 2020 17:04:50 +0000 Subject: [PATCH] Use hostname to avoid clash with section Switch to using 'hostname' rather than 'host' to specify the Hostname, FQDN or IP address of this host. This is to avoid a clash with a section of the same name *1 *1 https://github.com/openstack/masakari-monitors/blob/master/masakarimonitors/conf/host.py#L87 Change-Id: I7d95b063c2eabbd8893857b5e1e7d342db0aebec Closes-Bug: #1866660 --- masakarimonitors/conf/service.py | 3 ++- masakarimonitors/manager.py | 2 +- masakarimonitors/service.py | 4 ++-- releasenotes/notes/bug-1866660-ef8624f5283b2e5e.yaml | 11 +++++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/bug-1866660-ef8624f5283b2e5e.yaml diff --git a/masakarimonitors/conf/service.py b/masakarimonitors/conf/service.py index 4c3eb19..e234bdd 100644 --- a/masakarimonitors/conf/service.py +++ b/masakarimonitors/conf/service.py @@ -17,8 +17,9 @@ import socket from oslo_config import cfg service_opts = [ - cfg.StrOpt('host', + cfg.StrOpt('hostname', default=socket.gethostname(), + deprecated_name="host", help=''' Hostname, FQDN or IP address of this host. Must be valid within AMQP key. diff --git a/masakarimonitors/manager.py b/masakarimonitors/manager.py index f05458e..0f4da72 100644 --- a/masakarimonitors/manager.py +++ b/masakarimonitors/manager.py @@ -55,7 +55,7 @@ class Manager(PeriodicTasks): def __init__(self, host=None, service_name='undefined'): if not host: - host = CONF.host + host = CONF.hostname self.host = host self.service_name = service_name super(Manager, self).__init__() diff --git a/masakarimonitors/service.py b/masakarimonitors/service.py index e6ef132..df588a3 100644 --- a/masakarimonitors/service.py +++ b/masakarimonitors/service.py @@ -69,13 +69,13 @@ class Service(service.Service): def create(cls, host=None, binary=None, manager=None): """Instantiates class and passes back application object. - :param host: defaults to CONF.host + :param host: defaults to CONF.hostname :param binary: defaults to basename of executable :param manager: defaults to CONF._manager """ if not host: - host = CONF.host + host = CONF.hostname if not binary: binary = os.path.basename(sys.argv[0]) diff --git a/releasenotes/notes/bug-1866660-ef8624f5283b2e5e.yaml b/releasenotes/notes/bug-1866660-ef8624f5283b2e5e.yaml new file mode 100644 index 0000000..a5f3128 --- /dev/null +++ b/releasenotes/notes/bug-1866660-ef8624f5283b2e5e.yaml @@ -0,0 +1,11 @@ +--- +features: + - | + A 'hostname' option has been added to the Masakari monitors configuration + file which replaces the 'host' option. The option should be used to specify + the Hostname, FQDN or IP address of the host. +deprecations: + - | + The 'host' option in the 'DEFAULT' section has been deprecated as it + clashes with the name of a section in the same file. It has been replaced + by the 'hostname' option.