commit efe1cd5c890da81b4c93b1de0643ea67c5e4336d
Author: Marc Dequènes (Duck) <Duck@DuckCorp.org>
Date:   Mon Oct 12 22:13:55 2009 +0200

    [evol] improve config #1 (objects+relations config is separated)

diff --git a/bin/shadowwalker b/bin/shadowwalker
index e2edf72..61b5a32 100755
--- a/bin/shadowwalker
+++ b/bin/shadowwalker
@@ -76,9 +76,19 @@ end
 begin
   ActiveLdap::Base.setup_connection(config[:ldap])
 
-  config[:objects].each_pair do |obj_name, obj_data|
-    $ldapctl.load_object(obj_name, obj_data)
+  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)
   end
+
   $ldapctl.load_relations
 rescue ActiveLdap::Error => e
   STDERR.puts _("LDAP connection error: %s") % e.to_s
diff --git a/conf/ldap_shadows/objects/bot.conf b/conf/ldap_shadows/objects/bot.conf
new file mode 100644
index 0000000..ffc10b0
--- /dev/null
+++ b/conf/ldap_shadows/objects/bot.conf
@@ -0,0 +1,9 @@
+mapping:
+  dn_attribute: uid
+  prefix: ''
+  classes: ['bot']
+  sort_by: uid
+presentation:
+  allowed_aspects: ['primary', 'mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
+  hidden_attributes: ['uid']
+  expert_attributes: ['uidNumber', 'gidNumber', 'gecos']
diff --git a/conf/ldap_shadows/objects/domain.conf b/conf/ldap_shadows/objects/domain.conf
new file mode 100644
index 0000000..4080849
--- /dev/null
+++ b/conf/ldap_shadows/objects/domain.conf
@@ -0,0 +1,7 @@
+mapping:
+  dn_attribute: cn
+  prefix: ''
+  classes: ['genericDomain']
+  sort_by: cn
+presentation:
+  allowed_aspects: []
diff --git a/conf/ldap_shadows/objects/entity.conf b/conf/ldap_shadows/objects/entity.conf
new file mode 100644
index 0000000..77d800b
--- /dev/null
+++ b/conf/ldap_shadows/objects/entity.conf
@@ -0,0 +1,21 @@
+mapping:
+  dn_attribute: o
+  prefix: ''
+  classes: ['entity']
+  excluded_classes: ['dcObject']
+  sort_by: o
+presentation:
+  name_attribute: o
+  hidden_attributes: ['founder']
+  associated_relations: ['foundersIndividuals', 'foundersEntities']
+relations:
+  foundersIndividuals:
+    type: :has_many
+    object: individual
+    foreign_key: founder
+    primary_key: dn
+  foundersEntities:
+    type: :has_many
+    object: entity
+    foreign_key: founder
+    primary_key: dn
diff --git a/conf/ldap_shadows/objects/group.conf b/conf/ldap_shadows/objects/group.conf
new file mode 100644
index 0000000..7a377b9
--- /dev/null
+++ b/conf/ldap_shadows/objects/group.conf
@@ -0,0 +1,31 @@
+mapping:
+  dn_attribute: cn
+  prefix: ''
+  classes: ['posixGroup', 'groupOfMembers']
+  sort_by: cn
+presentation:
+  allowed_aspects: []
+  hidden_attributes: ['uniqueMember']
+  expert_attributes: ['gidNumber']
+  associated_relations: ['individualsPrimaryMembers', 'botsPrimaryMembers', 'individualsSecondaryMembers', 'botsSecondaryMembers']
+relations:
+  individualsPrimaryMembers:
+    type: :belongs_to
+    object: individual
+    many: gidNumber
+    foreign_key: gidNumber
+  botsPrimaryMembers:
+    type: :belongs_to
+    object: bot
+    many: gidNumber
+    foreign_key: gidNumber
+  individualsSecondaryMembers:
+    type: :has_many
+    object: individual
+    foreign_key: uniqueMember
+    primary_key: dn
+  botsSecondaryMembers:
+    type: :has_many
+    object: bot
+    foreign_key: uniqueMember
+    primary_key: dn
diff --git a/conf/ldap_shadows/objects/individual.conf b/conf/ldap_shadows/objects/individual.conf
new file mode 100644
index 0000000..bd35d9e
--- /dev/null
+++ b/conf/ldap_shadows/objects/individual.conf
@@ -0,0 +1,9 @@
+mapping:
+  dn_attribute: uid
+  prefix: ''
+  classes: ['individual']
+  sort_by: uid
+presentation:
+  allowed_aspects: ['primary', 'mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
+  hidden_attributes: ['uid']
+  expert_attributes: ['uidNumber', 'gidNumber', 'gecos']
diff --git a/conf/ldap_shadows/objects/secondary_account.conf b/conf/ldap_shadows/objects/secondary_account.conf
new file mode 100644
index 0000000..c7bb48a
--- /dev/null
+++ b/conf/ldap_shadows/objects/secondary_account.conf
@@ -0,0 +1,7 @@
+mapping:
+  dn_attribute: uid
+  prefix: ''
+  classes: ['secondaryAccount']
+  sort_by: uid
+presentation:
+  allowed_aspects: ['mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
diff --git a/conf/ldap_shadows/objects/system_account.conf b/conf/ldap_shadows/objects/system_account.conf
new file mode 100644
index 0000000..3cf103d
--- /dev/null
+++ b/conf/ldap_shadows/objects/system_account.conf
@@ -0,0 +1,7 @@
+mapping:
+  dn_attribute: uid
+  prefix: ''
+  classes: ['systemAccount']
+  sort_by: uid
+presentation:
+  allowed_aspects: ['mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
diff --git a/conf/ldap_shadows/objects/unit.conf b/conf/ldap_shadows/objects/unit.conf
new file mode 100644
index 0000000..bf03083
--- /dev/null
+++ b/conf/ldap_shadows/objects/unit.conf
@@ -0,0 +1,7 @@
+mapping:
+  dn_attribute: ou
+  prefix: ''
+  classes: ['organizationalUnit']
+  # no sort_by means sort by DN
+presentation:
+  name_attribute: dn
diff --git a/conf/ldap_shadows/test.conf b/conf/ldap_shadows/test.conf
index 8945263..5058aaf 100644
--- a/conf/ldap_shadows/test.conf
+++ b/conf/ldap_shadows/test.conf
@@ -2,113 +2,6 @@
 presentation:
   hidden_attributes: ['objectClass', 'userPassword', 'hasSubordinates', 'entryUUID', 'entryDN', 'structuralObjectClass', 'subschemaSubentry']
   tree_objects: ['unit', 'entity']
-objects:
-  bot:
-    mapping:
-      dn_attribute: uid
-      prefix: ''
-      classes: ['bot']
-      sort_by: uid
-    presentation:
-      allowed_aspects: ['primary', 'mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
-      hidden_attributes: ['uid']
-      expert_attributes: ['uidNumber', 'gidNumber', 'gecos']
-  individual:
-    mapping:
-      dn_attribute: uid
-      prefix: ''
-      classes: ['individual']
-      sort_by: uid
-    presentation:
-      allowed_aspects: ['primary', 'mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
-      hidden_attributes: ['uid']
-      expert_attributes: ['uidNumber', 'gidNumber', 'gecos']
-  group:
-    mapping:
-      dn_attribute: cn
-      prefix: ''
-      classes: ['posixGroup', 'groupOfMembers']
-      sort_by: cn
-    presentation:
-      allowed_aspects: []
-      hidden_attributes: ['uniqueMember']
-      expert_attributes: ['gidNumber']
-      associated_relations: ['individualsPrimaryMembers', 'botsPrimaryMembers', 'individualsSecondaryMembers', 'botsSecondaryMembers']
-    relations:
-      individualsPrimaryMembers:
-        type: :belongs_to
-        object: individual
-        many: gidNumber
-        foreign_key: gidNumber
-      botsPrimaryMembers:
-        type: :belongs_to
-        object: bot
-        many: gidNumber
-        foreign_key: gidNumber
-      individualsSecondaryMembers:
-        type: :has_many
-        object: individual
-        foreign_key: uniqueMember
-        primary_key: dn
-      botsSecondaryMembers:
-        type: :has_many
-        object: bot
-        foreign_key: uniqueMember
-        primary_key: dn
-  entity:
-    mapping:
-      dn_attribute: o
-      prefix: ''
-      classes: ['entity']
-      excluded_classes: ['dcObject']
-      sort_by: o
-    presentation:
-      name_attribute: o
-      hidden_attributes: ['founder']
-      associated_relations: ['foundersIndividuals', 'foundersEntities']
-    relations:
-      foundersIndividuals:
-        type: :has_many
-        object: individual
-        foreign_key: founder
-        primary_key: dn
-      foundersEntities:
-        type: :has_many
-        object: entity
-        foreign_key: founder
-        primary_key: dn
-  unit:
-    mapping:
-      dn_attribute: ou
-      prefix: ''
-      classes: ['organizationalUnit']
-      # no sort_by means sort by DN
-    presentation:
-      name_attribute: dn
-  secondary_account:
-    mapping:
-      dn_attribute: uid
-      prefix: ''
-      classes: ['secondaryAccount']
-      sort_by: uid
-    presentation:
-      allowed_aspects: ['mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
-  system_account:
-    mapping:
-      dn_attribute: uid
-      prefix: ''
-      classes: ['systemAccount']
-      sort_by: uid
-    presentation:
-      allowed_aspects: ['mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
-  domain:
-    mapping:
-      dn_attribute: cn
-      prefix: ''
-      classes: ['genericDomain']
-      sort_by: cn
-    presentation:
-      allowed_aspects: []
 aspects:
   mail:
     mapping:
