From 4d3727eafbc3a070c49f9e6d39e3668de3856349 Mon Sep 17 00:00:00 2001 From: "jeremy.zhang" Date: Tue, 28 Mar 2017 15:18:07 +0800 Subject: [PATCH] Use HostAddressOpt for opts that accept IP and hostnames Some configuration options were accepting both IP addresses and hostnames. Since there was no specific OSLO opt type to support this, we were using ``StrOpt``. The change [1] that added support for ``HostAddressOpt`` type was merged in Ocata and became available for use with oslo version 3.22. This patch changes the opt type of configuration options to use this more relevant opt type - HostAddressOpt. [1] I77bdb64b7e6e56ce761d76696bc4448a9bd325eb Change-Id: Idec43189ff8edc539027ba0b0369e54ae883cd2b --- watcher/conf/api.py | 7 ++++--- watcher/conf/service.py | 15 ++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/watcher/conf/api.py b/watcher/conf/api.py index ad8fa38c6..4531eca8e 100644 --- a/watcher/conf/api.py +++ b/watcher/conf/api.py @@ -32,9 +32,10 @@ API_SERVICE_OPTS = [ cfg.PortOpt('port', default=9322, help='The port for the watcher API server'), - cfg.StrOpt('host', - default='127.0.0.1', - help='The listen IP address for the watcher API server'), + cfg.HostAddressOpt('host', + default='127.0.0.1', + help='The listen IP address for the watcher API server' + ), cfg.IntOpt('max_limit', default=1000, help='The maximum number of items returned in a single ' diff --git a/watcher/conf/service.py b/watcher/conf/service.py index 56ff8d408..0f18d3a60 100644 --- a/watcher/conf/service.py +++ b/watcher/conf/service.py @@ -26,13 +26,14 @@ SERVICE_OPTS = [ cfg.IntOpt('periodic_interval', default=60, help=_('Seconds between running periodic tasks.')), - cfg.StrOpt('host', - default=socket.gethostname(), - help=_('Name of this node. This can be an opaque identifier. ' - 'It is not necessarily a hostname, FQDN, or IP address. ' - 'However, the node name must be valid within ' - 'an AMQP key, and if using ZeroMQ, a valid ' - 'hostname, FQDN, or IP address.')), + cfg.HostAddressOpt('host', + default=socket.gethostname(), + help=_('Name of this node. This can be an opaque ' + 'identifier. It is not necessarily a hostname, ' + 'FQDN, or IP address. However, the node name ' + 'must be valid within an AMQP key, and if using ' + 'ZeroMQ, a valid hostname, FQDN, or IP address.') + ), cfg.IntOpt('service_down_time', default=90, help=_('Maximum time since last check-in for up service.'))