X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/chopwood/blobdiff_plain/ae21e4f32dfa5f69d9e96394c99ce01b37252b8e..0c58273e69f08d17e69d9af6b04734bdce302532:/operation.py diff --git a/operation.py b/operation.py index f02b462..50d7952 100644 --- a/operation.py +++ b/operation.py @@ -24,6 +24,7 @@ ### . import os as OS +import syslog as L import config as CONF; CFG = CONF.CFG import util as U @@ -201,6 +202,9 @@ class BaseRequest (object): """ return optype(svc, user, **kw) + def describe(me): + return me.OP + def perform(me): """ Perform the queued-up operations. @@ -338,7 +342,15 @@ def operate(op, accts, *args, **kw): * a list of the individual operation objects. """ rq = getattr(CFG.RQCLASS, op)(accts, *args, **kw) - rq.check() + desc = rq.describe() + try: + rq.check() + except U.ExpectedError, e: + L.syslog('REFUSE %s %s: %s' % + (desc, + ', '.join(['%s@%s' % (o.user, o.svc.name) for o in rq.ops]), + e)) + raise ops = rq.perform() nwin = nlose = 0 for o in ops: @@ -350,6 +362,12 @@ def operate(op, accts, *args, **kw): else: if nlose: rc = outcome.FAIL else: rc = outcome.NOTHING + L.syslog('%s %s: %s' % (['OK', 'PARTIAL', 'FAIL', 'NOTHING'][rc], + desc, + '; '.join(['%s@%s %s' % (o.user, o.svc.name, + not o.error and 'OK' or + 'ERR %s' % o.error) + for o in ops]))) ii = [info(v, getattr(rq, k)) for k, v in rq.INFO.iteritems()] return outcome(rc, nwin, nlose), ii, rq, ops