commit ef24d7f968b3934a5f778891ab431824ff4fc450
Author: Marc Dequènes (Duck) <Duck@DuckCorp.org>
Date:   Mon Oct 12 23:01:47 2009 +0200

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

diff --git a/bin/shadowwalker b/bin/shadowwalker
index 61b5a32..dc49e26 100755
--- a/bin/shadowwalker
+++ b/bin/shadowwalker
@@ -68,25 +68,31 @@ cmdparser.add_command(CmdParse::HelpCommand.new)
 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
diff --git a/conf/ldap_shadows/aspects/fs.conf b/conf/ldap_shadows/aspects/fs.conf
new file mode 100644
index 0000000..49f4a1e
--- /dev/null
+++ b/conf/ldap_shadows/aspects/fs.conf
@@ -0,0 +1,15 @@
+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
diff --git a/conf/ldap_shadows/aspects/ftp.conf b/conf/ldap_shadows/aspects/ftp.conf
new file mode 100644
index 0000000..a839e44
--- /dev/null
+++ b/conf/ldap_shadows/aspects/ftp.conf
@@ -0,0 +1,5 @@
+mapping:
+  classes: ['ftpUser']
+  depend_aspects: ['primary', 'fs']
+presentation:
+relations:
diff --git a/conf/ldap_shadows/aspects/jabber.conf b/conf/ldap_shadows/aspects/jabber.conf
new file mode 100644
index 0000000..7124b08
--- /dev/null
+++ b/conf/ldap_shadows/aspects/jabber.conf
@@ -0,0 +1,4 @@
+mapping:
+  classes: ['jabberUser']
+presentation:
+relations:
diff --git a/conf/ldap_shadows/aspects/mail.conf b/conf/ldap_shadows/aspects/mail.conf
new file mode 100644
index 0000000..f70e952
--- /dev/null
+++ b/conf/ldap_shadows/aspects/mail.conf
@@ -0,0 +1,4 @@
+mapping:
+  classes: ['emailUser']
+presentation:
+relations:
diff --git a/conf/ldap_shadows/aspects/primary.conf b/conf/ldap_shadows/aspects/primary.conf
new file mode 100644
index 0000000..3e737d7
--- /dev/null
+++ b/conf/ldap_shadows/aspects/primary.conf
@@ -0,0 +1,5 @@
+mapping:
+  classes: ['primaryAccount']
+presentation:
+  associated_attributes: ['uid']
+relations:
diff --git a/conf/ldap_shadows/aspects/shell.conf b/conf/ldap_shadows/aspects/shell.conf
new file mode 100644
index 0000000..e771450
--- /dev/null
+++ b/conf/ldap_shadows/aspects/shell.conf
@@ -0,0 +1,6 @@
+mapping:
+  classes: ['shellUser']
+  depend_aspects: ['primary', 'fs']
+presentation:
+  associated_attributes: ['loginShell']
+relations:
diff --git a/conf/ldap_shadows/aspects/web.conf b/conf/ldap_shadows/aspects/web.conf
new file mode 100644
index 0000000..19cb38b
--- /dev/null
+++ b/conf/ldap_shadows/aspects/web.conf
@@ -0,0 +1,5 @@
+mapping:
+  classes: ['webUser']
+  depend_aspects: ['primary']
+presentation:
+relations:
diff --git a/conf/ldap_shadows/test.conf b/conf/ldap_shadows/test.conf
index 5058aaf..6f9d97b 100644
--- a/conf/ldap_shadows/test.conf
+++ b/conf/ldap_shadows/test.conf
@@ -2,55 +2,3 @@
 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:
