From 2d1c4f8a85bbc0522f4f02142d8d54270f774187 Mon Sep 17 00:00:00 2001 From: ZhaoBo Date: Thu, 13 Dec 2018 21:37:01 +0800 Subject: [PATCH] Add a new option '--redirect-http-code' into L7Policy CLI This patch add a new option '--redirect-http-code' into L7Policy for redirection url and prefix action. Change-Id: I30b1a7555e1d910e07379bc69e739225a35a1a0c Story: 2003609 Depends-On: https://review.openstack.org/#/c/625007 --- octaviaclient/osc/v2/constants.py | 3 ++- octaviaclient/osc/v2/l7policy.py | 17 +++++++++++++++++ octaviaclient/osc/v2/utils.py | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/octaviaclient/osc/v2/constants.py b/octaviaclient/osc/v2/constants.py index 5de57ab..ff7e73e 100644 --- a/octaviaclient/osc/v2/constants.py +++ b/octaviaclient/osc/v2/constants.py @@ -159,7 +159,8 @@ L7POLICY_ROWS = ( 'position', 'id', 'operating_status', - 'name') + 'name', + 'redirect_http_code') L7POLICY_COLUMNS = ( 'id', diff --git a/octaviaclient/osc/v2/l7policy.py b/octaviaclient/osc/v2/l7policy.py index 702f279..d54fc23 100644 --- a/octaviaclient/osc/v2/l7policy.py +++ b/octaviaclient/osc/v2/l7policy.py @@ -24,6 +24,7 @@ from octaviaclient.osc.v2 import validate ACTION_CHOICES = ['REDIRECT_TO_URL', 'REDIRECT_TO_POOL', 'REDIRECT_PREFIX', 'REJECT'] +REDIRECT_CODE_CHOICES = [301, 302, 303, 307, 308] class CreateL7Policy(command.ShowOne): @@ -74,6 +75,14 @@ class CreateL7Policy(command.ShowOne): help="Set the URL Prefix to redirect requests to." ) + parser.add_argument( + '--redirect-http-code', + metavar='', + choices=REDIRECT_CODE_CHOICES, + type=int, + help="Set the HTTP response code for REDIRECT_URL or" + "REDIRECT_PREFIX action." + ) parser.add_argument( '--position', metavar='', @@ -231,6 +240,14 @@ class SetL7Policy(command.Command): metavar='', help="Set the URL Prefix to redirect requests to." ) + parser.add_argument( + '--redirect-http-code', + metavar='', + choices=REDIRECT_CODE_CHOICES, + type=int, + help="Set the HTTP response code for REDIRECT_URL or" + "REDIRECT_PREFIX action." + ) parser.add_argument( '--position', metavar='', diff --git a/octaviaclient/osc/v2/utils.py b/octaviaclient/osc/v2/utils.py index 456183b..4756298 100644 --- a/octaviaclient/osc/v2/utils.py +++ b/octaviaclient/osc/v2/utils.py @@ -316,6 +316,7 @@ def get_l7policy_attrs(client_manager, parsed_args): 'name': ('name', str), 'description': ('description', str), 'redirect_url': ('redirect_url', str), + 'redirect_http_code': ('redirect_http_code', int), 'redirect_prefix': ('redirect_prefix', str), 'l7policy': ( 'l7policy_id',