Commit 68b5beb0 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

Do not allow duplicate provisions in a commission.

parent d41707ff
......@@ -35,6 +35,7 @@ from .quotaholder import QuotaholderAPI
from .exception import ( InvalidKeyError, NoEntityError,
NoQuantityError, NoCapacityError,
ExportLimitError, ImportLimitError,
CorruptedError, InvalidDataError)
CorruptedError, InvalidDataError,
DuplicateError)
API_Spec = QuotaholderAPI
......@@ -61,3 +61,7 @@ class ExportLimitError(CommissionException):
@register_exception
class ImportLimitError(CommissionException):
pass
@register_exception
class DuplicateError(CommissionException):
pass
......@@ -35,7 +35,8 @@ from synnefo.lib.quotaholder.api import (
QuotaholderAPI,
InvalidKeyError, NoEntityError,
NoQuantityError, NoCapacityError,
ExportLimitError, ImportLimitError)
ExportLimitError, ImportLimitError,
DuplicateError)
from synnefo.lib.commissioning import \
Callpoint, CorruptedError, InvalidDataError
......@@ -349,7 +350,15 @@ class QuotaholderDjangoDBCallpoint(Callpoint):
commission = create(entity_id=target, clientkey=clientkey, name=name)
serial = commission.serial
checked = []
for entity, resource, quantity in provisions:
ent_res = entity, resource
if ent_res in checked:
m = "Duplicate provision for %s.%s" % ent_res
raise DuplicateError(m)
checked.append(ent_res)
try:
e = Entity.objects.get(entity=entity)
except Entity.DoesNotExist:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment