Fix the automountlocation-tofiles command and add some labels

This commit is contained in:
Rob Crittenden 2010-02-12 16:27:52 -05:00 committed by Jason Gerard DeRose
parent a63224f4dc
commit 99dcf9d4f9

View File

@ -107,6 +107,7 @@ class automountlocation(LDAPObject):
takes_params = ( takes_params = (
Str('cn', Str('cn',
cli_name='location', cli_name='location',
label='Location',
doc='automount location name', doc='automount location name',
primary_key=True, primary_key=True,
), ),
@ -162,37 +163,44 @@ class automountlocation_tofiles(LDAPQuery):
ldap = self.obj.backend ldap = self.obj.backend
maps = [] maps = []
(maps, truncated) = self.api.Command['automountkey_find']( result = self.api.Command['automountkey_find'](
cn=args[0], automountmapname=u'auto.master' cn=args[0], automountmapname=u'auto.master'
) )
truncated = result['truncated']
maps = result['result']
# maps, truncated
# TODO: handle truncated results # TODO: handle truncated results
# ?use ldap.find_entries instead of automountkey_find? # ?use ldap.find_entries instead of automountkey_find?
keys = {} keys = {}
for (dn, m) in maps: for m in maps:
info = m['automountinformation'][0] info = m['automountinformation'][0]
(keys[info], truncated) = self.api.Command['automountkey_find']( result = self.api.Command['automountkey_find'](
cn=args[0], automountmapname=info cn=args[0], automountmapname=info
) )
truncated = result['truncated']
keys[info] = result['result']
# TODO: handle truncated results, same as above # TODO: handle truncated results, same as above
return (maps, keys) return dict(result=dict(maps=maps, keys=keys))
def output_for_cli(self, textui, result, *keys, **options): def output_for_cli(self, textui, result, *keys, **options):
(maps, keys) = result maps = result['result']['maps']
keys = result['result']['keys']
textui.print_plain('/etc/auto.master:') textui.print_plain('/etc/auto.master:')
for (dn, m) in maps: for m in maps:
textui.print_plain( textui.print_plain(
'%s\t/etc/%s' % ( '%s\t/etc/%s' % (
m['automountkey'][0], m['automountinformation'][0] m['automountkey'][0], m['automountinformation'][0]
) )
) )
for (dn, m) in maps: for m in maps:
info = m['automountinformation'][0] info = m['automountinformation'][0]
textui.print_plain('---------------------------') textui.print_plain('---------------------------')
textui.print_plain('/etc/%s:' % info) textui.print_plain('/etc/%s:' % info)
for (dn, k) in keys[info]: for k in keys[info]:
textui.print_plain( textui.print_plain(
'%s\t%s' % ( '%s\t%s' % (
k['automountkey'][0], k['automountinformation'][0] k['automountkey'][0], k['automountinformation'][0]
@ -219,11 +227,13 @@ class automountmap(LDAPObject):
takes_params = ( takes_params = (
Str('automountmapname', Str('automountmapname',
cli_name='map', cli_name='map',
label='Map',
primary_key=True, primary_key=True,
doc='automount map name', doc='automount map name',
), ),
Str('description?', Str('description?',
cli_name='desc', cli_name='desc',
label='Description',
doc='description', doc='description',
), ),
) )