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>
""")
port = cfg.IntOpt('port',
min=1,
max=65535,
port = cfg.PortOpt('port',
help="""
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

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.
""")
serialproxy_port_opt = cfg.IntOpt('serialproxy_port',
serialproxy_port_opt = cfg.PortOpt('serialproxy_port',
default=6083,
min=1,
max=65535,
help="""
The port number which is used by the ``nova-serialproxy`` service to listen
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,
min=1,
max=65535,
help="""
Port on which to listen for incoming requests
""")

View File

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

View File

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

View File

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