On Tue, 2014-05-13 at 16:47 +0200, Jan Cholasta wrote:
> On 12.5.2014 20:50, Nathaniel McCallum wrote:
> > On Mon, 2014-05-12 at 18:40 +0200, Misnyovszki Adam wrote:
> >> On Tue, 06 May 2014 11:46:14 -0400
> >> Nathaniel McCallum <npmccal...@redhat.com> wrote:
> >>
> >>> On Tue, 2014-05-06 at 11:38 -0400, Nathaniel McCallum wrote:
> >>>> On Tue, 2014-05-06 at 17:34 +0200, Petr Vobornik wrote:
> >>>>> On 6.5.2014 17:13, Nathaniel McCallum wrote:
> >>>>>> On Tue, 2014-05-06 at 17:04 +0200, Petr Vobornik wrote:
> >>>>>>> On 6.5.2014 16:51, Nathaniel McCallum wrote:
> >>>>>>>> Specifying the default in the LDAP Object causes the
> >>>>>>>> parameter to be specified for non-add operations. This is
> >>>>>>>> especially problematic when performing the modify operation
> >>>>>>>> as it causes the primary key to change for every modification.
> >>>>>>>>
> >>>>>>>> https://fedorahosted.org/freeipa/ticket/4227
> >>>>>>>>
> >>>>>>>
> >>>>>>> shouldn't removal of `autofill=True,` be enough?
> >>>>>>
> >>>>>> Removing autofill=True results in the default not being used
> >>>>>> for the otptoken-add operation. That may be a different bug
> >>>>>> (I'm not sure what the expectation of autofill is).
> >>>>>>
> >>>>>> Nathaniel
> >>>>>>
> >>>>>
> >>>>> Seems to work form me with:
> >>>>>
> >>>>> diff --git a/ipalib/plugins/otptoken.py
> >>>>> b/ipalib/plugins/otptoken.py index f68ea7d..623f1f1 100644
> >>>>> --- a/ipalib/plugins/otptoken.py
> >>>>> +++ b/ipalib/plugins/otptoken.py
> >>>>> @@ -121,9 +121,7 @@ class otptoken(LDAPObject):
> >>>>>                cli_name='id',
> >>>>>                label=_('Unique ID'),
> >>>>>                default_from=lambda: unicode(uuid.uuid4()),
> >>>>> -            autofill=True,
> >>>>>                primary_key=True,
> >>>>> -            flags=('optional_create'),
> >>>>>            ),
> >>>>>            StrEnum('type?',
> >>>>>                label=_('Type'),
> >>>>
> >>>> Doing this causes the ipa otptoken-add command to prompt for the
> >>>> Unique ID. This may be the desired behavior, but it is not how it
> >>>> worked previously (no prompt).
> >>>
> >>> Here is an alternate patch for this second approach. I have no strong
> >>> opinion on the correct behavior here.
> >>>
> >>> Nathaniel
> >>
> >> IMO you should update API.txt with ./makeapi
> >
> > Running ./makeapi results in no changes to API.txt.
> 
> This is not right, there *are* changes in the API and build fails for me 
> becase API.txt is not updated.

I think maybe I ran it from the wrong branch. Fixed.

Nathaniel

>From cec7564c11ba9ab9dc06f8ade4013bdc808afba5 Mon Sep 17 00:00:00 2001
From: Nathaniel McCallum <npmccal...@redhat.com>
Date: Thu, 1 May 2014 16:31:45 -0400
Subject: [PATCH] Only use the ipatokenuniqueid default in the add operation

Without this patch, the ipatokenuniqueid attribute gets filled in during
non-add operations. This is especially problematic when performing the
modify operation as it causes the primary key to change for every
modification.

https://fedorahosted.org/freeipa/ticket/4227
---
 API.txt                    | 10 +++++-----
 VERSION                    |  4 ++--
 ipalib/plugins/otptoken.py |  2 --
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/API.txt b/API.txt
index e674dfebeb924cb16e9b7fdb0520365774ac50d9..b90aca2a650fca5a215c188b413d7fb294b348aa 100644
--- a/API.txt
+++ b/API.txt
@@ -2224,7 +2224,7 @@ output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), None)
 output: PrimaryKey('value', None, None)
 command: otptoken_add
 args: 1,21,3
