Browse Source

Support REDIRECT_PREFIX for openstack client

Story: 2003700

Change-Id: I28cfe60eea46df3f416106f708269a70e97ee69a
changes/14/605914/6
sapd 3 years ago
parent
commit
8bf98eda7b
6 changed files with 34 additions and 2 deletions
  1. +1
    -0
      octaviaclient/osc/v2/constants.py
  2. +12
    -2
      octaviaclient/osc/v2/l7policy.py
  3. +1
    -0
      octaviaclient/osc/v2/utils.py
  4. +3
    -0
      octaviaclient/osc/v2/validate.py
  5. +13
    -0
      octaviaclient/tests/unit/osc/v2/test_validations.py
  6. +4
    -0
      releasenotes/notes/add-redirect-prefix-2f66455b3eacf5b6.yaml

+ 1
- 0
octaviaclient/osc/v2/constants.py View File

@ -147,6 +147,7 @@ L7POLICY_ROWS = (
'updated_at',
'redirect_pool_id',
'redirect_url',
'redirect_prefix',
'action',
'position',
'id',


+ 12
- 2
octaviaclient/osc/v2/l7policy.py View File

@ -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>',


+ 1
- 0
octaviaclient/osc/v2/utils.py View File

@ -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',


+ 3
- 0
octaviaclient/osc/v2/validate.py View File

@ -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)


+ 13
- 0
octaviaclient/tests/unit/osc/v2/test_validations.py View File

@ -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 = {


+ 4
- 0
releasenotes/notes/add-redirect-prefix-2f66455b3eacf5b6.yaml View File

@ -0,0 +1,4 @@
---
features:
- Add REDIRECT_PREFIX action for L7 Policy in l7policy create,
and set command

Loading…
Cancel
Save