Merge "Removes redundant code in quantum.api.v2.base.create()"
This commit is contained in:
commit
fa20b0587e
@ -292,42 +292,20 @@ class Controller(object):
|
|||||||
try:
|
try:
|
||||||
if self._collection in body:
|
if self._collection in body:
|
||||||
# Have to account for bulk create
|
# Have to account for bulk create
|
||||||
for item in body[self._collection]:
|
items = body[self._collection]
|
||||||
self._validate_network_tenant_ownership(
|
|
||||||
request,
|
|
||||||
item[self._resource],
|
|
||||||
)
|
|
||||||
policy.enforce(request.context,
|
|
||||||
action,
|
|
||||||
item[self._resource],
|
|
||||||
plugin=self._plugin)
|
|
||||||
try:
|
|
||||||
count = QUOTAS.count(request.context, self._resource,
|
|
||||||
self._plugin, self._collection,
|
|
||||||
item[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,
|
|
||||||
item[self._resource]['tenant_id'],
|
|
||||||
**kwargs)
|
|
||||||
else:
|
else:
|
||||||
self._validate_network_tenant_ownership(
|
items = [body]
|
||||||
request,
|
for item in items:
|
||||||
body[self._resource]
|
self._validate_network_tenant_ownership(request,
|
||||||
)
|
item[self._resource])
|
||||||
policy.enforce(request.context,
|
policy.enforce(request.context,
|
||||||
action,
|
action,
|
||||||
body[self._resource],
|
item[self._resource],
|
||||||
plugin=self._plugin)
|
plugin=self._plugin)
|
||||||
try:
|
try:
|
||||||
count = QUOTAS.count(request.context, self._resource,
|
count = QUOTAS.count(request.context, self._resource,
|
||||||
self._plugin, self._collection,
|
self._plugin, self._collection,
|
||||||
body[self._resource]['tenant_id'])
|
item[self._resource]['tenant_id'])
|
||||||
kwargs = {self._resource: count + 1}
|
kwargs = {self._resource: count + 1}
|
||||||
except exceptions.QuotaResourceUnknown as e:
|
except exceptions.QuotaResourceUnknown as e:
|
||||||
# We don't want to quota this resource
|
# We don't want to quota this resource
|
||||||
@ -336,7 +314,7 @@ class Controller(object):
|
|||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
QUOTAS.limit_check(request.context,
|
QUOTAS.limit_check(request.context,
|
||||||
body[self._resource]['tenant_id'],
|
item[self._resource]['tenant_id'],
|
||||||
**kwargs)
|
**kwargs)
|
||||||
except exceptions.PolicyNotAuthorized:
|
except exceptions.PolicyNotAuthorized:
|
||||||
LOG.exception(_("Create operation not authorized"))
|
LOG.exception(_("Create operation not authorized"))
|
||||||
|
Loading…
Reference in New Issue
Block a user