Support REDIRECT_PREFIX for openstack client
Story: 2003700 Change-Id: I28cfe60eea46df3f416106f708269a70e97ee69a
This commit is contained in:
parent
300fd657d6
commit
8bf98eda7b
|
@ -147,6 +147,7 @@ L7POLICY_ROWS = (
|
|||
'updated_at',
|
||||
'redirect_pool_id',
|
||||
'redirect_url',
|
||||
'redirect_prefix',
|
||||
'action',
|
||||
'position',
|
||||
'id',
|
||||
|
|
|
@ -22,7 +22,8 @@ from octaviaclient.osc.v2 import constants as const
|
|||
from octaviaclient.osc.v2 import utils as v2_utils
|
||||
from octaviaclient.osc.v2 import validate
|
||||
|
||||
ACTION_CHOICES = ['REDIRECT_TO_URL', 'REDIRECT_TO_POOL', 'REJECT']
|
||||
ACTION_CHOICES = ['REDIRECT_TO_URL', 'REDIRECT_TO_POOL',
|
||||
'REDIRECT_PREFIX', 'REJECT']
|
||||
|
||||
|
||||
class CreateL7Policy(command.ShowOne):
|
||||
|
@ -67,6 +68,11 @@ class CreateL7Policy(command.ShowOne):
|
|||
metavar='<url>',
|
||||
help="Set the URL to redirect requests to."
|
||||
)
|
||||
redirect_group.add_argument(
|
||||
'--redirect-prefix',
|
||||
metavar='<url>',
|
||||
help="Set the URL Prefix to redirect requests to."
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--position',
|
||||
|
@ -220,7 +226,11 @@ class SetL7Policy(command.Command):
|
|||
metavar='<url>',
|
||||
help="Set the URL to redirect requests to."
|
||||
)
|
||||
|
||||
redirect_group.add_argument(
|
||||
'--redirect-prefix',
|
||||
metavar='<url>',
|
||||
help="Set the URL Prefix to redirect requests to."
|
||||
)
|
||||
parser.add_argument(
|
||||
'--position',
|
||||
metavar='<position>',
|
||||
|
|
|
@ -297,6 +297,7 @@ def get_l7policy_attrs(client_manager, parsed_args):
|
|||
'name': ('name', str),
|
||||
'description': ('description', str),
|
||||
'redirect_url': ('redirect_url', str),
|
||||
'redirect_prefix': ('redirect_prefix', str),
|
||||
'l7policy': (
|
||||
'l7policy_id',
|
||||
'l7policies',
|
||||
|
|
|
@ -24,6 +24,9 @@ def check_l7policy_attrs(attrs):
|
|||
elif attrs['action'] == 'REDIRECT_TO_URL':
|
||||
if 'redirect_url' not in attrs:
|
||||
msg = 'Missing argument: --redirect-url'
|
||||
elif attrs['action'] == 'REDIRECT_PREFIX':
|
||||
if 'redirect_prefix' not in attrs:
|
||||
msg = 'Missing argument: --redirect-prefix'
|
||||
if msg is not None:
|
||||
raise exceptions.CommandError(msg)
|
||||
|
||||
|
|
|
@ -48,6 +48,19 @@ class TestValidations(utils.TestCommand):
|
|||
exceptions.CommandError,
|
||||
validate.check_l7policy_attrs, attrs_dict)
|
||||
|
||||
attrs_dict = {
|
||||
"action": "redirect_prefix".upper(),
|
||||
"redirect_prefix": "prefix",
|
||||
}
|
||||
try:
|
||||
validate.check_l7policy_attrs(attrs_dict)
|
||||
except exceptions.CommandError as e:
|
||||
self.fail("%s raised unexpectedly" % e)
|
||||
attrs_dict.pop("redirect_prefix")
|
||||
self.assertRaises(
|
||||
exceptions.CommandError,
|
||||
validate.check_l7policy_attrs, attrs_dict)
|
||||
|
||||
def test_check_l7rule_attrs(self):
|
||||
for i in ("cookie", "header"):
|
||||
attrs_dict = {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
features:
|
||||
- Add REDIRECT_PREFIX action for L7 Policy in l7policy create,
|
||||
and set command
|
Loading…
Reference in New Issue