diff --git a/snf-astakos-app/astakos/im/management/commands/reconcile-resources-astakos.py b/snf-astakos-app/astakos/im/management/commands/reconcile-resources-astakos.py index 9ed1b85caf8a24045e908a1f1ea09ee55b5504f0..c6e0567df679a468a9f0d3e9274959e428712507 100644 --- a/snf-astakos-app/astakos/im/management/commands/reconcile-resources-astakos.py +++ b/snf-astakos-app/astakos/im/management/commands/reconcile-resources-astakos.py @@ -41,6 +41,7 @@ from astakos.im.models import Service, AstakosUser from astakos.im.quotas import service_get_quotas, SYSTEM from astakos.im.functions import count_pending_app import astakos.quotaholder_app.callpoint as qh +import astakos.quotaholder_app.exception as qh_exception class Command(BaseCommand): @@ -129,8 +130,14 @@ class Command(BaseCommand): pprint_table(self.stderr, unsynced, headers) if options["fix"]: provisions = map(create_provision, unsynced) - s = qh.issue_commission('astakos', provisions, - name='RECONCILE', force=force) + try: + s = qh.issue_commission('astakos', provisions, + name='RECONCILE', force=force) + except qh_exception.NoCapacityError: + write("Reconciling failed because a limit has been " + "reached. Use --force to ignore the check.\n") + return + qh.resolve_pending_commission('astakos', s) write("Fixed unsynced resources\n") diff --git a/snf-cyclades-app/synnefo/quotas/management/commands/reconcile-resources-cyclades.py b/snf-cyclades-app/synnefo/quotas/management/commands/reconcile-resources-cyclades.py index f8e1c42178645f9235beafbd81aab3f924089342..652d7dc2b47e5a4d6aa81fb6138907d9624ad010 100644 --- a/snf-cyclades-app/synnefo/quotas/management/commands/reconcile-resources-cyclades.py +++ b/snf-cyclades-app/synnefo/quotas/management/commands/reconcile-resources-cyclades.py @@ -125,7 +125,12 @@ class Command(BaseCommand): request["auto_accept"] = True request["name"] = "RECONCILE" request["provisions"] = map(create_provision, unsynced) - qh.issue_commission(ASTAKOS_TOKEN, request) + try: + qh.issue_commission(ASTAKOS_TOKEN, request) + except quotas.QuotaLimit: + write("Reconciling failed because a limit has been " + "reached. Use --force to ignore the check.\n") + return write("Fixed unsynced resources\n") if pending_exists: diff --git a/snf-pithos-app/pithos/api/management/commands/reconcile-resources-pithos.py b/snf-pithos-app/pithos/api/management/commands/reconcile-resources-pithos.py index d9054bcaa2114ca89c9e0ee2bd1e479b9acb091a..909a452fa2f7b57b610bdde5aca6d90268712e42 100644 --- a/snf-pithos-app/pithos/api/management/commands/reconcile-resources-pithos.py +++ b/snf-pithos-app/pithos/api/management/commands/reconcile-resources-pithos.py @@ -38,6 +38,7 @@ from optparse import make_option from pithos.api.util import get_backend from pithos.backends.modular import CLUSTER_NORMAL, DEFAULT_SOURCE from synnefo.webproject.management import utils +from astakosclient.errors import QuotaLimit backend = get_backend() @@ -128,9 +129,16 @@ class Command(NoArgsCommand): request['auto_accept'] = True request['name'] = "RECONCILE" request['provisions'] = map(create_provision, unsynced) - backend.astakosclient.issue_commission( - backend.service_token, request - ) + try: + backend.astakosclient.issue_commission( + backend.service_token, request + ) + except QuotaLimit: + self.stdout.write( + "Reconciling failed because a limit has been " + "reached. Use --force to ignore the check.\n") + return + if pending_exists: self.stdout.write(