Project

General

Profile

« Previous | Next » 

Revision ef24d7f9

Added by Marc Dequènes almost 15 years ago

  • ID ef24d7f968b3934a5f778891ab431824ff4fc450

[evol] improve config #2 (aspects config is separated)

View differences:

bin/shadowwalker
cmdparser.add_command(CmdParse::VersionCommand.new)
def load_config_components(type)
c_config_dir = File.join(LdapShadows::Config::CFG_DIR, type)
c_config_pattern = File.join(c_config_dir, "**", "*.conf")
Dir.glob(c_config_pattern).each do |f|
next if f[0..0] == "."
c_name = File.basename(f).sub(".conf", "").to_sym
c_config = YAML.load(IO.read(f))
c_config.recursive_symbolize_keys!
yield(c_name, c_config)
end
end
$ldapctl = Controller.new
$ldapctl.set_global_config(config[:presentation])
config[:aspects].each_pair do |aspect_name, aspect_data|
$ldapctl.set_aspect(aspect_name, aspect_data)
load_config_components("aspects") do |c_name, c_config|
$ldapctl.set_aspect(c_name, c_config)
end
begin
ActiveLdap::Base.setup_connection(config[:ldap])
obj_config_dir = File.join(LdapShadows::Config::CFG_DIR, "objects")
obj_config_pattern = File.join(obj_config_dir, "**", "*.conf")
Dir.glob(obj_config_pattern).each do |f|
next if f[0..0] == "."
obj_name = File.basename(f).sub(".conf", "")
obj_config = YAML.load(IO.read(f))
obj_config.recursive_symbolize_keys!
$ldapctl.load_object(obj_name, obj_config)
load_config_components("objects") do |c_name, c_config|
$ldapctl.load_object(c_name, c_config)
end
$ldapctl.load_relations
conf/ldap_shadows/aspects/fs.conf
mapping:
classes: ['fsUser']
presentation:
associated_relations: ['primaryGroup', 'secondaryGroups']
relations:
primaryGroup:
type: :belongs_to
object: group
foreign_key: gidNumber
primary_key: gidNumber
secondaryGroups:
type: :belongs_to
object: group
many: uniqueMember
foreign_key: dn
conf/ldap_shadows/aspects/ftp.conf
mapping:
classes: ['ftpUser']
depend_aspects: ['primary', 'fs']
presentation:
relations:
conf/ldap_shadows/aspects/jabber.conf
mapping:
classes: ['jabberUser']
presentation:
relations:
conf/ldap_shadows/aspects/mail.conf
mapping:
classes: ['emailUser']
presentation:
relations:
conf/ldap_shadows/aspects/primary.conf
mapping:
classes: ['primaryAccount']
presentation:
associated_attributes: ['uid']
relations:
conf/ldap_shadows/aspects/shell.conf
mapping:
classes: ['shellUser']
depend_aspects: ['primary', 'fs']
presentation:
associated_attributes: ['loginShell']
relations:
conf/ldap_shadows/aspects/web.conf
mapping:
classes: ['webUser']
depend_aspects: ['primary']
presentation:
relations:
conf/ldap_shadows/test.conf
presentation:
hidden_attributes: ['objectClass', 'userPassword', 'hasSubordinates', 'entryUUID', 'entryDN', 'structuralObjectClass', 'subschemaSubentry']
tree_objects: ['unit', 'entity']
aspects:
mail:
mapping:
classes: ['emailUser']
presentation:
relations:
fs:
mapping:
classes: ['fsUser']
presentation:
associated_relations: ['primaryGroup', 'secondaryGroups']
relations:
primaryGroup:
type: :belongs_to
object: group
foreign_key: gidNumber
primary_key: gidNumber
secondaryGroups:
type: :belongs_to
object: group
many: uniqueMember
foreign_key: dn
shell:
mapping:
classes: ['shellUser']
depend_aspects: ['primary', 'fs']
presentation:
associated_attributes: ['loginShell']
relations:
ftp:
mapping:
classes: ['ftpUser']
depend_aspects: ['primary', 'fs']
presentation:
relations:
web:
mapping:
classes: ['webUser']
depend_aspects: ['primary']
presentation:
relations:
jabber:
mapping:
classes: ['jabberUser']
presentation:
relations:
primary:
mapping:
classes: ['primaryAccount']
presentation:
associated_attributes: ['uid']
relations:

Also available in: Unified diff