On 2016-03-21 12:02, Jan Cholasta wrote: > Hi, > > On 18.3.2016 15:26, Christian Heimes wrote: >> Hi, >> >> I'd like to use FreeIPA's RPC interface from Ansible directly. But the >> output of plugins is rather unfriendly and unpythonic: >> >>>>> print(api.Command.dnsconfig_show()) >> {u'result': {u'dn': u'cn=dns,dc=ipa,dc=example', u'idnsallowsyncptr': >> (u'FALSE',)}, u'value': None, u'summary': None} >> >> Please notice (u'FALSE',) instead of False. > > This is how the framework does things - there is no internal consistency > and no singular place where coding of values is handled, lot of the > output is generated by ad-hoc code somewhere in post_callbacks. > Unfortunately this is not easily fixable.
Yes, it's a bit unfortunate. FreeIPA has a rich and powerful RPC-API. The under-documented and nested output makes the RPCs hard to use from Python code. I'd wish we had something like JSON schema for input and output documentation. >> But it is failing for some plugins like user_find(). The plugin returns >> u'memberof_group': (u'admins', u'trust admins'). However >> global_output_params defines the value as an optional and single valued >> string: >> >> Str('memberof_group?', label=_('Member of groups')). >> >> I think the definition is wrong. memberof_group and some other fields >> should be defined as optional and multivalued fields insteads. Even the >> field's label uses a plural form. >> >> What do you think? > > Yes, the definition is wrong, but I don't think it's worth fixing, since > you can't rely on a single-value param having a single value in the > output for any other command and param anyway. I think it's a low-hanging fruit. All memberof and indirectmemberof params should be multivalued. That's an easy fix. Christian
signature.asc
Description: OpenPGP digital signature
-- 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