Add autmount-specific location and default entries

This commit is contained in:
Rob Crittenden 2008-11-14 18:04:57 -05:00
parent f8f4058014
commit c513743e7c
4 changed files with 33 additions and 10 deletions

View File

@ -117,7 +117,7 @@ class ldap(CrudBackend):
return object_type
def find_entry_dn(self, key_attribute, primary_key, object_type=None):
def find_entry_dn(self, key_attribute, primary_key, object_type=None, base=None):
"""
Find an existing entry's dn from an attribute
"""
@ -133,7 +133,10 @@ class ldap(CrudBackend):
self.dn.escape_dn_chars(primary_key)
)
search_base = "%s, %s" % (self.api.env.container_accounts, self.api.env.basedn)
if not base:
base = self.api.env.container_accounts
search_base = "%s, %s" % (base, self.api.env.basedn)
entry = servercore.get_sub_entry(search_base, search_filter, ['dn', 'objectclass'])

View File

@ -33,3 +33,22 @@ add:objectClasses:
DESC 'Automount information' SUP top STRUCTURAL
MUST ( automountKey $ automountInformation ) MAY description
X-ORIGIN 'RFC 2307bis' )
# Add the default automount entries
dn: cn=automount,$SUFFIX
add:objectClass: nsContainer
add:cn: automount
dn: automountmapname=auto.master,cn=automount,$SUFFIX
add:objectClass: automountMap
add:automountMapName: auto.master
dn: automountkey=/-,automountmapname=auto.master,cn=automount,$SUFFIX
add:objectClass: automount
add:automountKey: '/-'
add:automountInformation: auto.direct
dn: automountmapname=auto.direct,cn=automount,$SUFFIX
add:objectClass: automountMap
add:automountMapName: auto.direct

View File

@ -72,6 +72,7 @@ DEFAULT_CONFIG = (
('container_service', 'cn=services,cn=accounts'),
('container_host', 'cn=computers,cn=accounts'),
('container_hostgroup', 'cn=hostgroups,cn=accounts'),
('container_automount', 'cn=automount'),
# Ports, hosts, and URIs:
('lite_xmlrpc_port', 8888),

View File

@ -53,7 +53,7 @@ def make_automount_dn(mapname):
import ldap
return 'automountmapname=%s,%s,%s' % (
ldap.dn.escape_dn_chars(mapname),
api.env.container_accounts,
api.env.container_automount,
api.env.basedn,
)
@ -133,7 +133,7 @@ class automount_addkey(crud.Add):
ldap = self.api.Backend.ldap
# use find_entry_dn instead of make_automap_dn so we can confirm that
# the map exists
map_dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap")
map_dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap", api.env.container_automount)
kw['dn'] = "automountkey=%s,%s" % (kw['automountkey'], map_dn)
kw['objectClass'] = ['automount']
@ -193,7 +193,7 @@ class automount_delkey(crud.Del):
:param kw: "key" the key to be removed
"""
ldap = self.api.Backend.ldap
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap")
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap", api.env.container_automount)
keys = api.Command['automount_getkeys'](mapname)
keydn = None
keyname = kw.get('automountkey').lower()
@ -235,7 +235,7 @@ class automount_modmap(crud.Mod):
assert 'automountmapname' not in kw
assert 'dn' not in kw
ldap = self.api.Backend.ldap
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap")
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap", api.env.container_automount)
return ldap.update(dn, **kw)
def output_for_cli(self, ret):
@ -274,7 +274,7 @@ class automount_modkey(crud.Mod):
keyname = kw.get('automountkey').lower()
del kw['automountkey']
ldap = self.api.Backend.ldap
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap")
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap", api.env.container_automount)
keys = api.Command['automount_getkeys'](mapname)
keydn = None
if keys:
@ -388,7 +388,7 @@ class automount_showmap(crud.Get):
:param kw: "all" set to True = return all attributes
"""
ldap = self.api.Backend.ldap
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap")
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap", api.env.container_automount)
# FIXME: should kw contain the list of attributes to display?
if kw.get('all', False):
return ldap.retrieve(dn)
@ -420,7 +420,7 @@ class automount_showkey(crud.Get):
:param kw: "all" set to True = return all attributes
"""
ldap = self.api.Backend.ldap
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap")
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap", api.env.container_automount)
keys = api.Command['automount_getkeys'](mapname)
keyname = kw.get('automountkey').lower()
keydn = None
@ -468,7 +468,7 @@ class automount_getkeys(frontend.Command):
:param mapname: Retrieve all keys for this mapname
"""
ldap = self.api.Backend.ldap
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap")
dn = ldap.find_entry_dn("automountmapname", mapname, "automountmap", api.env.container_automount)
try:
keys = ldap.get_one_entry(dn, 'objectclass=*', ['automountkey'])
except errors.NotFound: