From 3c30088c1e0f59c56dc34ae58809d70e47d64560 Mon Sep 17 00:00:00 2001 From: Bill Dodd Date: Mon, 21 May 2018 13:02:57 -0500 Subject: [PATCH] Add min/max values to integer config options None of the existing ironic-python-agent integer config options included min or max values. Added appropriate min/max values for the integer config options. Two of the integer options are for ports (listen_port and advertise_port). These were changed to use the more appropriate oslo_config cfg.PortOpt instead of cfg.IntOpt. PortOpt has the proper min and max values built in. Change-Id: I98709a45d099aea62c9973beb6817591cb445a9c Story: 1731950 --- ironic_python_agent/config.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/ironic_python_agent/config.py b/ironic_python_agent/config.py index 03033aadf..02c4cbe7d 100644 --- a/ironic_python_agent/config.py +++ b/ironic_python_agent/config.py @@ -39,11 +39,11 @@ cli_opts = [ help='The IP address to listen on. ' 'Can be supplied as "ipa-listen-host" kernel parameter.'), - cfg.IntOpt('listen_port', - default=int(APARAMS.get('ipa-listen-port', 9999)), - deprecated_name='listen-port', - help='The port to listen on. ' - 'Can be supplied as "ipa-listen-port" kernel parameter.'), + cfg.PortOpt('listen_port', + default=int(APARAMS.get('ipa-listen-port', 9999)), + deprecated_name='listen-port', + help='The port to listen on. ' + 'Can be supplied as "ipa-listen-port" kernel parameter.'), cfg.StrOpt('advertise_host', default=APARAMS.get('ipa-advertise-host', None), @@ -53,15 +53,16 @@ cli_opts = [ 'Can be supplied as "ipa-advertise-host" ' 'kernel parameter.'), - cfg.IntOpt('advertise_port', - default=int(APARAMS.get('ipa-advertise-port', 9999)), - deprecated_name='advertise-port', - help='The port to tell Ironic to reply and send ' - 'commands to. ' - 'Can be supplied as "ipa-advertise-port" ' - 'kernel parameter.'), + cfg.PortOpt('advertise_port', + default=int(APARAMS.get('ipa-advertise-port', 9999)), + deprecated_name='advertise-port', + help='The port to tell Ironic to reply and send ' + 'commands to. ' + 'Can be supplied as "ipa-advertise-port" ' + 'kernel parameter.'), cfg.IntOpt('ip_lookup_attempts', + min=1, default=int(APARAMS.get('ipa-ip-lookup-attempts', 3)), deprecated_name='ip-lookup-attempts', help='The number of times to try and automatically ' @@ -70,6 +71,7 @@ cli_opts = [ 'kernel parameter.'), cfg.IntOpt('ip_lookup_sleep', + min=0, default=int(APARAMS.get('ipa-ip-lookup-timeout', 10)), deprecated_name='ip-lookup-sleep', help='The amount of time to sleep between attempts ' @@ -85,6 +87,7 @@ cli_opts = [ 'kernel parameter.'), cfg.IntOpt('lookup_timeout', + min=0, default=int(APARAMS.get('ipa-lookup-timeout', 300)), deprecated_name='lookup-timeout', help='The amount of time to retry the initial lookup ' @@ -94,6 +97,7 @@ cli_opts = [ 'kernel parameter.'), cfg.IntOpt('lookup_interval', + min=0, default=int(APARAMS.get('ipa-lookup-interval', 1)), deprecated_name='lookup-interval', help='The initial interval for retries on the initial ' @@ -142,6 +146,7 @@ cli_opts = [ 'kernel parameter.'), cfg.IntOpt('inspection_dhcp_wait_timeout', + min=0, default=APARAMS.get('ipa-inspection-dhcp-wait-timeout', inspector.DEFAULT_DHCP_WAIT_TIMEOUT), help='Maximum time (in seconds) to wait for the PXE NIC ' @@ -162,6 +167,7 @@ cli_opts = [ 'kernel parameter.'), cfg.IntOpt('hardware_initialization_delay', + min=0, default=APARAMS.get('ipa-hardware-initialization-delay', 0), help='How much time (in seconds) to wait for hardware to ' 'initialize before proceeding with any actions. ' @@ -169,6 +175,7 @@ cli_opts = [ 'kernel parameter.'), cfg.IntOpt('disk_wait_attempts', + min=0, default=APARAMS.get('ipa-disk-wait-attempts', 10), help='The number of times to try and check to see if ' 'at least one suitable disk has appeared in inventory ' @@ -177,6 +184,7 @@ cli_opts = [ 'kernel parameter.'), cfg.IntOpt('disk_wait_delay', + min=0, default=APARAMS.get('ipa-disk-wait-delay', 3), help='How much time (in seconds) to wait between attempts ' 'to check if at least one suitable disk has appeared '