log must be initilized before first usage in API, otherwise traceback is shown:

# ipa -e random-nonexistent-key=1 user-find
Traceback (most recent call last):
  File "/bin/ipa", line 32, in <module>
    cli.run(api)
  File "/usr/lib/python2.7/site-packages/ipalib/cli.py", line 1346, in run
    api.log.exception('%s: %s', e.__class__.__name__, str(e))
AttributeError: 'API' object has no attribute 'log'

Patch attached.

--
Martin Basti

From e6f58d28036fbe7e58b32df0ffc9da70a54cba57 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Wed, 8 Jul 2015 14:13:19 +0200
Subject: [PATCH] Fix logging in API

Setup log in API before first usage
---
 ipalib/plugable.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 2ce7acfd6c916000923500a1da077f49e68392d1..45b3463760965f1afdbe1145b3af9bcf4943def9 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -372,11 +372,11 @@ class API(ReadOnly):
         Initialize environment variables and logging.
         """
         self.__doing('bootstrap')
-        self.env._bootstrap(**overrides)
-        self.env._finalize_core(**dict(DEFAULT_CONFIG))
         self.log_mgr = log_mgr
         log = log_mgr.root_logger
         self.log = log
+        self.env._bootstrap(**overrides)
+        self.env._finalize_core(**dict(DEFAULT_CONFIG))
 
         # Add the argument parser
         if not parser:
-- 
2.4.3

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to