Revision 0d75a0b6
Added by Marc Dequènes over 15 years ago
- ID 0d75a0b69e66109ca47b906c5d44044bc48dbb88
bin/shadowwalker | ||
---|---|---|
end
|
||
cmdparser.add_command(cmd)
|
||
|
||
def display_tree(tree, level)
|
||
tree.keys.sort.each do |key|
|
||
str = ""
|
||
str += " " + "| " * (level -1) + "+-- " if level > 0
|
||
str += "<#{key}>"
|
||
puts str
|
||
|
||
display_tree(tree[key], level + 1) if tree[key]
|
||
end
|
||
end
|
||
|
||
cmd = CmdParse::Command.new('tree', false)
|
||
cmd.short_desc = "show skeleton objects tree"
|
||
cmd.set_execution_block do |args|
|
||
puts "Tree:"
|
||
|
||
base_dn = ActiveLdap::DistinguishedName.parse(LdapShadows::LdapObject.base)
|
||
|
||
gconfig = ldapctl.get_global_config()
|
||
if gconfig.has_key?(:tree_objects)
|
||
tree = {}
|
||
|
||
gconfig[:tree_objects].each do |obj_hdl|
|
||
obj_klass = ldapctl.find_klass(obj_hdl)
|
||
raise "object '#{obj_hdl}' not defined" unless obj_klass
|
||
|
||
obj_klass.find(:all).each do |obj|
|
||
ptree = tree
|
||
pdn = nil
|
||
(obj.dn_obj - base_dn).to_s.split(',').reverse.each do |pdn|
|
||
ptree[pdn] = {} unless ptree.has_key?(pdn)
|
||
ptree = ptree[pdn]
|
||
end
|
||
ptree = nil
|
||
end
|
||
end
|
||
tree = {base_dn => tree}
|
||
|
||
display_tree(tree, 0)
|
||
end
|
||
end
|
||
cmdparser.add_command(cmd)
|
||
|
||
cmdparser.parse
|
||
|
Also available in: Unified diff
[evol] added tree view