Re: [Freeipa-devel] [PATCH] 112 Fix automountlocation-import conflicts

2011-08-19 Thread Rob Crittenden

Martin Kosek wrote:

Do not fail import operation with DuplicateEntry when imported
maps/keys conflict with maps/keys pre-created by
automountlocation-add command. Currently, this applies for map
'auto.direct' and key '/-'.

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


ack.

Rebased and pushed to master and ipa-2-1

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


[Freeipa-devel] [PATCH] 112 Fix automountlocation-import conflicts

2011-08-16 Thread Martin Kosek
Do not fail import operation with DuplicateEntry when imported
maps/keys conflict with maps/keys pre-created by
automountlocation-add command. Currently, this applies for map
'auto.direct' and key '/-'.

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

>From 543a75c221a0da180e299c0a377e746b94ed052e Mon Sep 17 00:00:00 2001
From: Martin Kosek 
Date: Tue, 16 Aug 2011 16:20:09 +0200
Subject: [PATCH] Fix automountlocation-import conflicts

Do not fail import operation with DuplicateEntry when imported
maps/keys conflict with maps/keys pre-created by
automountlocation-add command. Currently, this applies for map
'auto.direct' and key '/-'.

https://fedorahosted.org/freeipa/ticket/1551
---
 ipalib/plugins/automount.py |   16 ++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/ipalib/plugins/automount.py b/ipalib/plugins/automount.py
index e0408033d46964b7dd6b28e6d92bb8a523b517eb..e0470726e691a84346a92115d917b282702562bf 100644
--- a/ipalib/plugins/automount.py
+++ b/ipalib/plugins/automount.py
@@ -177,6 +177,8 @@ from ipalib import _, ngettext
 import ldap as _ldap
 import os
 
+DEFAULT_MAPS = (u'auto.direct', )
+DEFAULT_KEYS = (u'/-', )
 
 class automountlocation(LDAPObject):
 """
@@ -212,6 +214,10 @@ class automountlocation_add(LDAPCreate):
 def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
 # create auto.master for the new location
 self.api.Command['automountmap_add'](keys[-1], u'auto.master')
+
+# add additional pre-created maps and keys
+# IMPORTANT: add pre-created maps/keys to DEFAULT_MAPS/DEFAULT_KEYS
+# so that they do not cause conflicts during import operation
 self.api.Command['automountmap_add_indirect'](
 keys[-1], u'auto.direct', key=u'/-'
 )
@@ -386,7 +392,10 @@ class automountlocation_import(LDAPQuery):
 automountinformation=unicode(' '.join(am[1:])))
 result['keys'].append([am[0], u'auto.master'])
 except errors.DuplicateEntry, e:
-if options.get('continue', False):
+if unicode(am[0]) in DEFAULT_KEYS:
+# ignore conflict when the key was pre-created by the framework
+pass
+elif options.get('continue', False):
 result['duplicatekeys'].append(am[0])
 pass
 else:
@@ -397,7 +406,10 @@ class automountlocation_import(LDAPQuery):
 api.Command['automountmap_add'](args[0], unicode(am[1]))
 result['maps'].append(am[1])
 except errors.DuplicateEntry, e:
-if options.get('continue', False):
+if unicode(am[1]) in DEFAULT_MAPS:
+# ignore conflict when the map was pre-created by the framework
+pass
+elif options.get('continue', False):
 result['duplicatemaps'].append(am[0])
 pass
 else:
-- 
1.7.6

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