From 674541e583fc344e495a7ad230d45c0c0d474c42 Mon Sep 17 00:00:00 2001 From: Yang JianFeng Date: Tue, 14 Aug 2018 07:06:07 +0000 Subject: [PATCH] Add l7policy and l7rule to octavia quota Story: 2003382 Task: 24457 Depends-On: https://review.opendev.org/#/c/590620/ Change-Id: I1e3e60d5d326ff37a1ba53abd767c893748c2774 --- octaviaclient/osc/v2/constants.py | 4 +++ octaviaclient/osc/v2/quota.py | 26 +++++++++++++++++- octaviaclient/osc/v2/utils.py | 2 ++ octaviaclient/tests/unit/osc/v2/constants.py | 2 ++ octaviaclient/tests/unit/osc/v2/test_quota.py | 27 ++++++++++++++----- ...l7rule-quota-support-73098a090b252901.yaml | 3 +++ 6 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/add-l7policy-and-l7rule-quota-support-73098a090b252901.yaml diff --git a/octaviaclient/osc/v2/constants.py b/octaviaclient/osc/v2/constants.py index cc32649..6aa2640 100644 --- a/octaviaclient/osc/v2/constants.py +++ b/octaviaclient/osc/v2/constants.py @@ -236,6 +236,8 @@ QUOTA_ROWS = ( 'pool', 'health_monitor', 'member', + 'l7policy', + 'l7rule', ) QUOTA_COLUMNS = ( @@ -245,6 +247,8 @@ QUOTA_COLUMNS = ( 'pool', 'health_monitor', 'member', + 'l7policy', + 'l7rule', ) AMPHORA_ROWS = ( diff --git a/octaviaclient/osc/v2/quota.py b/octaviaclient/osc/v2/quota.py index 3a4771c..004c8a9 100644 --- a/octaviaclient/osc/v2/quota.py +++ b/octaviaclient/osc/v2/quota.py @@ -101,7 +101,7 @@ class SetQuota(command.ShowOne): @staticmethod def _check_attrs(attrs): args = ['health_monitor', 'listener', 'load_balancer', 'member', - 'pool'] + 'pool', 'l7policy', 'l7rule'] if not any(arg in attrs for arg in args): args = [arg.replace('_', '') for arg in args] @@ -150,6 +150,20 @@ class SetQuota(command.ShowOne): 'unlimited.') ) + quota_group.add_argument( + '--l7policy', + metavar='', + help=('New value for the l7policy quota limit. Value -1 means ' + 'unlimited.') + ) + + quota_group.add_argument( + '--l7rule', + metavar='', + help=('New value for the l7rule quota limit. Value -1 means ' + 'unlimited.') + ) + parser.add_argument( 'project', metavar='', @@ -232,6 +246,16 @@ class UnsetQuota(command.Command): action='store_true', help="Reset the health monitor quota to the default." ) + parser.add_argument( + '--l7policy', + action='store_true', + help="Reset the l7policy quota to the default." + ) + parser.add_argument( + '--l7rule', + action='store_true', + help="Reset the l7rule quota to the default." + ) return parser def take_action(self, parsed_args): diff --git a/octaviaclient/osc/v2/utils.py b/octaviaclient/osc/v2/utils.py index a02b44c..56c8f01 100644 --- a/octaviaclient/osc/v2/utils.py +++ b/octaviaclient/osc/v2/utils.py @@ -440,6 +440,8 @@ def get_quota_attrs(client_manager, parsed_args): 'load_balancer': ('load_balancer', int), 'member': ('member', int), 'pool': ('pool', int), + 'l7policy': ('l7policy', int), + 'l7rule': ('l7rule', int), 'project': ( 'project_id', 'project', diff --git a/octaviaclient/tests/unit/osc/v2/constants.py b/octaviaclient/tests/unit/osc/v2/constants.py index c0bc6a2..cfd8852 100644 --- a/octaviaclient/tests/unit/osc/v2/constants.py +++ b/octaviaclient/tests/unit/osc/v2/constants.py @@ -165,6 +165,8 @@ QUOTA_ATTRS = { "load_balancer": 5, "member": 50, "pool": None, + "l7policy": 20, + "l7rule": 30, "project_id": uuidutils.generate_uuid(dashed=True), } diff --git a/octaviaclient/tests/unit/osc/v2/test_quota.py b/octaviaclient/tests/unit/osc/v2/test_quota.py index a5b6fb7..09a7378 100644 --- a/octaviaclient/tests/unit/osc/v2/test_quota.py +++ b/octaviaclient/tests/unit/osc/v2/test_quota.py @@ -90,7 +90,9 @@ class TestQuotaDefaultsShow(TestQuota): "listener": 2, "load_balancer": 3, "member": 4, - "pool": 5 + "pool": 5, + "l7policy": 6, + "l7rule": 7 } def setUp(self): @@ -136,17 +138,22 @@ class TestQuotaSet(TestQuota): 'listener': '1', 'load_balancer': '2', 'member': '3', - 'pool': '4' + 'pool': '4', + 'l7policy': '5', + 'l7rule': '6', } arglist = [self._qt.project_id, '--healthmonitor', '-1', '--listener', - '1', '--loadbalancer', '2', '--member', '3', '--pool', '4'] + '1', '--loadbalancer', '2', '--member', '3', '--pool', '4', + '--l7policy', '5', '--l7rule', '6'] verifylist = [ ('project', self._qt.project_id), ('health_monitor', '-1'), ('listener', '1'), ('load_balancer', '2'), ('member', '3'), - ('pool', '4') + ('pool', '4'), + ('l7policy', '5'), + ('l7rule', '6') ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -156,7 +163,9 @@ class TestQuotaSet(TestQuota): 'listener': '1', 'load_balancer': '2', 'member': '3', - 'pool': '4'}}) + 'pool': '4', + 'l7policy': '5', + 'l7rule': '6'}}) @mock.patch('octaviaclient.osc.v2.utils.get_quota_attrs') def test_quota_set_no_args(self, mock_attrs): @@ -201,7 +210,7 @@ class TestQuotaReset(TestQuota): class TestQuotaUnset(TestQuota): PARAMETERS = ('loadbalancer', 'listener', 'pool', - 'member', 'healthmonitor') + 'member', 'healthmonitor', 'l7policy', 'l7rule') def setUp(self): super(TestQuotaUnset, self).setUp() @@ -222,6 +231,12 @@ class TestQuotaUnset(TestQuota): def test_quota_unset_member(self): self._test_quota_unset_param('member') + def test_quota_unset_l7policy(self): + self._test_quota_unset_param('l7policy') + + def test_quota_unset_l7rule(self): + self._test_quota_unset_param('l7rule') + @mock.patch('octaviaclient.osc.v2.utils.get_resource_id') def _test_quota_unset_param(self, param, mock_get_resource): self.api_mock.quota_set.reset_mock() diff --git a/releasenotes/notes/add-l7policy-and-l7rule-quota-support-73098a090b252901.yaml b/releasenotes/notes/add-l7policy-and-l7rule-quota-support-73098a090b252901.yaml new file mode 100644 index 0000000..0dcaebb --- /dev/null +++ b/releasenotes/notes/add-l7policy-and-l7rule-quota-support-73098a090b252901.yaml @@ -0,0 +1,3 @@ +--- +features: + - Add l7policy and l7rule's quota support to octaviaclient.