summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipalib/plugins/f_automount.py57
-rw-r--r--tests/test_xmlrpc/test_automount_plugin.py59
2 files changed, 112 insertions, 4 deletions
diff --git a/ipalib/plugins/f_automount.py b/ipalib/plugins/f_automount.py
index 8de6c5ab9..4c392438d 100644
--- a/ipalib/plugins/f_automount.py
+++ b/ipalib/plugins/f_automount.py
@@ -435,13 +435,13 @@ class automount_showkey(crud.Get):
def output_for_cli(self, textui, result, *args, **options):
# The automount map name associated with this key is available only
# in the dn. Add it as an attribute to display instead.
- if entry and not entry.get('automountmapname'):
- elements = explode_dn(entry.get('dn').lower())
+ if result and not result.get('automountmapname'):
+ elements = explode_dn(result.get('dn').lower())
for e in elements:
(attr, value) = e.split('=',1)
if attr == 'automountmapname':
- entry['automountmapname'] = value
- display_entry(textui, entry)
+ result['automountmapname'] = value
+ display_entry(textui, result)
api.register(automount_showkey)
@@ -508,3 +508,52 @@ class automount_getmaps(frontend.Command):
textui.print_plain('%s: %s' % (k.get('automountinformation'), k.get('automountkey')))
api.register(automount_getmaps)
+
+class automount_addindirectmap(crud.Add):
+ 'Add a new automap indirect mount point.'
+ takes_options = (
+ Param('parentmap?',
+ cli_name='parentmap',
+ default='auto.master',
+ doc='The parent map to connect this to. Default: auto.master'),
+ Param('automountkey',
+ cli_name='key',
+ doc='An entry in an automount map'),
+ Param('description?',
+ doc='A description of the automount map'),
+ )
+
+ def execute(self, mapname, **kw):
+ """
+ Execute the automount-addindirectmap operation.
+
+ Returns the key entry as it will be created in LDAP.
+
+ This function creates 2 LDAP entries. It creates an
+ automountmapname entry and an automountkey entry.
+
+ :param mapname: The map name being added.
+ :param kw['parentmap'] is the top-level map to add this to.
+ defaulting to auto.master
+ :param kw['automountkey'] is the mount point
+ :param kw['description'] is a textual description of this map
+ """
+ mapkw = {}
+ if kw.get('description'):
+ mapkw['description'] = kw.get('description')
+ newmap = api.Command['automount_addmap'](mapname, **mapkw)
+
+ keykw = {'automountkey': kw['automountkey'], 'automountinformation': mapname}
+ if kw.get('description'):
+ keykw['description'] = kw.get('description')
+ newkey = api.Command['automount_addkey'](kw['parentmap'], **keykw)
+
+ return newkey
+ def output_for_cli(self, textui, result, map, **options):
+ """
+ Output result of this command to command line interface.
+ """
+ textui.print_plain("Indirect automount map %s added" % map)
+
+api.register(automount_addindirectmap)
+
diff --git a/tests/test_xmlrpc/test_automount_plugin.py b/tests/test_xmlrpc/test_automount_plugin.py
index 2a9ffc4ea..522ee689a 100644
--- a/tests/test_xmlrpc/test_automount_plugin.py
+++ b/tests/test_xmlrpc/test_automount_plugin.py
@@ -182,3 +182,62 @@ class test_Service(XMLRPC_test):
pass
else:
assert False
+
+class test_Indirect(XMLRPC_test):
+ """
+ Test the `f_automount` plugin Indirect map function.
+ """
+ mapname='auto.home'
+ keyname='/home'
+ parentmap='auto.master'
+ description='Home directories'
+ map_kw={'automountkey': keyname, 'parentmap': parentmap, 'description': description}
+
+ def test_add_indirect(self):
+ """
+ Test adding an indirect map.
+ """
+ res = api.Command['automount_addindirectmap'](self.mapname, **self.map_kw)
+ assert res
+ assert res.get('automountinformation','') == self.mapname
+
+ def test_doshowkey(self):
+ """
+ Test the `xmlrpc.automount_showkey` method.
+ """
+ showkey_kw={'automountmapname': self.parentmap, 'automountkey': self.keyname}
+ res = api.Command['automount_showkey'](**showkey_kw)
+ assert res
+ assert res.get('automountkey','') == self.keyname
+
+ def test_remove_key(self):
+ """
+ Remove the indirect key /home
+ """
+ delkey_kw={'automountmapname': self.parentmap, 'automountkey': self.keyname}
+ res = api.Command['automount_delkey'](**delkey_kw)
+ assert res == True
+
+ # Verify that it is gone
+ try:
+ res = api.Command['automount_showkey'](**delkey_kw)
+ except errors.NotFound:
+ pass
+ else:
+ assert False
+
+ def test_remove_map(self):
+ """
+ Remove the indirect map for auto.home
+ """
+ res = api.Command['automount_delmap'](self.mapname)
+ assert res == True
+
+ # Verify that it is gone
+ try:
+ res = api.Command['automount_showmap'](self.mapname)
+ except errors.NotFound:
+ pass
+ else:
+ assert False
+