Avoid duplicating tenant check when creating resources
The check of the tenant done in the method _get_tenant_id_for_create() is already did by the Neutron Controller in prepare_request_body(), with a call to attributes.populate_tenant_id(). Moreover, when the Controller processes a "create" requests, it will add the 'tenant_id' to the resource dict. Thus, _get_tenant_id_for_create() can be deleted. Calls to this method are replaced by the res['tenant_id']. Changes have to be done in UT to explicitly add the tenant_id while creating resources, since the UT framework is bypassing the controller code that automatically adds the tenant_id to the resource. Co-Authored-By: Hong Hui Xiao <xiaohhui@cn.ibm.com> Closes-Bug: #1513825 Change-Id: Icea06dc81344e1120bdf986a97a6b1094bbb765e Depends-On: I31022e9230fc5404c6a94edabbb08d2b079c3a09 Depends-On: Iea3f014ef17a1e1b755cd2efe99afd1a36ebbc6a Depends-On: I604602d023e0cbf7f6591149f914d73217d7a574
This commit is contained in:
@@ -47,7 +47,8 @@ class L3SchedulerBaseTest(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
||||
return agent
|
||||
|
||||
def _create_router(self, name):
|
||||
router = {'name': name, 'admin_state_up': True}
|
||||
router = {'name': name, 'admin_state_up': True,
|
||||
'tenant_id': self.adminContext.tenant_id}
|
||||
return self.l3_plugin.create_router(
|
||||
self.adminContext, {'router': router})
|
||||
|
||||
@@ -304,7 +305,8 @@ class L3AZSchedulerBaseTest(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
||||
|
||||
def _create_router(self, az_hints, ha):
|
||||
router = {'name': 'router1', 'admin_state_up': True,
|
||||
'availability_zone_hints': az_hints}
|
||||
'availability_zone_hints': az_hints,
|
||||
'tenant_id': self._tenant_id}
|
||||
if ha:
|
||||
router['ha'] = True
|
||||
return self.l3_plugin.create_router(
|
||||
|
||||
Reference in New Issue
Block a user