Skip to content

Commit 7790669

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Support quota hard_limit values of zero"
2 parents 15fcd72 + e93fdc0 commit 7790669

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

magnum/api/controllers/v1/quota.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Quota(base.APIBase):
4242
id = wsme.wsattr(wtypes.IntegerType(minimum=1))
4343
"""unique id"""
4444

45-
hard_limit = wsme.wsattr(wtypes.IntegerType(minimum=1), default=1)
45+
hard_limit = wsme.wsattr(wtypes.IntegerType(minimum=0), default=1)
4646
"""The hard limit for total number of clusters. Default to 1 if not set"""
4747

4848
project_id = wsme.wsattr(wtypes.StringType(min_length=1, max_length=255),

magnum/tests/unit/api/controllers/v1/test_quota.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,17 @@ def test_create_quota(self, mock_keystone, mock_policy):
222222
self.assertEqual(201, response.status_int)
223223
self.assertEqual(quota_dict['project_id'], response.json['project_id'])
224224

225+
@mock.patch("magnum.common.policy.enforce")
226+
@mock.patch.object(clients.OpenStackClients, 'keystone')
227+
def test_create_zero_quota(self, mock_keystone, mock_policy):
228+
mock_policy.return_value = True
229+
quota_dict = apiutils.quota_post_data(hard_limit=0)
230+
response = self.post_json('/quotas', quota_dict)
231+
self.assertEqual('application/json', response.content_type)
232+
self.assertEqual(201, response.status_int)
233+
self.assertEqual(quota_dict['project_id'], response.json['project_id'])
234+
self.assertEqual(quota_dict['hard_limit'], response.json['hard_limit'])
235+
225236
@mock.patch.object(clients.OpenStackClients, 'keystone')
226237
def test_create_quota_project_id_not_found(self, mock_keystone):
227238
keystone = mock.MagicMock()

0 commit comments

Comments
 (0)