From: James Arendt Date: Wed, 26 Aug 2015 23:53:24 +0000 (-0700) Subject: Add tenant_id to flavor service profiles attributes X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=db4ea4517886741c2bd3e15e39bee0ecbd1356ae;p=openstack-build%2Fneutron-build.git Add tenant_id to flavor service profiles attributes Neutron v2 base.py auto populates a 'tenant_id' attribute on calls if the attribute is not passed. This causes a POST to create a flavor service binding to fail when verifying attributes with: Unrecognized attribute(s) 'tenant_id' Solution is to add tenant_id as expected attribute in the attribute map as done in other sub resources like QOS. Fix unit test for non-keystone case. Change-Id: Ic2bd1271f297fc10b49304ffd5fe617637e3d8f4 Closes-Bug: 1489197 --- diff --git a/neutron/extensions/flavors.py b/neutron/extensions/flavors.py index 8de5fd08f..22be68cdd 100644 --- a/neutron/extensions/flavors.py +++ b/neutron/extensions/flavors.py @@ -84,7 +84,12 @@ SUB_RESOURCE_ATTRIBUTE_MAP = { 'member_name': 'flavor'}, 'parameters': {'id': {'allow_post': True, 'allow_put': False, 'validate': {'type:uuid': None}, - 'is_visible': True}} + 'is_visible': True}, + 'tenant_id': {'allow_post': True, 'allow_put': False, + 'required_by_policy': True, + 'validate': {'type:string': + attr.TENANT_ID_MAX_LEN}, + 'is_visible': True}} } } diff --git a/neutron/tests/unit/extensions/test_flavors.py b/neutron/tests/unit/extensions/test_flavors.py index 8de2cf5ca..83a78b77b 100644 --- a/neutron/tests/unit/extensions/test_flavors.py +++ b/neutron/tests/unit/extensions/test_flavors.py @@ -224,7 +224,9 @@ class FlavorExtensionTestCase(extension.ExtensionTestCase): self.assertEqual(expected, res) def test_associate_service_profile_with_flavor(self): - expected = {'service_profile': {'id': _uuid()}} + tenant_id = uuidutils.generate_uuid() + expected = {'service_profile': {'id': _uuid(), + 'tenant_id': tenant_id}} instance = self.plugin.return_value instance.create_flavor_service_profile.return_value = ( expected['service_profile'])