Drew Erny wrote:
On 06/16/2015 02:29 PM, Drew Erny wrote:
Hi, All,

I'm using the IPA Python API to write the Community Portal. Most of
the documentation for using the IPA Python API is targeted a plugin
authors, and this isn't a plugin for (what I think are) good reasons.
I'm doing

    # in the main program
    import api from ipalib
    api.bootstrap(context="client")
    api.finalize()
    api.Backend.rpcclient.connect()

    # and then, inside of a separate class
    api.Command.stageuser_add(...)

Which is how doc/examples/python-api.py shows it.

However, calling api.Command.stageuser_add(...) causes
    AttributeError: No context.rpcclient_... in thread 'Thread-1'

I think this is probably related to the fact that I haven't configured
my program to connect to any particular IPA server, because before the
program errors out, it prints:
    ipa: INFO: Forwarding 'stageuser_add' to json server 'None'

If the problem is the lack of a target server, as I suspect, how would
I configure the program to connect to a particular IPA server? If this
isn't caused by that, what could the causes be?

I think this may be a bug. Even after doing ipa-client-install and
following exactly the guide outlined in this email
(https://www.redhat.com/archives/freeipa-users/2012-June/msg00334.html)
I still get the same error. I've poked around in the code around this,
though, and if it is a bug then I might need help because it's WAY deep
in the FreeIPA internals.

Also, forgot to mention, all of the ellipses (...) in the code in the
first email are elided code, not literal ellipses.


I wonder if it's detecting that you are in-tree so trying to use ~/.ipa/default.conf.

This code:

from ipalib import api
api.bootstrap(context="client")
api.finalize()
api.Backend.rpcclient.connect()

# and then, inside of a separate class
print api.Command.user_show(u'admin')

produces this:

$ python derny.py
ipa: INFO: trying https://ipadev.greyoak.com/ipa/session/json
ipa: INFO: Forwarding 'user_show' to json server 'https://ipadev.greyoak.com/ipa/session/json' {u'result': {u'dn': u'uid=admin,cn=users,cn=accounts,dc=greyoak,dc=com', u'has_keytab': True, u'uid': (u'admin',), u'loginshell': (u'/bin/bash',), u'uidnumber': (u'590000000',), u'gidnumber': (u'590000000',), u'memberof_group': (u'admins', u'trust admins'), u'has_password': True, u'sn': (u'Administrator',), u'homedirectory': (u'/home/admin',), u'nsaccountlock': False}, u'value': u'admin', u'summary': None}

rob

--
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