Fix Setting Quotas in Neutron
Currently Quota Set command doenst work in SDK version 0.9.12 as the request formed for the Neutron API is not correct. This patch attempts to fix the same. Change-Id: Id58b05bcdbfee73cb9b93dd5533b4c7d93dd03aa Partial-Bug:#1652317 Closes-Bug:#1655445
This commit is contained in:
@@ -58,6 +58,17 @@ class Quota(resource.Resource):
|
||||
#: The maximum amount of security groups you can create. *Type: int*
|
||||
security_groups = resource.Body('security_group', type=int)
|
||||
|
||||
def _prepare_request(self, requires_id=True, prepend_key=False):
|
||||
_request = super(Quota, self)._prepare_request(requires_id,
|
||||
prepend_key)
|
||||
if self.resource_key in _request.body:
|
||||
_body = _request.body[self.resource_key]
|
||||
else:
|
||||
_body = _request.body
|
||||
if 'id' in _body:
|
||||
del _body['id']
|
||||
return _request
|
||||
|
||||
|
||||
class QuotaDefault(Quota):
|
||||
base_path = '/quotas/%(project)s/default'
|
||||
|
||||
@@ -27,3 +27,10 @@ class TestQuota(base.BaseFunctionalTest):
|
||||
self.assertIn('security_group', qot)
|
||||
self.assertIn('subnetpool', qot)
|
||||
self.assertIn('rbac_policy', qot)
|
||||
|
||||
def test_set(self):
|
||||
attrs = {'network': 123456789}
|
||||
self.conn.network.update_quota(**attrs)
|
||||
quota_list = self.conn.network.get_quota()
|
||||
for quota in quota_list:
|
||||
self.assertIn('123456789', quota)
|
||||
|
||||
@@ -67,6 +67,12 @@ class TestQuota(testtools.TestCase):
|
||||
self.assertEqual(EXAMPLE['l7policy'], sot.l7_policies)
|
||||
self.assertEqual(EXAMPLE['pool'], sot.pools)
|
||||
|
||||
def test_prepare_request(self):
|
||||
body = {'id': 'ABCDEFGH', 'network': '12345'}
|
||||
quota_obj = quota.Quota(**body)
|
||||
response = quota_obj._prepare_request()
|
||||
self.assertNotIn('id', response)
|
||||
|
||||
|
||||
class TestQuotaDefault(testtools.TestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user