From 1227a53cfe7be9bbb8eb21c120329648c70fc70f Mon Sep 17 00:00:00 2001 From: lei-zhang-99cloud Date: Mon, 31 Aug 2015 14:39:12 +0800 Subject: [PATCH] Add port type on port option According to [1] oslo.config can use portType to support the ability to set valid range on port option values. [1]: http://docs.openstack.org/developer/oslo.config/cfg.html Change-Id: Ic06b982a9127cf47b10de787a78665cbb3b2399e --- sahara/config.py | 7 +++++-- sahara/tests/integration/configs/config.py | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sahara/config.py b/sahara/config.py index 6a938baa..336374be 100644 --- a/sahara/config.py +++ b/sahara/config.py @@ -16,6 +16,7 @@ import itertools from oslo_config import cfg +from oslo_config import types from oslo_log import log from sahara import exceptions as ex @@ -28,12 +29,14 @@ from sahara.utils.openstack import keystone from sahara.utils import remote from sahara import version +PORT_TYPE = types.Integer(1, 65535) + cli_opts = [ cfg.StrOpt('host', default='', help='Hostname or IP address that will be used to listen on.'), - cfg.IntOpt('port', default=8386, - help='Port that will be used to listen on.'), + cfg.Opt('port', default=8386, type=PORT_TYPE, + help='Port that will be used to listen on.'), cfg.BoolOpt('log-exchange', default=False, help='Log request/response exchange details: environ, ' 'headers and bodies.') diff --git a/sahara/tests/integration/configs/config.py b/sahara/tests/integration/configs/config.py index 10ceffeb..79acac11 100644 --- a/sahara/tests/integration/configs/config.py +++ b/sahara/tests/integration/configs/config.py @@ -20,6 +20,8 @@ import sys from oslo_config import cfg +from sahara import config + def singleton(cls): instances = {} @@ -53,6 +55,7 @@ COMMON_CONFIG_OPTS = [ default='127.0.0.1', help='Host for Sahara.'), cfg.IntOpt('SAHARA_PORT', + type=config.PORT_TYPE, default=8386, help='Port for Sahara.'), cfg.StrOpt('SAHARA_API_VERSION',