Allow case-insensitive entries when selecting from choices
Change-Id: Iececc977d9e23f9b5175e69892f02d9f4fd938ec
This commit is contained in:
parent
c7100d548f
commit
c606a1da72
|
@ -24,6 +24,7 @@ from octaviaclient.osc.v2 import utils as v2_utils
|
|||
|
||||
HTTP_METHODS = ['GET', 'POST', 'DELETE', 'PUT', 'HEAD', 'OPTIONS', 'PATCH',
|
||||
'CONNECT', 'TRACE']
|
||||
TYPE_CHOICES = ['PING', 'HTTP', 'TCP', 'HTTPS', 'TLS-HELLO']
|
||||
|
||||
|
||||
class CreateHealthMonitor(command.ShowOne):
|
||||
|
@ -55,9 +56,10 @@ class CreateHealthMonitor(command.ShowOne):
|
|||
"the member to declare it healthy."
|
||||
)
|
||||
parser.add_argument(
|
||||
'--http_method',
|
||||
metavar="{GET,POST,DELETE,PUT,HEAD,OPTIONS,PATCH,CONNECT,TRACE}",
|
||||
'--http-method',
|
||||
metavar='{' + ','.join(HTTP_METHODS) + '}',
|
||||
choices=HTTP_METHODS,
|
||||
type=lambda s: s.upper(), # case insensitive
|
||||
help="Set the HTTP method that the health monitor uses for "
|
||||
"requests."
|
||||
)
|
||||
|
@ -86,10 +88,11 @@ class CreateHealthMonitor(command.ShowOne):
|
|||
)
|
||||
parser.add_argument(
|
||||
'--type',
|
||||
metavar="{PING,HTTP,TCP,HTTPS,TLS-HELLO}",
|
||||
metavar='{' + ','.join(TYPE_CHOICES) + '}',
|
||||
required=True,
|
||||
choices=['PING', 'HTTP', 'TCP', 'HTTPS', 'TLS-HELLO'],
|
||||
help="Set the type of health monitor."
|
||||
choices=TYPE_CHOICES,
|
||||
type=lambda s: s.upper(), # case insensitive
|
||||
help="Set the health monitor type."
|
||||
)
|
||||
parser.add_argument(
|
||||
'--max-retries-down',
|
||||
|
@ -234,9 +237,10 @@ class SetHealthMonitor(command.Command):
|
|||
"the member to declare it healthy."
|
||||
)
|
||||
parser.add_argument(
|
||||
'--http_method',
|
||||
metavar="{GET,POST,DELETE,PUT,HEAD,OPTIONS,PATCH,CONNECT,TRACE}",
|
||||
'--http-method',
|
||||
metavar='{' + ','.join(HTTP_METHODS) + '}',
|
||||
choices=HTTP_METHODS,
|
||||
type=lambda s: s.upper(), # case insensitive
|
||||
help="Set the HTTP method that the health monitor uses for "
|
||||
"requests."
|
||||
)
|
||||
|
|
|
@ -49,9 +49,10 @@ class CreateL7Policy(command.ShowOne):
|
|||
|
||||
parser.add_argument(
|
||||
'--action',
|
||||
metavar="{REDIRECT_TO_URL,REDIRECT_TO_POOL,REJECT}",
|
||||
metavar='{' + ','.join(ACTION_CHOICES) + '}',
|
||||
required=True,
|
||||
choices=ACTION_CHOICES,
|
||||
type=lambda s: s.upper(), # case insensitive
|
||||
help="Set the action of the policy."
|
||||
)
|
||||
|
||||
|
@ -202,8 +203,9 @@ class SetL7Policy(command.Command):
|
|||
)
|
||||
parser.add_argument(
|
||||
'--action',
|
||||
metavar="{REDIRECT_TO_URL,REDIRECT_TO_POOL,REJECT}",
|
||||
metavar='{' + ','.join(ACTION_CHOICES) + '}',
|
||||
choices=ACTION_CHOICES,
|
||||
type=lambda s: s.upper(), # case insensitive
|
||||
help="Set the action of the policy."
|
||||
)
|
||||
|
||||
|
|
|
@ -38,9 +38,10 @@ class CreateL7Rule(command.ShowOne):
|
|||
)
|
||||
parser.add_argument(
|
||||
'--compare-type',
|
||||
metavar="{REGEX,EQUAL_TO,CONTAINS,ENDS_WITH,STARTS_WITH}",
|
||||
metavar='{' + ','.join(COMPARE_TYPES) + '}',
|
||||
required=True,
|
||||
choices=COMPARE_TYPES,
|
||||
type=lambda s: s.upper(), # case insensitive
|
||||
help="Set the compare type for the l7rule."
|
||||
)
|
||||
parser.add_argument(
|
||||
|
@ -62,9 +63,10 @@ class CreateL7Rule(command.ShowOne):
|
|||
)
|
||||
parser.add_argument(
|
||||
'--type',
|
||||
metavar="{FILE_TYPE,PATH,COOKIE,HOST_NAME,HEADER}",
|
||||
metavar='{' + ','.join(TYPES) + '}',
|
||||
required=True,
|
||||
choices=TYPES,
|
||||
type=lambda s: s.upper(), # case insensitive
|
||||
help="Set the type for the l7rule."
|
||||
)
|
||||
admin_group = parser.add_mutually_exclusive_group()
|
||||
|
@ -205,8 +207,9 @@ class SetL7Rule(command.Command):
|
|||
)
|
||||
parser.add_argument(
|
||||
'--compare-type',
|
||||
metavar="{REGEX,EQUAL_TO,CONTAINS,ENDS_WITH,STARTS_WITH}",
|
||||
metavar='{' + ','.join(COMPARE_TYPES) + '}',
|
||||
choices=COMPARE_TYPES,
|
||||
type=lambda s: s.upper(), # case insensitive
|
||||
help="Set the compare type for the l7rule."
|
||||
)
|
||||
parser.add_argument(
|
||||
|
@ -227,8 +230,9 @@ class SetL7Rule(command.Command):
|
|||
)
|
||||
parser.add_argument(
|
||||
'--type',
|
||||
metavar="{FILE_TYPE,PATH,COOKIE,HOST_NAME,HEADER}",
|
||||
metavar='{' + ','.join(TYPES) + '}',
|
||||
choices=TYPES,
|
||||
type=lambda s: s.upper(), # case insensitive
|
||||
help="Set the type for the l7rule."
|
||||
)
|
||||
admin_group = parser.add_mutually_exclusive_group()
|
||||
|
|
|
@ -22,6 +22,8 @@ from osc_lib import utils
|
|||
from octaviaclient.osc.v2 import constants as const
|
||||
from octaviaclient.osc.v2 import utils as v2_utils
|
||||
|
||||
PROTOCOL_CHOICES = ['TCP', 'HTTP', 'HTTPS', 'TERMINATED_HTTPS']
|
||||
|
||||
|
||||
class CreateListener(command.ShowOne):
|
||||
"""Create a listener"""
|
||||
|
@ -46,8 +48,9 @@ class CreateListener(command.ShowOne):
|
|||
)
|
||||
parser.add_argument(
|
||||
'--protocol',
|
||||
metavar='{TCP,HTTP,HTTPS,TERMINATED_HTTPS}',
|
||||
choices=['TCP', 'HTTP', 'HTTPS', 'TERMINATED_HTTPS'],
|
||||
metavar='{' + ','.join(PROTOCOL_CHOICES) + '}',
|
||||
choices=PROTOCOL_CHOICES,
|
||||
type=lambda s: s.upper(), # case insensitive
|
||||
required=True,
|
||||
help="The protocol for the listener."
|
||||
)
|
||||
|
|
|
@ -21,6 +21,9 @@ from osc_lib import utils
|
|||
from octaviaclient.osc.v2 import constants as const
|
||||
from octaviaclient.osc.v2 import utils as v2_utils
|
||||
|
||||
PROTOCOL_CHOICES = ['TCP', 'HTTP', 'HTTPS', 'TERMINATED_HTTPS', 'PROXY']
|
||||
ALGORITHM_CHOICES = ['SOURCE_IP', 'ROUND_ROBIN', 'LEAST_CONNECTIONS']
|
||||
|
||||
|
||||
class CreatePool(command.ShowOne):
|
||||
"""Create a pool"""
|
||||
|
@ -40,9 +43,10 @@ class CreatePool(command.ShowOne):
|
|||
)
|
||||
parser.add_argument(
|
||||
'--protocol',
|
||||
metavar="{TCP,HTTP,HTTPS,TERMINATED_HTTPS,PROXY}",
|
||||
metavar='{' + ','.join(PROTOCOL_CHOICES) + '}',
|
||||
required=True,
|
||||
choices=['TCP', 'HTTP', 'HTTPS', 'TERMINATED_HTTPS', 'PROXY'],
|
||||
choices=PROTOCOL_CHOICES,
|
||||
type=lambda s: s.upper(), # case insensitive
|
||||
help="Set the pool protocol."
|
||||
)
|
||||
parent_group = parser.add_mutually_exclusive_group(required=True)
|
||||
|
@ -63,9 +67,10 @@ class CreatePool(command.ShowOne):
|
|||
)
|
||||
parser.add_argument(
|
||||
'--lb-algorithm',
|
||||
metavar="{SOURCE_IP,ROUND_ROBIN,LEAST_CONNECTIONS}",
|
||||
metavar='{' + ','.join(ALGORITHM_CHOICES) + '}',
|
||||
required=True,
|
||||
choices=['SOURCE_IP', 'ROUND_ROBIN', 'LEAST_CONNECTIONS'],
|
||||
choices=ALGORITHM_CHOICES,
|
||||
type=lambda s: s.upper(), # case insensitive
|
||||
help="Load balancing algorithm to use."
|
||||
)
|
||||
admin_group = parser.add_mutually_exclusive_group()
|
||||
|
@ -208,8 +213,9 @@ class SetPool(command.Command):
|
|||
)
|
||||
parser.add_argument(
|
||||
'--lb-algorithm',
|
||||
metavar="{SOURCE_IP,ROUND_ROBIN,LEAST_CONNECTIONS}",
|
||||
choices=['SOURCE_IP', 'ROUND_ROBIN', 'LEAST_CONNECTIONS'],
|
||||
metavar='{' + ','.join(ALGORITHM_CHOICES) + '}',
|
||||
choices=ALGORITHM_CHOICES,
|
||||
type=lambda s: s.upper(), # case insensitive
|
||||
help="Set the load balancing algorithm to use."
|
||||
)
|
||||
admin_group = parser.add_mutually_exclusive_group()
|
||||
|
|
|
@ -137,14 +137,16 @@ class TestHealthMonitorCreate(TestHealthMonitor):
|
|||
'--delay', str(self._hm.delay),
|
||||
'--timeout', str(self._hm.timeout),
|
||||
'--max-retries', str(self._hm.max_retries),
|
||||
'--type', self._hm.type]
|
||||
'--type', self._hm.type.lower(),
|
||||
'--http-method', self._hm.http_method.lower()]
|
||||
verifylist = [
|
||||
('pool', 'mock_pool_id'),
|
||||
('name', self._hm.name),
|
||||
('delay', str(self._hm.delay)),
|
||||
('timeout', str(self._hm.timeout)),
|
||||
('max_retries', self._hm.max_retries),
|
||||
('type', self._hm.type)
|
||||
('type', self._hm.type),
|
||||
('http_method', self._hm.http_method),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
|
|
@ -143,7 +143,7 @@ class TestL7PolicyCreate(TestL7Policy):
|
|||
}
|
||||
arglist = ['mock_li_id',
|
||||
'--name', self._l7po.name,
|
||||
'--action', 'REDIRECT_TO_POOL',
|
||||
'--action', 'REDIRECT_TO_POOL'.lower(),
|
||||
'--redirect-pool', self._l7po.redirect_pool_id]
|
||||
|
||||
verifylist = [
|
||||
|
|
|
@ -158,7 +158,7 @@ class TestL7RuleCreate(TestL7Policy):
|
|||
arglist = [self._l7po.id,
|
||||
'--compare-type', 'ENDS_WITH',
|
||||
'--value', '.example.com',
|
||||
'--type', 'HOST_NAME']
|
||||
'--type', 'HOST_NAME'.lower()]
|
||||
|
||||
verifylist = [
|
||||
('l7policy', self._l7po.id),
|
||||
|
|
|
@ -172,7 +172,7 @@ class TestListenerCreate(TestListener):
|
|||
mock_client.return_value = self.li_info['listeners'][0]
|
||||
arglist = ['mock_lb_id',
|
||||
'--name', self._li.name,
|
||||
'--protocol', 'TERMINATED_HTTPS',
|
||||
'--protocol', 'TERMINATED_HTTPS'.lower(),
|
||||
'--protocol-port', '443',
|
||||
'--sni-container-refs',
|
||||
self._li.sni_container_refs[0],
|
||||
|
|
Loading…
Reference in New Issue