summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-08-19 16:20:01 -0400
committerRob Crittenden <rcritten@redhat.com>2011-08-19 01:21:35 -0400
commit4797cddbd0ac922d03943d63ef9ff131e67c71e4 (patch)
treed4de6b6f8159cf6dcfa15d36292a454a3fbd5f9a /ipalib
parent159c13a550f1943de47592615a43576c9dbc2dbe (diff)
downloadfreeipa-4797cddbd0ac922d03943d63ef9ff131e67c71e4.zip
freeipa-4797cddbd0ac922d03943d63ef9ff131e67c71e4.tar.gz
freeipa-4797cddbd0ac922d03943d63ef9ff131e67c71e4.tar.xz
Log each command in a batch separately.
This also fixes command logging in general, it wasn't working in most cases as a regression in ticket 1322. https://fedorahosted.org/freeipa/ticket/1598
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/plugins/batch.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/ipalib/plugins/batch.py b/ipalib/plugins/batch.py
index 973526a..b95e5d0 100644
--- a/ipalib/plugins/batch.py
+++ b/ipalib/plugins/batch.py
@@ -51,6 +51,7 @@ from ipalib import Str, List
from ipalib.output import Output
from ipalib import output
from ipalib.text import _
+from ipalib.request import context
from ipapython.version import API_VERSION
class batch(Command):
@@ -81,17 +82,40 @@ class batch(Command):
def execute(self, *args, **options):
results=[]
for arg in args[0]:
+ params = dict()
+ name = None
try:
+ if 'method' not in arg:
+ raise errors.RequirementError(name='method')
+ if 'params' not in arg:
+ raise errors.RequirementError(name='params')
+ name = arg['method']
+ if name not in self.Command:
+ raise errors.CommandError(name=name)
a = arg['params'][0]
kw = arg['params'][1]
newkw = {}
for k in kw:
newkw[str(k)] = kw[k]
- result = api.Command[arg['method']](*a, **newkw)
+ params = api.Command[name].args_options_2_params(*a, **newkw)
+
+ result = api.Command[name](*a, **newkw)
+ self.info(
+ 'batch: %s(%s): SUCCESS', name, ', '.join(api.Command[name]._repr_iter(**params))
+ )
result['error']=None
except Exception, e:
result = dict()
result['error'] = unicode(e)
+ if isinstance(e, errors.RequirementError) or \
+ isinstance(e, errors.CommandError):
+ self.info(
+ '%s: batch: %s', context.principal, e.__class__.__name__
+ )
+ else:
+ self.info(
+ '%s: batch: %s(%s): %s', context.principal, name, ', '.join(api.Command[name]._repr_iter(**params)), e.__class__.__name__
+ )
results.append(result)
return dict(count=len(results) , results=results)