]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add tenant_id to flavor service profiles attributes
authorJames Arendt <james.arendt@hp.com>
Wed, 26 Aug 2015 23:53:24 +0000 (16:53 -0700)
committerArmando Migliaccio <armamig@gmail.com>
Wed, 2 Sep 2015 16:44:11 +0000 (16:44 +0000)
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

neutron/extensions/flavors.py
neutron/tests/unit/extensions/test_flavors.py

index 8de5fd08fe1ce79b01baa8be4d0b3cc480e8bcce..22be68cdd7419e9240bb05c2c6c0b772156a95f7 100644 (file)
@@ -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}}
     }
 }
 
index 8de2cf5cacc3b14083a2e9753705cb8c3c570408..83a78b77b0b35505b00156d6c3f0e5345142c339 100644 (file)
@@ -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'])