Commit a4205872 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Fix quotaholder exception handling

Currently, QuotaholderHTTP returns CallError, with the call_error
attribute indicating the error.
parent bde4228b
......@@ -35,8 +35,8 @@ from synnefo.db.models import QuotaHolderSerial
from synnefo.api.faults import OverLimit
from commissioning.clients.quotaholder import QuotaholderHTTP
from commissioning.api.exception import (CommissionException, NoCapacityError,
from commissioning.api.exception import (NoCapacityError, NoQuantityError,
import logging
log = logging.getLogger(__name__)
......@@ -73,7 +73,7 @@ def uses_commission(func):
if serials:
return ret
except CommissionException:
except CallError:
log.exception("Unexpected error")
if serials:
......@@ -133,6 +133,9 @@ def issue_commission(**commission_info):
serial = qh.issue_commission(**commission_info)
except (NoCapacityError, NoQuantityError):
raise OverLimit("Limit exceeded for your account")
except CallError as e:
if e.call_error in ["NoCapacityError", "NoQuantityError"]:
raise OverLimit("Limit exceeded for your account")
db_serial = QuotaHolderSerial.objects.create(serial=serial)
return db_serial
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