From 52525071aa708fc8f002ef9266307d30a76c9598 Mon Sep 17 00:00:00 2001 From: Eric Brown Date: Sat, 15 Aug 2015 10:06:38 -0700 Subject: [PATCH] Use min and max on IntOpt option types Latest version of oslo.config support the ability to set valid range on IntOpt option values. This path makes use of that feature for a number of options with well known minimum and maximum values. Change-Id: Ifec4afcc5673563e1e63fe131b9df753818f0f98 --- glance/common/config.py | 3 ++- glance/common/wsgi.py | 2 +- glance/registry/__init__.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/glance/common/config.py b/glance/common/config.py index ecd40a6e2a..a70e7389f2 100644 --- a/glance/common/config.py +++ b/glance/common/config.py @@ -131,6 +131,7 @@ common_opts = [ 'be a security risk, so use this setting with ' 'caution! The overrides show_image_direct_url.')), cfg.IntOpt('image_size_cap', default=1099511627776, + max=9223372036854775808, help=_("Maximum size of image a user can upload in bytes. " "Defaults to 1099511627776 bytes (1 TB)." "WARNING: this value should only be increased after " @@ -159,7 +160,7 @@ common_opts = [ cfg.StrOpt('pydev_worker_debug_host', help=_('The hostname/IP of the pydev process listening for ' 'debug connections')), - cfg.IntOpt('pydev_worker_debug_port', default=5678, + cfg.IntOpt('pydev_worker_debug_port', default=5678, min=1, max=65535, help=_('The port on which a pydev process is listening for ' 'connections.')), cfg.StrOpt('metadata_encryption_key', secret=True, diff --git a/glance/common/wsgi.py b/glance/common/wsgi.py index b71f765468..b42290c9f6 100644 --- a/glance/common/wsgi.py +++ b/glance/common/wsgi.py @@ -60,7 +60,7 @@ bind_opts = [ cfg.StrOpt('bind_host', default='0.0.0.0', help=_('Address to bind the server. Useful when ' 'selecting a particular network interface.')), - cfg.IntOpt('bind_port', + cfg.IntOpt('bind_port', min=1, max=65535, help=_('The port on which the server will listen.')), ] diff --git a/glance/registry/__init__.py b/glance/registry/__init__.py index 9322845299..ea1880138f 100644 --- a/glance/registry/__init__.py +++ b/glance/registry/__init__.py @@ -26,7 +26,7 @@ _ = i18n._ registry_addr_opts = [ cfg.StrOpt('registry_host', default='0.0.0.0', help=_('Address to find the registry server.')), - cfg.IntOpt('registry_port', default=9191, + cfg.IntOpt('registry_port', default=9191, min=1, max=65535, help=_('Port the registry server is listening on.')), ]