From 70a74337a611c008afb02cc03c8b8512d7fa6c9e Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Wed, 3 May 2017 22:11:04 +0000 Subject: [PATCH] Specify alternate_id in network quota In network quota object, tenant_id is a unique key of the resource. alternate_id must be specified in the resource definition. Change-Id: Ia77a3711a08ee684fafcc76a8e1bb7d7f32ff1c1 Closes-Bug: #1687202 --- openstack/network/v2/quota.py | 2 +- openstack/tests/functional/network/v2/test_quota.py | 3 --- openstack/tests/unit/network/v2/test_quota.py | 8 ++++++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/openstack/network/v2/quota.py b/openstack/network/v2/quota.py index a77f5aac..c37e712a 100644 --- a/openstack/network/v2/quota.py +++ b/openstack/network/v2/quota.py @@ -44,7 +44,7 @@ class Quota(resource.Resource): #: The maximum amount of ports you can create. *Type: int* ports = resource.Body('port', type=int) #: The ID of the project these quota values are for. - project_id = resource.Body('tenant_id') + project_id = resource.Body('tenant_id', alternate_id=True) #: The maximum amount of RBAC policies you can create. *Type: int* rbac_policies = resource.Body('rbac_policy', type=int) #: The maximum amount of routers you can create. *Type: int* diff --git a/openstack/tests/functional/network/v2/test_quota.py b/openstack/tests/functional/network/v2/test_quota.py index 14be76dd..9fa10045 100644 --- a/openstack/tests/functional/network/v2/test_quota.py +++ b/openstack/tests/functional/network/v2/test_quota.py @@ -10,8 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import unittest - from openstack.tests.functional import base @@ -22,7 +20,6 @@ class TestQuota(base.BaseFunctionalTest): self.assertIsNotNone(qot.project_id) self.assertIsNotNone(qot.networks) - @unittest.skip('bug/1687202') def test_set(self): attrs = {'networks': 123456789} for project_quota in self.conn.network.quotas(): diff --git a/openstack/tests/unit/network/v2/test_quota.py b/openstack/tests/unit/network/v2/test_quota.py index 26b18ca4..20f55eff 100644 --- a/openstack/tests/unit/network/v2/test_quota.py +++ b/openstack/tests/unit/network/v2/test_quota.py @@ -13,6 +13,7 @@ import testtools from openstack.network.v2 import quota +from openstack import resource2 as resource IDENTIFIER = 'IDENTIFIER' EXAMPLE = { @@ -73,6 +74,13 @@ class TestQuota(testtools.TestCase): response = quota_obj._prepare_request() self.assertNotIn('id', response) + def test_alternate_id(self): + my_tenant_id = 'my-tenant-id' + body = {'tenant_id': my_tenant_id, 'network': 12345} + quota_obj = quota.Quota(**body) + self.assertEqual(my_tenant_id, + resource.Resource._get_id(quota_obj)) + class TestQuotaDefault(testtools.TestCase):