[Freeipa-devel] [PATCH] 0030 Fix --{user, group}-ignore-attribute in migration plugin.

2014-11-20 Thread David Kupka

https://fedorahosted.org/freeipa/ticket/4620
--
David Kupka
From b6aba1531af03ca3511690548de109d585828486 Mon Sep 17 00:00:00 2001
From: David Kupka dku...@redhat.com
Date: Wed, 19 Nov 2014 09:57:59 -0500
Subject: [PATCH] Fix --{user,group}-ignore-attribute in migration plugin.

Ignore case in attribute names.

https://fedorahosted.org/freeipa/ticket/4620
---
 ipalib/plugins/migration.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipalib/plugins/migration.py b/ipalib/plugins/migration.py
index 6b630a464f0be163e82de95afe3a74b22889574b..57545b594f4ec6c53521abeab339399099d8125e 100644
--- a/ipalib/plugins/migration.py
+++ b/ipalib/plugins/migration.py
@@ -197,7 +197,7 @@ def _pre_migrate_user(ldap, pkey, dn, entry_attrs, failed, config, ctx, **kwargs
 
 # do not migrate all attributes
 for attr in entry_attrs.keys():
-if attr in attr_blacklist:
+if attr.lower() in attr_blacklist:
 del entry_attrs[attr]
 
 # do not migrate all object classes
@@ -394,7 +394,7 @@ def _pre_migrate_group(ldap, pkey, dn, entry_attrs, failed, config, ctx, **kwarg
 
 # do not migrate all attributes
 for attr in entry_attrs.keys():
-if attr in attr_blacklist:
+if attr.lower() in attr_blacklist:
 del entry_attrs[attr]
 
 # do not migrate all object classes
-- 
2.1.0

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

Re: [Freeipa-devel] [PATCH] 0030 Fix --{user, group}-ignore-attribute in migration plugin.

2014-11-20 Thread Martin Kosek
On 11/20/2014 09:51 AM, David Kupka wrote:
 https://fedorahosted.org/freeipa/ticket/4620

This should work fine, the change was also already tested by the reporter. Do
we also normalize the user blacklist option so that it works if user passes for
example a CamelCase'd attributes?

Martin

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


Re: [Freeipa-devel] [PATCH] 0030 Fix --{user, group}-ignore-attribute in migration plugin.

2014-11-20 Thread Jan Cholasta

Dne 20.11.2014 v 09:51 David Kupka napsal(a):

https://fedorahosted.org/freeipa/ticket/4620


IMO changing the loop to:

   for attr in attr_blacklist:
   entry_attrs.pop(attr, None)

would be better, because LDAPEntry already handles case insensitivity in 
attribute names.


--
Jan Cholasta

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


Re: [Freeipa-devel] [PATCH] 0030 Fix --{user, group}-ignore-attribute in migration plugin.

2014-11-20 Thread David Kupka

On 11/20/2014 10:03 AM, Jan Cholasta wrote:

Dne 20.11.2014 v 09:51 David Kupka napsal(a):

https://fedorahosted.org/freeipa/ticket/4620


IMO changing the loop to:

for attr in attr_blacklist:
entry_attrs.pop(attr, None)

would be better, because LDAPEntry already handles case insensitivity in
attribute names.


This seems better, thanks.
--
David Kupka
From 94293d14e51507819c4296c52d5d8ce4def9a4c8 Mon Sep 17 00:00:00 2001
From: David Kupka dku...@redhat.com
Date: Wed, 19 Nov 2014 09:57:59 -0500
Subject: [PATCH] Fix --{user,group}-ignore-attribute in migration plugin.

Ignore case in attribute names.

https://fedorahosted.org/freeipa/ticket/4620
---
 ipalib/plugins/migration.py | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/ipalib/plugins/migration.py b/ipalib/plugins/migration.py
index 6b630a464f0be163e82de95afe3a74b22889574b..fa3d512bf1434c7d349713f78c292b481021303a 100644
--- a/ipalib/plugins/migration.py
+++ b/ipalib/plugins/migration.py
@@ -196,9 +196,8 @@ def _pre_migrate_user(ldap, pkey, dn, entry_attrs, failed, config, ctx, **kwargs
 entry_attrs.setdefault('loginshell', default_shell)
 
 # do not migrate all attributes
-for attr in entry_attrs.keys():
-if attr in attr_blacklist:
-del entry_attrs[attr]
+for attr in attr_blacklist:
+entry_attrs.pop(attr, None)
 
 # do not migrate all object classes
 if 'objectclass' in entry_attrs:
@@ -393,9 +392,8 @@ def _pre_migrate_group(ldap, pkey, dn, entry_attrs, failed, config, ctx, **kwarg
 raise ValueError('Schema %s not supported' % schema)
 
 # do not migrate all attributes
-for attr in entry_attrs.keys():
-if attr in attr_blacklist:
-del entry_attrs[attr]
+for attr in attr_blacklist:
+entry_attrs.pop(attr, None)
 
 # do not migrate all object classes
 if 'objectclass' in entry_attrs:
-- 
2.1.0

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

Re: [Freeipa-devel] [PATCH] 0030 Fix --{user, group}-ignore-attribute in migration plugin.

2014-11-20 Thread Martin Basti

On 20/11/14 11:53, David Kupka wrote:

On 11/20/2014 10:03 AM, Jan Cholasta wrote:

Dne 20.11.2014 v 09:51 David Kupka napsal(a):

https://fedorahosted.org/freeipa/ticket/4620


IMO changing the loop to:

for attr in attr_blacklist:
entry_attrs.pop(attr, None)

would be better, because LDAPEntry already handles case insensitivity in
attribute names.


This seems better, thanks.



IMO the same problem is with objectclasses.


# do not migrate all object classes
if 'objectclass' in entry_attrs:
for object_class in kwargs.get('oc_blacklist', []):
try:
entry_attrs['objectclass'].remove(object_class)   # 
this is case sensitive

except ValueError:  # object class not present
pass

Am I right?
Martin^2

--
Martin Basti

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


Re: [Freeipa-devel] [PATCH] 0030 Fix --{user, group}-ignore-attribute in migration plugin.

2014-11-20 Thread Jan Cholasta

Dne 20.11.2014 v 14:51 Martin Basti napsal(a):

On 20/11/14 11:53, David Kupka wrote:

On 11/20/2014 10:03 AM, Jan Cholasta wrote:

Dne 20.11.2014 v 09:51 David Kupka napsal(a):

https://fedorahosted.org/freeipa/ticket/4620


IMO changing the loop to:

for attr in attr_blacklist:
entry_attrs.pop(attr, None)

would be better, because LDAPEntry already handles case insensitivity in
attribute names.


This seems better, thanks.



IMO the same problem is with objectclasses.


 # do not migrate all object classes
 if 'objectclass' in entry_attrs:
 for object_class in kwargs.get('oc_blacklist', []):
 try:
 entry_attrs['objectclass'].remove(object_class)   #
this is case sensitive
 except ValueError:  # object class not present
 pass

Am I right?


Yes. LDAPEntry does not support case insensitivity in this case, 
although I plan to implement it in 4.2.


--
Jan Cholasta

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


Re: [Freeipa-devel] [PATCH] 0030 Fix --{user, group}-ignore-attribute in migration plugin.

2014-11-20 Thread Martin Basti

On 20/11/14 15:25, Jan Cholasta wrote:

Dne 20.11.2014 v 14:51 Martin Basti napsal(a):

On 20/11/14 11:53, David Kupka wrote:

On 11/20/2014 10:03 AM, Jan Cholasta wrote:

Dne 20.11.2014 v 09:51 David Kupka napsal(a):

https://fedorahosted.org/freeipa/ticket/4620


IMO changing the loop to:

for attr in attr_blacklist:
entry_attrs.pop(attr, None)

would be better, because LDAPEntry already handles case 
insensitivity in

attribute names.


This seems better, thanks.



IMO the same problem is with objectclasses.


 # do not migrate all object classes
 if 'objectclass' in entry_attrs:
 for object_class in kwargs.get('oc_blacklist', []):
 try:
entry_attrs['objectclass'].remove(object_class)   #
this is case sensitive
 except ValueError:  # object class not present
 pass

Am I right?


Yes. LDAPEntry does not support case insensitivity in this case, 
although I plan to implement it in 4.2.



objectclasses are normalized to lowercase before, so it is not a issue.

The patch works fine, ACK :-) .

--
Martin Basti

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


Re: [Freeipa-devel] [PATCH] 0030 Fix --{user, group}-ignore-attribute in migration plugin.

2014-11-20 Thread Petr Viktorin

On 11/20/2014 03:35 PM, Martin Basti wrote:

On 20/11/14 15:25, Jan Cholasta wrote:

Dne 20.11.2014 v 14:51 Martin Basti napsal(a):

On 20/11/14 11:53, David Kupka wrote:

On 11/20/2014 10:03 AM, Jan Cholasta wrote:

Dne 20.11.2014 v 09:51 David Kupka napsal(a):

https://fedorahosted.org/freeipa/ticket/4620


IMO changing the loop to:

for attr in attr_blacklist:
entry_attrs.pop(attr, None)

would be better, because LDAPEntry already handles case
insensitivity in
attribute names.


This seems better, thanks.



IMO the same problem is with objectclasses.


 # do not migrate all object classes
 if 'objectclass' in entry_attrs:
 for object_class in kwargs.get('oc_blacklist', []):
 try:
entry_attrs['objectclass'].remove(object_class)   #
this is case sensitive
 except ValueError:  # object class not present
 pass

Am I right?


Yes. LDAPEntry does not support case insensitivity in this case,
although I plan to implement it in 4.2.


objectclasses are normalized to lowercase before, so it is not a issue.

The patch works fine, ACK :-) .



Pushed to:
master: 35dad9684b22819a2c848e7ebb78cfbc438a30e6
ipa-4-1: 8ab85f161513b376c95094ccfe2b60202fe41baa

--
PetrĀ³

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