The check of the tenant done in neutron/db/common_db_mixin._get_tenant_id_for_create() is already did by the
Neutron Controller in prepare_request_body(), with a call to attibutes.populate_tenant_id().
Moreover, when the Controller processes a "create" requests, it will add the 'tenant_id' to the resource dict.
So instead of calling the _get_tenant_id_for_create(), modules can directly get the tenant_id in the resource dict.
A firsts patch has been submitted to avoid duplicated code [1], but it requires a bigger effort to add the tenant_id in requests used during UTs. Indeed, UT framework seems to bypass the controller. Thus, the tenant_id is not automatically added by the controller during UTs. The _get_tenant_id_for_create() was convenient for UTs, since it retrieves the tenant_id from the context, if it is not in the resource dict.
[1]https://review.openstack.org/#/c/241984/
Fix proposed to branch: master /review. openstack. org/242841
Review: https:/