summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2011-08-16 16:20:09 +0200
committerRob Crittenden <rcritten@redhat.com>2011-08-18 22:49:09 -0400
commit2e9d614cabfb556aedb6ca805593dfcf3fa811cd (patch)
treed3821fed91f2a54280de19b9bc13dae9dfea961e /ipalib/plugins
parent24d3d0269391e491492dd15bc1de820ea69904b6 (diff)
downloadfreeipa-2e9d614cabfb556aedb6ca805593dfcf3fa811cd.zip
freeipa-2e9d614cabfb556aedb6ca805593dfcf3fa811cd.tar.gz
freeipa-2e9d614cabfb556aedb6ca805593dfcf3fa811cd.tar.xz
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
Diffstat (limited to 'ipalib/plugins')
-rw-r--r--ipalib/plugins/automount.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/ipalib/plugins/automount.py b/ipalib/plugins/automount.py
index b27df4f..6aa3afd 100644
--- a/ipalib/plugins/automount.py
+++ b/ipalib/plugins/automount.py
@@ -178,6 +178,8 @@ import ldap as _ldap
import os
DIRECT_MAP_KEY = u'/-'
+DEFAULT_MAPS = (u'auto.direct', )
+DEFAULT_KEYS = (u'/-', )
class automountlocation(LDAPObject):
"""
@@ -213,6 +215,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=DIRECT_MAP_KEY
)
@@ -387,7 +393,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:
@@ -398,7 +407,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: