Merge "Removes redundant code in quantum.api.v2.base.create()"

This commit is contained in:
Jenkins 2012-12-25 11:38:07 +00:00 committed by Gerrit Code Review
commit fa20b0587e

View File

@ -292,11 +292,12 @@ class Controller(object):
try:
if self._collection in body:
# Have to account for bulk create
for item in body[self._collection]:
self._validate_network_tenant_ownership(
request,
item[self._resource],
)
items = body[self._collection]
else:
items = [body]
for item in items:
self._validate_network_tenant_ownership(request,
item[self._resource])
policy.enforce(request.context,
action,
item[self._resource],
@ -315,29 +316,6 @@ class Controller(object):
QUOTAS.limit_check(request.context,
item[self._resource]['tenant_id'],
**kwargs)
else:
self._validate_network_tenant_ownership(
request,
body[self._resource]
)
policy.enforce(request.context,
action,
body[self._resource],
plugin=self._plugin)
try:
count = QUOTAS.count(request.context, self._resource,
self._plugin, self._collection,
body[self._resource]['tenant_id'])
kwargs = {self._resource: count + 1}
except exceptions.QuotaResourceUnknown as e:
# We don't want to quota this resource
LOG.debug(e)
except Exception:
raise
else:
QUOTAS.limit_check(request.context,
body[self._resource]['tenant_id'],
**kwargs)
except exceptions.PolicyNotAuthorized:
LOG.exception(_("Create operation not authorized"))
raise webob.exc.HTTPForbidden()