chiark
/
gitweb
/
~mdw
/
chopwood
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
format.py: Fix some commentary typos.
[chopwood]
/
operation.py
diff --git
a/operation.py
b/operation.py
index f02b46250cfc0c06a90c017c44950758c1893472..fccd172fc908ee5b7b9fa0895e735e8eb5d913fa 100644
(file)
--- a/
operation.py
+++ b/
operation.py
@@
-24,6
+24,7
@@
### <http://www.gnu.org/licenses/>.
import os as OS
### <http://www.gnu.org/licenses/>.
import os as OS
+import syslog as L
import config as CONF; CFG = CONF.CFG
import util as U
import config as CONF; CFG = CONF.CFG
import util as U
@@
-178,7
+179,7
@@
class BaseRequest (object):
It provides an empty `INFO' map; a simple `check' method which checks the
operation name (in the class attribute `OP') against the configured policy
It provides an empty `INFO' map; a simple `check' method which checks the
operation name (in the class attribute `OP') against the configured policy
- `CFG
'
ALLOWOP'; and the obvious `perform' method which assumes that the
+ `CFG
.
ALLOWOP'; and the obvious `perform' method which assumes that the
`ops' list has already been constructed.
"""
`ops' list has already been constructed.
"""
@@
-201,6
+202,9
@@
class BaseRequest (object):
"""
return optype(svc, user, **kw)
"""
return optype(svc, user, **kw)
+ def describe(me):
+ return me.OP
+
def perform(me):
"""
Perform the queued-up operations.
def perform(me):
"""
Perform the queued-up operations.
@@
-338,7
+342,16
@@
def operate(op, accts, *args, **kw):
* a list of the individual operation objects.
"""
rq = getattr(CFG.RQCLASS, op)(accts, *args, **kw)
* a list of the individual operation objects.
"""
rq = getattr(CFG.RQCLASS, op)(accts, *args, **kw)
- rq.check()
+ desc = rq.describe()
+ if not CFG.OPTS.ignpol:
+ 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:
ops = rq.perform()
nwin = nlose = 0
for o in ops:
@@
-350,6
+363,12
@@
def operate(op, accts, *args, **kw):
else:
if nlose: rc = outcome.FAIL
else: rc = outcome.NOTHING
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
ii = [info(v, getattr(rq, k)) for k, v in rq.INFO.iteritems()]
return outcome(rc, nwin, nlose), ii, rq, ops