[Freeipa-users] Export user and host list to a csv or text file
Chris Swingler
cto at sshchicago.org
Fri May 23 12:39:12 UTC 2014
Another alternative is to use Apache Directory Studio; it can dump most objects out into a CSV, and you should be able to filter out only the data you want.
> On May 23, 2014, at 7:33 AM, Petr Vobornik <pvoborni at redhat.com> wrote:
>
>> On 23.5.2014 14:02, Bret Wortman wrote:
>> Is the Python API documented anywhere? I've looked around without success.
>
> Not yet.
>
> For now, you can use IPA CLI for inspection:
>
> CLI commands are basically API commands, where `_` is replaced by `-`.
>
> List objects:
> `ipa help topics`
>
> List object commands:
> `ipa help $object`, e.g., `ipa help user`
>
> List command CLI options and parameters:
> `ipa $command --help`, e.g., `ipa user-mod --help`
>
> Map command params and options names to API option names:
> `ipa show-mappings $command`, e.g., `ipa show-mappings user-add`
>
> More can be read from code or by observing Web UI communication in browser developer tools - network tab.
>
>
> Then the python syntax is ~
> args = ['arg1', 'arg2']
> options = dict(option1="foo", option2="bar")
> api.Command['command_name'](*args, **options)
>
> HTH
>
>>
>>> On 05/23/2014 07:54 AM, Martin Kosek wrote:
>>>> On 05/23/2014 06:42 AM, Sanju A wrote:
>>>> Dear All,
>>>>
>>>> Is there any command to export the user and host list to a csv or
>>>> text format
>>> There is no such command out of the shelf, I would personally just
>>> write a
>>> short Python script to export the hosts (or anything else) in a format
>>> I need.
>>>
>>> Example for host:
>>>
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> #!/usr/bin/python2
>>>
>>> from ipalib import api
>>> api.bootstrap(context='exporter', debug=False)
>>> api.finalize()
>>> api.Backend.xmlclient.connect()
>>>
>>> hosts = api.Command['host_find']()['result']
>>>
>>> for host in hosts:
>>> print host['fqdn'][0]
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>
>>> This will print one host for each new line.
>>>
>>> Martin
> --
> Petr Vobornik
>
> _______________________________________________
> Freeipa-users mailing list
> Freeipa-users at redhat.com
> https://www.redhat.com/mailman/listinfo/freeipa-users
More information about the Freeipa-users
mailing list