Merge "Ensure that decomposed plugins do not break"

This commit is contained in:
Jenkins 2016-01-11 14:41:20 +00:00 committed by Gerrit Code Review
commit e811983b2d

View File

@ -15,11 +15,14 @@
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
@ -167,6 +170,18 @@ class CommonDbMixin(object):
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()