Add l7policy and l7rule to octavia quota

Story: 2003382
Task: 24457

Depends-On: https://review.opendev.org/#/c/590620/
Change-Id: I1e3e60d5d326ff37a1ba53abd767c893748c2774
This commit is contained in:
Yang JianFeng 2018-08-14 07:06:07 +00:00
parent 7408e1dc50
commit 674541e583
6 changed files with 57 additions and 7 deletions

View File

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

View File

@ -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='<l7policy>',
help=('New value for the l7policy quota limit. Value -1 means '
'unlimited.')
)
quota_group.add_argument(
'--l7rule',
metavar='<l7rule>',
help=('New value for the l7rule quota limit. Value -1 means '
'unlimited.')
)
parser.add_argument(
'project',
metavar='<project>',
@ -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):

View File

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

View File

@ -165,6 +165,8 @@ QUOTA_ATTRS = {
"load_balancer": 5,
"member": 50,
"pool": None,
"l7policy": 20,
"l7rule": 30,
"project_id": uuidutils.generate_uuid(dashed=True),
}

View File

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

View File

@ -0,0 +1,3 @@
---
features:
- Add l7policy and l7rule's quota support to octaviaclient.