[Freeipa-users] call implemented methods via xml-rpc

ALAHYANE Rachid afkkir at gmail.com
Thu Apr 22 16:39:10 UTC 2010


Hi,

As I don't know how to specify the xmlrpc_uri in the bootstrap() method, I
modified this file /usr/lib/python2.6/site-packages/ipalib/constants.py.

I put this line
('xmlrpc_uri', 'https://server.domain.org/ipa/xml')
instead
('xmlrpc_uri', 'http://localhost:8888/ipa/xml')

Here is the execution of my_script inside the ipython console

---------------------------------------------------------------
In [1]: from ipalib import api

In [2]: api.bootstrap_with_global_options(context='webservices')
Out[2]:
(<Values at 0x889ee8c: {'debug': None, 'conf': None, 'env': None, 'verbose':
None}>,
 [])

In [3]: api.finalize()

In [4]: api.env.xmlrpc_uri
Out[4]: u'https://server.domain.org/ipa/xml'

In [5]: api.Backend.xmlclient.connect()

In [6]: api.Command.user_show(u'admin')
---------------------------------------------------------------------------
ConversionError                           Traceback (most recent call last)

/var/www/<ipython console> in <module>()

/usr/lib/python2.6/site-packages/ipalib/frontend.pyc in __call__(self,
*args, **options)
    399         self.validate(**params)
    400         (args, options) = self.params_2_args_options(**params)
--> 401         ret = self.run(*args, **options)
    402         if (
    403             isinstance(ret, dict)

/usr/lib/python2.6/site-packages/ipalib/frontend.pyc in run(self, *args,
**options)
    668         if self.api.env.in_server:
    669             return self.execute(*args, **options)
--> 670         return self.forward(*args, **options)
    671
    672     def execute(self, *args, **kw):

/usr/lib/python2.6/site-packages/ipalib/frontend.pyc in forward(self, *args,
**kw)
    689         Forward call over XML-RPC to this same command on server.
    690         """
--> 691         return self.Backend.xmlclient.forward(self.name, *args,
**kw)
    692
    693     def finalize(self):

/usr/lib/python2.6/site-packages/ipalib/rpc.pyc in forward(self, name,
*args, **kw)
    412             if e.faultCode in self.__errors:
    413                 error = self.__errors[e.faultCode]
--> 414                 raise error(message=e.faultString)
    415             raise UnknownError(
    416                 code=e.faultCode,

ConversionError: invalid 'uid': Only one value is allowed

---------------------------------------------------------------

Hem, Yet another problem :(

---
Meilleures salutations / Best Regards

Rachid ALAHYANE



2010/4/22 ALAHYANE Rachid <afkkir at gmail.com>

> Thank you for answer, now I get this error :
> -----------------------------------------------------
> NetworkError: cannot connect to u'http://localhost:8888/ipa/xml':
> Permission denied
> -----------------------------------------------------
>
> How can I specify my ipa server address. Can I do this in the
> api.bootstrap() method ?
> What is the difference between api.bootstrap()
> and api.bootstrap_with_global_options()  ?
>
> ---
> Meilleures salutations / Best Regards
>
> Rachid ALAHYANE
>
>
>
> 2010/4/22 Jason Gerard DeRose <jderose at redhat.com>
>
> On Wed, 2010-04-21 at 15:21 -0400, Rob Crittenden wrote:
>> > ALAHYANE Rachid wrote:
>> > > Here is my apache logs :
>> > >
>> ------------------------------------------------------------------------------------------------
>> > > ==> /var/log/httpd/error_log <==
>> > > [Wed Apr 21 20:02:51 2010] [warn] mod_python (pid=1529,
>> > > interpreter='rpcserver.domain.org <http://rpcserver.domain.org>'):
>> > > Module directory listed in "sys.path". This may cause problems. Please
>> > > check code. File being imported is
>> > > "/usr/lib/python2.6/site-packages/webservices/account.py".
>> > > [Wed Apr 21 20:02:51 2010] [notice] mod_python (pid=1529,
>> > > interpreter='rpcserver.domain.org <http://rpcserver.domain.org>'):
>> > > Importing module
>> '/usr/lib/python2.6/site-packages/webservices/account.py'
>> > > /usr/lib/python2.6/site-packages/mod_python/importer.py:32:
>> > > DeprecationWarning: the md5 module is deprecated; use hashlib instead
>> > >   import md5
>> > > ipa: ERROR: Could not create log_dir '/root/.ipa/log'
>> > > ipa: ERROR: could not load plugin module
>> > > '/usr/lib/python2.6/site-packages/ipalib/plugins/migration.py'
>> > > Traceback (most recent call last):
>> > >   File "/usr/lib/python2.6/site-packages/ipalib/plugable.py", line
>> 533,
>> > > in import_plugins
>> > >     __import__(fullname)
>> > >   File "/usr/lib/python2.6/site-packages/ipalib/plugins/migration.py",
>> > > line 33, in <module>
>> > >     from ipaserver.plugins.ldap2 import ldap2
>> > >   File "/usr/lib/python2.6/site-packages/ipaserver/__init__.py", line
>> > > 33, in <module>
>> > >     api.bootstrap(context='server', debug=True, log=None)
>> > >   File "/usr/lib/python2.6/site-packages/ipalib/plugable.py", line
>> 380,
>> > > in bootstrap
>> > >     self.__doing('bootstrap')
>> > >   File "/usr/lib/python2.6/site-packages/ipalib/plugable.py", line
>> 365,
>> > > in __doing
>> > >     '%s.%s() already called' % (self.__class__.__name__, name)
>> > > StandardError: API.bootstrap() already called
>> >
>> > Very strange. You explicitly set the context to 'webservices' and this
>> > backtrace shows it as 'server' which is why migration.py is trying to
>> > load ldap2 (and blowing up).
>> >
>> > Jason, any ideas?
>>
>> Okay, took me a while to realize what's going on... in alpha2 we were
>> still running the server under mod_python (we have since switched to
>> mod_wsgi).
>>
>> In alpha2, when ipaserver is imported, ipaserver/__init__.py tries to
>> import mod_python (which would indicate we are running under the Apache
>> process).  When mod_python could be imported, we always initialized IPA
>> for use in the server.  The worked fine for us at the time, but it
>> obviously causes problems when trying to use the library from another
>> mod_python handler.
>>
>> I recommend you try working with the current code from git, where this
>> implied initialization has been removed:
>>
>>    git clone git://git.fedorahosted.org/git/freeipa.git
>>
>> I attached a script that I use to install a bunch of dependencies for
>> building the rpm (or srpm).
>>
>> After you have these dependencies installed, you can then build and
>> install ipa doing something like this:
>>
>>    cd freeipa
>>    make rpms
>>    yum install --nogpgcheck dist/rpms/*.rpm
>>    ipa-server-install
>>
>>
>> Hope this helps!
>>
>> > rob
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/freeipa-users/attachments/20100422/8f2c211b/attachment.htm>


More information about the Freeipa-users mailing list