[Freeipa-devel] [PATCH 0017] Add OTP support to ipalib CLI

Petr Viktorin pviktori at redhat.com
Wed Oct 2 10:00:41 UTC 2013


On 10/01/2013 11:00 PM, Nathaniel McCallum wrote:
> On Thu, 2013-09-05 at 12:19 +0200, Petr Viktorin wrote:
>> On 09/05/2013 06:38 AM, Nathaniel McCallum wrote:
>>> 3. I had to make the 'id' option optional to make the uuid
>>> autogeneration work in otp-add. However, this has the side-effect that
>>> 'id' is now optional in all the other commands. This is particularly bad
>>> in the case of otp-del, where calling this command with no ID
>>> transparently removes all tokens. How can I make this optional for
>>> otp-add but required for all other commands?
>>
>> You'll need to add a new option flag.
>>
>> 1. Add a 'optional_create' flag to the comment in ipalib.parameters.Param.
>> 2. Handle the flag in ipalib.crud.Create.get_options (clone with
>> attribute=attribute, required=False)
>>
>> See the handling of 'ask_create' for exapmles.
>
> I spent part of yesterday and all day today working on this and I can't
> make the attached patch work... No matter what I do, the Param with the
> 'optional_create' flag is never actually optional. There is no failure,
> it just doesn't work. Any thoughts?

get_args is overridden in plugins/baseldap.py, and that contains a bug. 
Thanks for bringing this up!
Here's a patch, apply it on top of your "Add optional_create flag".

> As a hint, the code in cli.py and frontend.py seems to call cmd.args()
> rather than cmd.get_args(). Though, when I changed this it seemed to
> break stuff. There seems to be lots of Python magic going on here via
> the NameSpace class and I can't quite follow the logic.

Yeah, the framework is a bit of a maze. Sorry for that.

-- 
Petr³
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freeipa-pviktori-0303-Fix-bug-in-LDAPCreate-and-crud.Create-get_args-metho.patch
Type: text/x-patch
Size: 1688 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20131002/a22030d2/attachment.bin>


More information about the Freeipa-devel mailing list