-arg: Str('ipatokenuniqueid', attribute=True, autofill=True, cli_name='id', multivalue=False, primary_key=True, required=False)
+arg: Str('ipatokenuniqueid', attribute=True, cli_name='id', multivalue=False, primary_key=True, required=True)
 option: Str('addattr*', cli_name='addattr', exclude='webui')
 option: Flag('all', autofill=True, cli_name='all', default=False, exclude='webui')
 option: Str('description', attribute=True, cli_name='desc', multivalue=False, required=False)
@@ -2251,7 +2251,7 @@ output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), None)
 output: PrimaryKey('value', None, None)
 command: otptoken_del
 args: 1,2,3
-arg: Str('ipatokenuniqueid', attribute=True, autofill=True, cli_name='id', multivalue=True, primary_key=True, query=True, required=True)
+arg: Str('ipatokenuniqueid', attribute=True, cli_name='id', multivalue=True, primary_key=True, query=True, required=True)
 option: Flag('continue', autofill=True, cli_name='continue', default=False)
 option: Str('version?', exclude='webui')
 output: Output('result', <type 'dict'>, None)
@@ -2287,7 +2287,7 @@ output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), None)
 output: Output('truncated', <type 'bool'>, None)
 command: otptoken_mod
 args: 1,16,3
-arg: Str('ipatokenuniqueid', attribute=True, autofill=True, cli_name='id', multivalue=False, primary_key=True, query=True, required=True)
+arg: Str('ipatokenuniqueid', attribute=True, cli_name='id', multivalue=False, primary_key=True, query=True, required=True)
 option: Str('addattr*', cli_name='addattr', exclude='webui')
 option: Flag('all', autofill=True, cli_name='all', default=False, exclude='webui')
 option: Str('delattr*', cli_name='delattr', exclude='webui')
@@ -2300,7 +2300,7 @@ option: Str('ipatokenowner', attribute=True, autofill=False, cli_name='owner', m
 option: Str('ipatokenserial', attribute=True, autofill=False, cli_name='serial', multivalue=False, required=False)
 option: Str('ipatokenvendor', attribute=True, autofill=False, cli_name='vendor', default=u'FreeIPA', multivalue=False, required=False)
 option: Flag('raw', autofill=True, cli_name='raw', default=False, exclude='webui')
-option: Str('rename', autofill=True, cli_name='rename', multivalue=False, primary_key=True, required=False)
+option: Str('rename', cli_name='rename', multivalue=False, primary_key=True, required=False)
 option: Flag('rights', autofill=True, default=False)
 option: Str('setattr*', cli_name='setattr', exclude='webui')
 option: Str('version?', exclude='webui')
@@ -2309,7 +2309,7 @@ output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), None)
 output: PrimaryKey('value', None, None)
 command: otptoken_show
 args: 1,4,3
-arg: Str('ipatokenuniqueid', attribute=True, autofill=True, cli_name='id', multivalue=False, primary_key=True, query=True, required=True)
+arg: Str('ipatokenuniqueid', attribute=True, cli_name='id', multivalue=False, primary_key=True, query=True, required=True)
 option: Flag('all', autofill=True, cli_name='all', default=False, exclude='webui')
 option: Flag('raw', autofill=True, cli_name='raw', default=False, exclude='webui')
 option: Flag('rights', autofill=True, default=False)
diff --git a/VERSION b/VERSION
index 9a47a23a287faf25f973c8b3f0706d23f4cd8504..f9678d2b39fd2d9fab70d1929744afdbd32bba24 100644
--- a/VERSION
+++ b/VERSION
@@ -89,5 +89,5 @@ IPA_DATA_VERSION=20100614120000
 #                                                      #
 ########################################################
 IPA_API_VERSION_MAJOR=2
-IPA_API_VERSION_MINOR=85
-# Last change: tbabej - expose krbPrincipalExpiration
+IPA_API_VERSION_MINOR=86
+# Last change: npmccallum - Don't autofill token uid
diff --git a/ipalib/plugins/otptoken.py b/ipalib/plugins/otptoken.py
index f68ea7df596c8d7e837d98874f4fd630a6d7524a..623f1f1dcd798aa7b8f3b9210b2de90fb82cd4bf 100644
--- a/ipalib/plugins/otptoken.py
+++ b/ipalib/plugins/otptoken.py
@@ -121,9 +121,7 @@ class otptoken(LDAPObject):
             cli_name='id',
             label=_('Unique ID'),
             default_from=lambda: unicode(uuid.uuid4()),
-            autofill=True,
             primary_key=True,
-            flags=('optional_create'),
         ),
         StrEnum('type?',
             label=_('Type'),
-- 
1.9.0

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to