From ec59ea8db7cc4aa6f4751a12483b179677369a7a Mon Sep 17 00:00:00 2001 From: Eric Brown Date: Thu, 13 Aug 2015 00:06:31 -0700 Subject: [PATCH] Use min and max on IntOpt option types The latest oslo.config supports a minimum and maximum value for IntOpt options. This patch utilizes this for a number of options with well known ranges. Change-Id: I897d8870fdf67a095915c8fcdf239024b092e9e3 --- nova/api/ec2/cloud.py | 2 ++ nova/cmd/novncproxy.py | 2 ++ nova/cmd/serialproxy.py | 2 ++ nova/cmd/spicehtml5proxy.py | 2 ++ nova/console/xvp.py | 2 ++ nova/debugger.py | 2 ++ nova/image/glance.py | 2 ++ nova/image/s3.py | 2 ++ nova/network/linux_net.py | 2 ++ nova/network/manager.py | 2 ++ nova/objectstore/s3server.py | 2 ++ nova/service.py | 6 ++++++ nova/virt/vmwareapi/driver.py | 4 ++++ nova/virt/xenapi/image/bittorrent.py | 4 ++++ nova/virt/xenapi/vm_utils.py | 2 ++ nova/vnc/xvp_proxy.py | 2 ++ 16 files changed, 40 insertions(+) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 362a45a7ceff..1047b6fe167d 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -63,6 +63,8 @@ ec2_opts = [ help='The internal IP address of the EC2 API server'), cfg.IntOpt('ec2_port', default=8773, + min=1, + max=65535, help='The port of the EC2 API server'), cfg.StrOpt('ec2_scheme', default='http', diff --git a/nova/cmd/novncproxy.py b/nova/cmd/novncproxy.py index c34479cb7222..acd56925faab 100644 --- a/nova/cmd/novncproxy.py +++ b/nova/cmd/novncproxy.py @@ -32,6 +32,8 @@ opts = [ help='Host on which to listen for incoming requests'), cfg.IntOpt('novncproxy_port', default=6080, + min=1, + max=65535, help='Port on which to listen for incoming requests'), ] diff --git a/nova/cmd/serialproxy.py b/nova/cmd/serialproxy.py index cc92915a66a9..86d5dd88f5bb 100644 --- a/nova/cmd/serialproxy.py +++ b/nova/cmd/serialproxy.py @@ -31,6 +31,8 @@ opts = [ help='Host on which to listen for incoming requests'), cfg.IntOpt('serialproxy_port', default=6083, + min=1, + max=65535, help='Port on which to listen for incoming requests'), ] diff --git a/nova/cmd/spicehtml5proxy.py b/nova/cmd/spicehtml5proxy.py index b0bd3971d70a..f6695dcf2870 100644 --- a/nova/cmd/spicehtml5proxy.py +++ b/nova/cmd/spicehtml5proxy.py @@ -32,6 +32,8 @@ opts = [ help='Host on which to listen for incoming requests'), cfg.IntOpt('html5proxy_port', default=6082, + min=1, + max=65535, help='Port on which to listen for incoming requests'), ] diff --git a/nova/console/xvp.py b/nova/console/xvp.py index f58cf8cf2246..46e9853781b1 100644 --- a/nova/console/xvp.py +++ b/nova/console/xvp.py @@ -46,6 +46,8 @@ xvp_opts = [ help='XVP log file'), cfg.IntOpt('console_xvp_multiplex_port', default=5900, + min=1, + max=65535, help='Port for XVP to multiplex VNC connections on'), ] diff --git a/nova/debugger.py b/nova/debugger.py index c5c15340735a..e4d42768f65c 100644 --- a/nova/debugger.py +++ b/nova/debugger.py @@ -38,6 +38,8 @@ def register_cli_opts(): 'under normal operation. Use at your own risk.'), cfg.IntOpt('port', + min=1, + max=65535, help='Debug port to connect. Note ' 'that using the remote debug option changes how ' 'Nova uses the eventlet library to support async IO. ' diff --git a/nova/image/glance.py b/nova/image/glance.py index 58c6c2763ada..887076f19378 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -47,6 +47,8 @@ glance_opts = [ help='Default glance hostname or IP address'), cfg.IntOpt('port', default=9292, + min=1, + max=65535, help='Default glance port'), cfg.StrOpt('protocol', default='http', diff --git a/nova/image/s3.py b/nova/image/s3.py index 6abe396e9f99..6cb4ccd8506b 100644 --- a/nova/image/s3.py +++ b/nova/image/s3.py @@ -51,6 +51,8 @@ s3_opts = [ 'the S3 api'), cfg.IntOpt('s3_port', default=3333, + min=1, + max=65535, help='Port used when accessing the S3 api'), cfg.StrOpt('s3_access_key', default='notchecked', diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index bfea55f4233f..1d55f8e97d7a 100644 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -108,6 +108,8 @@ linux_net_opts = [ help='The IP address for the metadata API server'), cfg.IntOpt('metadata_port', default=8775, + min=1, + max=65535, help='The port for the metadata API port'), cfg.StrOpt('iptables_top_regex', default='', diff --git a/nova/network/manager.py b/nova/network/manager.py index dc56ed7762c3..2f73dc800151 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -78,6 +78,8 @@ network_opts = [ help='FlatDhcp will bridge into this interface if set'), cfg.IntOpt('vlan_start', default=100, + min=1, + max=4094, help='First VLAN for private networks'), cfg.StrOpt('vlan_interface', help='VLANs will bridge into this interface if set'), diff --git a/nova/objectstore/s3server.py b/nova/objectstore/s3server.py index ee7ff3c63953..0b8d0642b7e9 100644 --- a/nova/objectstore/s3server.py +++ b/nova/objectstore/s3server.py @@ -64,6 +64,8 @@ s3_opts = [ help='IP address for S3 API to listen'), cfg.IntOpt('s3_listen_port', default=3333, + min=1, + max=65535, help='Port for S3 API to listen'), ] diff --git a/nova/service.py b/nova/service.py index 24c6a4e66225..a09187d23865 100644 --- a/nova/service.py +++ b/nova/service.py @@ -67,6 +67,8 @@ service_opts = [ help='The IP address on which the EC2 API will listen.'), cfg.IntOpt('ec2_listen_port', default=8773, + min=1, + max=65535, help='The port on which the EC2 API will listen.'), cfg.IntOpt('ec2_workers', help='Number of workers for EC2 API service. The default will ' @@ -76,6 +78,8 @@ service_opts = [ help='The IP address on which the OpenStack API will listen.'), cfg.IntOpt('osapi_compute_listen_port', default=8774, + min=1, + max=65535, help='The port on which the OpenStack API will listen.'), cfg.IntOpt('osapi_compute_workers', help='Number of workers for OpenStack API service. The default ' @@ -88,6 +92,8 @@ service_opts = [ help='The IP address on which the metadata API will listen.'), cfg.IntOpt('metadata_listen_port', default=8775, + min=1, + max=65535, help='The port on which the metadata API will listen.'), cfg.IntOpt('metadata_workers', help='Number of workers for metadata service. The default will ' diff --git a/nova/virt/vmwareapi/driver.py b/nova/virt/vmwareapi/driver.py index fd7616e7261e..f1754f8fb803 100644 --- a/nova/virt/vmwareapi/driver.py +++ b/nova/virt/vmwareapi/driver.py @@ -55,6 +55,8 @@ vmwareapi_opts = [ 'vCenter host.'), cfg.IntOpt('host_port', default=443, + min=1, + max=65535, help='Port for connection to VMware vCenter host.'), cfg.StrOpt('host_username', help='Username for connection to VMware vCenter host.'), @@ -83,6 +85,8 @@ vmwareapi_opts = [ 'socket error, etc.'), cfg.IntOpt('vnc_port', default=5900, + min=1, + max=65535, help='VNC starting port'), cfg.IntOpt('vnc_port_total', default=10000, diff --git a/nova/virt/xenapi/image/bittorrent.py b/nova/virt/xenapi/image/bittorrent.py index 5321a92aa3f2..aa7508313e98 100644 --- a/nova/virt/xenapi/image/bittorrent.py +++ b/nova/virt/xenapi/image/bittorrent.py @@ -40,9 +40,13 @@ xenapi_torrent_opts = [ ' seconds can be reaped'), cfg.IntOpt('torrent_listen_port_start', default=6881, + min=1, + max=65535, help='Beginning of port range to listen on'), cfg.IntOpt('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, diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 0a835e3ae0cb..4e7f63025375 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -70,6 +70,8 @@ xenapi_vm_utils_opts = [ ' image_property `cache_in_nova=True`, and `none` turns' ' off caching entirely'), cfg.IntOpt('image_compression_level', + min=1, + max=9, help='Compression level for images, e.g., 9 for gzip -9.' ' Range is 1-9, 9 being most compressed but most CPU' ' intensive on dom0.'), diff --git a/nova/vnc/xvp_proxy.py b/nova/vnc/xvp_proxy.py index 726c3bcab4db..2b7071cb9452 100644 --- a/nova/vnc/xvp_proxy.py +++ b/nova/vnc/xvp_proxy.py @@ -38,6 +38,8 @@ LOG = logging.getLogger(__name__) xvp_proxy_opts = [ cfg.IntOpt('xvpvncproxy_port', default=6081, + min=1, + max=65535, help='Port that the XCP VNC proxy should bind to'), cfg.StrOpt('xvpvncproxy_host', default='0.0.0.0',