Revision 428fdd46
Added by Marc Dequènes about 15 years ago
- ID 428fdd46a8f2ab849d47b17123cf6413d6cbfacc
conf/ldap_shadows/shadows/MilkyPond/aspects/fs.conf | ||
---|---|---|
---
|
||
mapping:
|
||
classes: ['fsUser']
|
||
presentation:
|
||
associated_relations: ['primaryGroup', 'secondaryGroups']
|
||
relations:
|
||
primaryGroup:
|
conf/ldap_shadows/shadows/MilkyPond/aspects/primary.conf | ||
---|---|---|
---
|
||
mapping:
|
||
classes: ['primaryAccount']
|
||
presentation:
|
||
associated_attributes: ['uid']
|
conf/ldap_shadows/shadows/MilkyPond/aspects/shell.conf | ||
---|---|---|
mapping:
|
||
classes: ['shellUser']
|
||
depend_aspects: ['primary', 'fs']
|
||
presentation:
|
||
associated_attributes: ['loginShell']
|
conf/ldap_shadows/shadows/MilkyPond/objects/bot.conf | ||
---|---|---|
prefix: ''
|
||
classes: ['bot']
|
||
sort_by: uid
|
||
possible_aspects: ['primary', 'mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
|
||
presentation:
|
||
allowed_aspects: ['primary', 'mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
|
||
hidden_attributes: ['uid']
|
||
expert_attributes: ['uidNumber', 'gidNumber', 'gecos']
|
conf/ldap_shadows/shadows/MilkyPond/objects/entity.conf | ||
---|---|---|
classes: ['entity']
|
||
excluded_classes: ['dcObject']
|
||
sort_by: o
|
||
associated_relations: ['foundersIndividuals', 'foundersEntities']
|
||
presentation:
|
||
name_attribute: o
|
||
hidden_attributes: ['founder']
|
||
associated_relations: ['foundersIndividuals', 'foundersEntities']
|
||
relations:
|
||
foundersIndividuals:
|
||
type: has_many
|
conf/ldap_shadows/shadows/MilkyPond/objects/group.conf | ||
---|---|---|
prefix: ''
|
||
classes: ['posixGroup', 'groupOfMembers']
|
||
sort_by: cn
|
||
associated_relations: ['individualsPrimaryMembers', 'botsPrimaryMembers', 'individualsSecondaryMembers', 'botsSecondaryMembers']
|
||
presentation:
|
||
hidden_attributes: ['uniqueMember']
|
||
expert_attributes: ['gidNumber']
|
||
associated_relations: ['individualsPrimaryMembers', 'botsPrimaryMembers', 'individualsSecondaryMembers', 'botsSecondaryMembers']
|
||
relations:
|
||
individualsPrimaryMembers:
|
||
type: belongs_to
|
conf/ldap_shadows/shadows/MilkyPond/objects/individual.conf | ||
---|---|---|
prefix: ''
|
||
classes: ['individual']
|
||
sort_by: uid
|
||
possible_aspects: ['primary', 'mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
|
||
presentation:
|
||
allowed_aspects: ['primary', 'mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
|
||
hidden_attributes: ['uid']
|
||
expert_attributes: ['uidNumber', 'gidNumber', 'gecos']
|
conf/ldap_shadows/shadows/MilkyPond/objects/secondary_account.conf | ||
---|---|---|
prefix: ''
|
||
classes: ['secondaryAccount']
|
||
sort_by: uid
|
||
presentation:
|
||
allowed_aspects: ['mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
|
||
possible_aspects: ['mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
|
conf/ldap_shadows/shadows/MilkyPond/objects/system_account.conf | ||
---|---|---|
prefix: ''
|
||
classes: ['systemAccount']
|
||
sort_by: uid
|
||
presentation:
|
||
allowed_aspects: ['mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
|
||
possible_aspects: ['mail', 'fs', 'shell', 'ftp', 'web', 'jabber']
|
||
presentation: {}
|
data/ldap_shadows/default_config/aspect.yaml | ||
---|---|---|
mapping:
|
||
classes: []
|
||
depend_aspects: []
|
||
presentation:
|
||
associated_relations: []
|
||
associated_attributes: []
|
||
associate_unclaimed_attributes: false
|
||
associated_relations: []
|
||
relations: {}
|
||
plugin: {}
|
data/ldap_shadows/default_config/object.yaml | ||
---|---|---|
---
|
||
mapping: {}
|
||
mapping:
|
||
possible_aspects: []
|
||
associated_relations: []
|
||
associated_attributes: []
|
||
presentation:
|
||
name_attribute:
|
||
allowed_aspects: []
|
||
associated_attributes: []
|
||
hidden_attributes: []
|
||
expert_attributes: []
|
||
associated_relations: []
|
||
relations: {}
|
||
plugin: {}
|
data/ldap_shadows/schema/aspect.yaml | ||
---|---|---|
type: seq
|
||
sequence:
|
||
- type: str
|
||
"presentation":
|
||
type: map
|
||
mapping:
|
||
"associated_attributes":
|
||
"associated_relations":
|
||
type: seq
|
||
sequence:
|
||
- type: str
|
||
"associate_unclaimed_attributes": {type: bool}
|
||
"associated_relations":
|
||
"associated_attributes":
|
||
type: seq
|
||
sequence:
|
||
- type: str
|
||
"associate_unclaimed_attributes": {type: bool}
|
||
"relations":
|
||
type: map
|
||
mapping:
|
data/ldap_shadows/schema/object.yaml | ||
---|---|---|
required: true
|
||
name: ObjectMapping
|
||
mapping:
|
||
"possible_aspects":
|
||
type: seq
|
||
sequence:
|
||
- type: str
|
||
=: {type: any}
|
||
"presentation":
|
||
type: map
|
||
mapping:
|
||
"name_attribute": {type: str}
|
||
"allowed_aspects":
|
||
type: seq
|
||
sequence:
|
||
- type: str
|
||
"hidden_attributes":
|
||
type: seq
|
||
sequence:
|
lib/ldap_shadows/config.rb | ||
---|---|---|
@shadows[shadow_name]
|
||
end
|
||
|
||
def parse(def_name, type, def_data_raw, validate = true)
|
||
def parse(def_name, type, def_data_raw, validate = true, extra_data = nil)
|
||
schema = load_schema(type)
|
||
|
||
if validate
|
||
... | ... | |
when 'aspect'
|
||
AspectValidator
|
||
else
|
||
Kwalify::Validator
|
||
LdapShadowsValidator
|
||
end
|
||
validator = validator_klass.new(schema)
|
||
validator.extra_data = extra_data
|
||
else
|
||
validator = nil
|
||
end
|
||
... | ... | |
end
|
||
|
||
class LdapShadowsValidator < Kwalify::Validator
|
||
attr_accessor :extra_data
|
||
|
||
## hook method called by Validator#validate()
|
||
def validate_hook(value, rule, path, errors)
|
||
msg_list = []
|
||
... | ... | |
end
|
||
end
|
||
|
||
def validate_hook_in(value, rule, path, msg_list)
|
||
end
|
||
|
||
def validate_hook_relation(value, rule, path, msg_list)
|
||
extra_params = [:type, :object]
|
||
|
||
... | ... | |
case rule.name
|
||
when 'ObjectMapping'
|
||
ne_params = value.keys.collect{|k| k.to_sym } -
|
||
ActiveLdap::Base::VALID_LDAP_MAPPING_OPTIONS
|
||
ActiveLdap::Base::VALID_LDAP_MAPPING_OPTIONS -
|
||
@extra_data[:default_parameters][:mapping].keys
|
||
unless ne_params.empty?
|
||
msg_list << _("nonexisting object mapping parameters (%s)") % ne_params.join(", ")
|
||
end
|
lib/ldap_shadows/elements/object.rb | ||
---|---|---|
def self.cast
|
||
super
|
||
|
||
ldap_mapping self.parameters[:mapping]
|
||
ldap_mapping self.parameters[:mapping].reject {|key, val| self.default_parameters[:mapping].keys.include?(key)}
|
||
end
|
||
|
||
def self.cast_relations
|
||
... | ... | |
end
|
||
|
||
def relations
|
||
rel_list = self.class.parameters[:presentation][:associated_relations]
|
||
rel_list = self.class.parameters[:mapping][:associated_relations]
|
||
|
||
aspects.values.each do |aspect|
|
||
rel_list += aspect.parameters[:presentation][:associated_relations]
|
||
rel_list += aspect.parameters[:mapping][:associated_relations]
|
||
end
|
||
|
||
rel_list & possible_relations
|
||
end
|
||
|
||
def self.possible_aspects
|
||
self.parameters[:presentation][:allowed_aspects].sort
|
||
self.parameters[:mapping][:possible_aspects].sort
|
||
end
|
||
|
||
def aspects
|
||
... | ... | |
self.aspects.values.each do |aspect|
|
||
aspect_data = aspect.parameters
|
||
|
||
unless aspect_data[:presentation][:associated_attributes].empty?
|
||
taken_attr_list = aspect_data[:presentation][:associated_attributes] & (attr_list + ignored_attrs)
|
||
unless aspect_data[:mapping][:associated_attributes].empty?
|
||
taken_attr_list = aspect_data[:mapping][:associated_attributes] & (attr_list + ignored_attrs)
|
||
unless taken_attr_list.empty?
|
||
obj_aspects[aspect.handle] ||= {}
|
||
obj_aspects[aspect.handle].merge!(fetch_attributes_data(taken_attr_list, expert_attributes, admin_attributes))
|
||
... | ... | |
end
|
||
end
|
||
|
||
unless aspect_data[:presentation][:associated_relations].empty?
|
||
taken_rel_list = aspect_data[:presentation][:associated_relations] & rel_list
|
||
unless aspect_data[:mapping][:associated_relations].empty?
|
||
taken_rel_list = aspect_data[:mapping][:associated_relations] & rel_list
|
||
unless taken_rel_list.empty?
|
||
obj_aspects[aspect.handle] ||= {}
|
||
obj_aspects[aspect.handle].merge!(fetch_relations_data(taken_rel_list, expert_attributes))
|
||
... | ... | |
|
||
# manage general attributes
|
||
obj_info = {}
|
||
if self.class.parameters[:presentation][:associate_unclaimed_attributes]
|
||
if self.class.parameters[:mapping][:associate_unclaimed_attributes]
|
||
taken_attr_list = attr_list
|
||
else
|
||
taken_attr_list = admin_attributes
|
||
taken_attr_list += self.class.parameters[:presentation][:associated_attributes]
|
||
taken_attr_list += self.class.parameters[:mapping][:associated_attributes]
|
||
taken_attr_list += self.class.possible_attributes
|
||
end
|
||
taken_attr_list = taken_attr_list.uniq & attr_list
|
||
... | ... | |
attr_list -= taken_attr_list
|
||
|
||
# manage general relations
|
||
if self.class.parameters[:presentation][:associated_relations]
|
||
taken_rel_list = self.class.parameters[:presentation][:associated_relations] & rel_list
|
||
if self.class.parameters[:mapping][:associated_relations]
|
||
taken_rel_list = self.class.parameters[:mapping][:associated_relations] & rel_list
|
||
unless taken_rel_list.empty?
|
||
obj_info.merge!(fetch_relations_data(taken_rel_list, expert_attributes))
|
||
rel_list -= taken_rel_list
|
lib/ldap_shadows/shadow.rb | ||
---|---|---|
raise PreProcessingError, _("Element '%s' for model '%s' as already been defined") % [e_name, e_type]
|
||
end
|
||
|
||
e_def = @config.parse(e_name, e_type, e_def_raw)
|
||
e_default_parameters = @config.load_default_config(e_type)
|
||
e_def = @config.parse(e_name, e_type, e_def_raw, true, {:default_parameters => e_default_parameters})
|
||
e_config = e_default_parameters.recursive_merge(e_def)
|
||
|
||
klass = @container.module_eval(<<-EOS)
|
||
... | ... | |
klass.instance_variable_set(:@handle, e_name)
|
||
klass.instance_variable_set(:@shadow, self)
|
||
klass.instance_variable_set(:@config, @config)
|
||
klass.instance_variable_set(:@default_parameters, e_default_parameters)
|
||
klass.instance_variable_set(:@parameters, e_config)
|
||
klass.meta_eval do
|
||
attr_reader :handle, :shadow, :config, :parameters
|
||
attr_reader :handle, :shadow, :config, :default_parameters, :parameters
|
||
end
|
||
|
||
begin
|
||
... | ... | |
|
||
klass
|
||
rescue
|
||
raise PreProcessingError, _("Could not create element '%s' for model '%s': %s") % [e_type, e_name, $!]
|
||
raise PreProcessingError, _("Could not create element '%s' for model '%s': %s") % [e_name, e_type, $!]
|
||
end
|
||
end
|
||
end
|
Also available in: Unified diff
[cleanup] reorganized config