Use oslo_config new type PortOpt for port options

The oslo.config library provides new type PortOpt to validate the
range of port now.
Note: PorOpt allows port 0, which tells the OS to automatically
assign a port. We also assign port with 0 unit test.

Co-Authored-By: ChangBo Guo(gcb) <eric.guo@easystack.cn>
Change-Id: I90008e7b49ce753eb0fcc1a4cdef5f1b9a69641f
This commit is contained in:
ChangBo Guo(gcb) 2016-06-07 16:53:44 +08:00
parent e75956043b
commit f574b29554
6 changed files with 15 additions and 33 deletions

View File

@ -45,9 +45,7 @@ Possible Values:
--remote_debug-host <IP address where the debugger is running> --remote_debug-host <IP address where the debugger is running>
""") """)
port = cfg.IntOpt('port', port = cfg.PortOpt('port',
min=1,
max=65535,
help=""" help="""
Debug port to connect to. This command line parameter allows you to specify Debug port to connect to. This command line parameter allows you to specify
the port you want to use to connect to a nova service via a debugger running the port you want to use to connect to a nova service via a debugger running

View File

@ -149,10 +149,8 @@ Interdependencies to other options:
``base_url`` of this section or use ``0.0.0.0`` to listen on all addresses. ``base_url`` of this section or use ``0.0.0.0`` to listen on all addresses.
""") """)
serialproxy_port_opt = cfg.IntOpt('serialproxy_port', serialproxy_port_opt = cfg.PortOpt('serialproxy_port',
default=6083, default=6083,
min=1,
max=65535,
help=""" help="""
The port number which is used by the ``nova-serialproxy`` service to listen The port number which is used by the ``nova-serialproxy`` service to listen
for incoming requests. for incoming requests.

View File

@ -55,10 +55,8 @@ Host on which to listen for incoming requests
""") """)
html5proxy_port_opt = cfg.IntOpt('html5proxy_port', html5proxy_port_opt = cfg.PortOpt('html5proxy_port',
default=6082, default=6082,
min=1,
max=65535,
help=""" help="""
Port on which to listen for incoming requests Port on which to listen for incoming requests
""") """)

View File

@ -157,12 +157,9 @@ Related options:
* novncproxy_base_url * novncproxy_base_url
""") """)
# TODO(sfinucan): This should be a PortOpt novncproxy_port = cfg.PortOpt(
novncproxy_port = cfg.IntOpt(
'novncproxy_port', 'novncproxy_port',
default=6080, default=6080,
min=1,
max=65535,
deprecated_group='DEFAULT', deprecated_group='DEFAULT',
help=""" help="""
Port that the noVNC console proxy should bind to. Port that the noVNC console proxy should bind to.
@ -248,12 +245,9 @@ Related options:
* xvpvncproxy_base_url * xvpvncproxy_base_url
""") """)
# TODO(sfinucan): This should be a PortOpt xvpvncproxy_port = cfg.PortOpt(
xvpvncproxy_port = cfg.IntOpt(
'xvpvncproxy_port', 'xvpvncproxy_port',
default=6081, default=6081,
min=1,
max=65535,
deprecated_group='DEFAULT', deprecated_group='DEFAULT',
help=""" help="""
Port that the XVP VNC console proxy should bind to. Port that the XVP VNC console proxy should bind to.

View File

@ -157,16 +157,12 @@ xenapi_torrent_opts = [
default=86400, default=86400,
help='Cached torrent files not accessed within this number of' help='Cached torrent files not accessed within this number of'
' seconds can be reaped'), ' seconds can be reaped'),
cfg.IntOpt('torrent_listen_port_start', cfg.PortOpt('torrent_listen_port_start',
default=6881, default=6881,
min=1, help='Beginning of port range to listen on'),
max=65535, cfg.PortOpt('torrent_listen_port_end',
help='Beginning of port range to listen on'), default=6891,
cfg.IntOpt('torrent_listen_port_end', help='End of port range to listen on'),
default=6891,
min=1,
max=65535,
help='End of port range to listen on'),
cfg.IntOpt('torrent_download_stall_cutoff', cfg.IntOpt('torrent_download_stall_cutoff',
default=600, default=600,
help='Number of seconds a download can remain at the same' help='Number of seconds a download can remain at the same'

View File

@ -45,12 +45,10 @@ xvp_opts = [
default='/var/log/xvp.log', default='/var/log/xvp.log',
deprecated_group='DEFAULT', deprecated_group='DEFAULT',
help='XVP log file'), help='XVP log file'),
cfg.IntOpt('console_xvp_multiplex_port', cfg.PortOpt('console_xvp_multiplex_port',
default=5900, default=5900,
deprecated_group='DEFAULT', deprecated_group='DEFAULT',
min=1, help='Port for XVP to multiplex VNC connections on'),
max=65535,
help='Port for XVP to multiplex VNC connections on'),
] ]