import weakref
+from debtcollector import removals
import six
from sqlalchemy import and_
from sqlalchemy import or_
from sqlalchemy import sql
+from neutron._i18n import _
+from neutron.common import exceptions as n_exc
from neutron.db import sqlalchemyutils
if key in fields))
return resource
+ @removals.remove(message='This method will be removed in N')
+ def _get_tenant_id_for_create(self, context, resource):
+ if context.is_admin and 'tenant_id' in resource:
+ tenant_id = resource['tenant_id']
+ elif ('tenant_id' in resource and
+ resource['tenant_id'] != context.tenant_id):
+ reason = _('Cannot create resource for another tenant')
+ raise n_exc.AdminRequired(reason=reason)
+ else:
+ tenant_id = context.tenant_id
+ return tenant_id
+
def _get_by_id(self, context, model, id):
query = self._model_query(context, model)
return query.filter(model.id == id).one()