[Freeipa-devel] IPA Python API
Drew Erny
derny at redhat.com
Thu Jun 25 17:33:33 UTC 2015
If I add the lines
if not api.Backend.rpcclient.isconnected():
api.Backend.rpcclient.connect()
before I call the api, the code works. Problem (pretty much) solved.
On 06/23/2015 04:36 PM, Drew Erny wrote:
> Resurrecting this thread, because the problem is getting me again.
>
> If I go through the python interpreter and import the code that calls
> the ipalib, and then manually call it myself the way the webserver
> does, the code works. If the same code is run in the course of the web
> server process, I get the error:
>
> Traceback (most recent call last):
> File
> "/home/derny/freeipa/env/lib/python2.7/site-packages/cherrypy/_cprequest.py",
> line 670, in respond
> response.body = self.handler()
> File
> "/home/derny/freeipa/env/lib/python2.7/site-packages/cherrypy/lib/encoding.py",
> line 217, in __call__
> self.body = self.oldhandler(*args, **kwargs)
> File
> "/home/derny/freeipa/env/lib/python2.7/site-packages/cherrypy/_cpdispatch.py",
> line 61, in __call__
> return self.callable(*self.args, **self.kwargs)
> File "freeipa_community_portal/app.py", line 39, in POST
> errors = user.save()
> File "freeipa_community_portal/model/user.py", line 33, in save
> self._call_api()
> File "freeipa_community_portal/model/user.py", line 45, in _call_api
> mail=self.email
> File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line
> 439, in __call__
> ret = self.run(*args, **options)
> File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line
> 755, in run
> return self.forward(*args, **options)
> File "/usr/lib/python2.7/site-packages/ipalib/frontend.py", line
> 776, in forward
> return self.Backend.rpcclient.forward(self.name, *args, **kw)
> File "/usr/lib/python2.7/site-packages/ipalib/rpc.py", line 880, in
> forward
> command = getattr(self.conn, name)
> File "/usr/lib/python2.7/site-packages/ipalib/backend.py", line 97,
> in __get_conn
> self.id, threading.currentThread().getName())
> AttributeError: no context.rpcclient in thread 'CP Server Thread-6'
>
> The error shows up whether the server is run from within the python
> interpreter or by itself.
>
> I kinit and have a TGT from the IPA server. The client machine is
> registered with the IPA server. When I run the commands "by hand", an
> HTTP ticket can be seen in the klist. When I run the webserver, no
> HTTP ticket is ever recieved, so the code is failing on the client
> side before it even gets to the server.
>
> Which is obviously not what should be happening. It's the same error I
> got when I was using Flask, and now I'm using cherrypy and it's still
> broken. Could this have something to do with the web server being a
> multithreaded environment?
>
More information about the Freeipa-devel
mailing list