From 1d4eef59af67b8b83319d9280c88b91b3a935bc5 Mon Sep 17 00:00:00 2001 From: Kevin_Zheng Date: Thu, 5 May 2016 20:31:21 +0800 Subject: [PATCH] Use PortOpt and IpOpt Use PortOpt and IpOpt as other OpenStack project does, as PortOpt and IpOpt from oslo will perform checks to ensure those configuration options are in correct form. Change-Id: I914c930ce8427f6888ab120aeac6942a89f50824 --- tricircle/api/app.py | 8 ++++---- tricircle/cinder_apigw/app.py | 8 ++++---- tricircle/nova_apigw/app.py | 8 ++++---- tricircle/tests/base.py | 16 ++++++++++++---- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/tricircle/api/app.py b/tricircle/api/app.py index 941ae98..597b2a2 100644 --- a/tricircle/api/app.py +++ b/tricircle/api/app.py @@ -22,10 +22,10 @@ from tricircle.common import restapp common_opts = [ - cfg.StrOpt('bind_host', default='0.0.0.0', - help=_("The host IP to bind to")), - cfg.IntOpt('bind_port', default=19999, - help=_("The port to bind to")), + cfg.IPOpt('bind_host', default='0.0.0.0', + help=_("The host IP to bind to")), + cfg.PortOpt('bind_port', default=19999, + help=_("The port to bind to")), cfg.IntOpt('api_workers', default=1, help=_("number of api workers")), cfg.StrOpt('api_extensions_path', default="", diff --git a/tricircle/cinder_apigw/app.py b/tricircle/cinder_apigw/app.py index 2eaf00a..524ee1f 100644 --- a/tricircle/cinder_apigw/app.py +++ b/tricircle/cinder_apigw/app.py @@ -22,10 +22,10 @@ from tricircle.common import restapp common_opts = [ - cfg.StrOpt('bind_host', default='0.0.0.0', - help=_("The host IP to bind to")), - cfg.IntOpt('bind_port', default=19997, - help=_("The port to bind to")), + cfg.IPOpt('bind_host', default='0.0.0.0', + help=_("The host IP to bind to")), + cfg.PortOpt('bind_port', default=19997, + help=_("The port to bind to")), cfg.IntOpt('api_workers', default=1, help=_("number of api workers")), cfg.StrOpt('api_extensions_path', default="", diff --git a/tricircle/nova_apigw/app.py b/tricircle/nova_apigw/app.py index 489f313..9a16994 100644 --- a/tricircle/nova_apigw/app.py +++ b/tricircle/nova_apigw/app.py @@ -22,10 +22,10 @@ from tricircle.nova_apigw.controllers import root common_opts = [ - cfg.StrOpt('bind_host', default='0.0.0.0', - help=_("The host IP to bind to")), - cfg.IntOpt('bind_port', default=19998, - help=_("The port to bind to")), + cfg.IPOpt('bind_host', default='0.0.0.0', + help=_("The host IP to bind to")), + cfg.PortOpt('bind_port', default=19998, + help=_("The port to bind to")), cfg.IntOpt('api_workers', default=1, help=_("number of api workers")), cfg.StrOpt('api_extensions_path', default="", diff --git a/tricircle/tests/base.py b/tricircle/tests/base.py index f9d3bcd..3f692f8 100644 --- a/tricircle/tests/base.py +++ b/tricircle/tests/base.py @@ -18,13 +18,21 @@ from oslo_config import cfg from oslotest import base +CONFLICT_OPT_NAMES = [ + 'api_extensions_path', + 'bind_port', + 'bind_host' +] + + class TestCase(base.BaseTestCase): """Test case base class for all unit tests.""" def setUp(self): - # neutron has configuration options "api_extensions_path" and - # "bind_port" which conflicts with tricircle configuration option, - # so unregister this option before running tricircle tests + # neutron has configuration options "api_extensions_path", + # "bind_port" and "bind_host"which conflicts with tricircle + # configuration option, so unregister this option before + # running tricircle tests for opt in config.core_opts: - if opt.name == 'api_extensions_path' or opt.name == 'bind_port': + if opt.name in CONFLICT_OPT_NAMES: cfg.CONF.unregister_opt(opt) super(TestCase, self).setUp()