Project

General

Profile

« Previous | Next » 

Revision ee2c32c3

Added by Marc Dequènes over 13 years ago

  • ID ee2c32c3f26e0d62c2a169beb342a54a15a94e79

[evol] Botnet/Interface: '/?' search now return a Hash in order to get the object name easily for further manipulations, updated Librarian accordingly

View differences:

IDEAS
each queue is an internal channel, each processor is a task.
API (all bots):
- list manipulators:
+ /? -> search(<criterias>)
+ /+ -> create(<data>)
+ /- -> delete(<name>)
MapMaker:
- API:
/Services/DNS -> named info
bin/test_client
ask "Librarian", :info2, "/_cyborg_"
ask "Librarian", :library, "/Records"
ask "Librarian", :persons, "/Records/Persons"
ask "Librarian", :dns_domains, "/Records/DnsDomains"
#ask "Librarian", :dns_domains, "/Records/DnsDomains"
ask "Librarian", :gorou, "/Records/Persons/gorou"
ask "Librarian", :guihome_net, "/Records/DnsDomains/guihome.net"
ask "Librarian", :person_search, "/Records/Persons/?", {:uidNumber => 10033}
ask "Librarian", :person_search_null, "/Records/Persons/?"
ask "Librarian", :person_search, "/Records/Persons/?", {:uid => "g*"}
#ask "Librarian", :person_search_null, "/Records/Persons/?"
#ask "MapMaker", :zones, "/Zones"
#ask "MapMaker", :wanted_failure, "/prout"
#ask "MapMaker", :dns, "/Services/DNS"
......
#ask "MapMaker", :zone_mp, "/Zones/milkypond.org"
#ask "MapMaker", :dns_check, "/Services/DNS/check_config"
#ask "MapMaker", :search, "/Zones/?"
#ask "MapMaker", :search_master, "/Zones/?", {:master => true}
#ask "MapMaker", :search_slave, "/Zones/?", {:master => false}
ask "MapMaker", :search_master, "/Zones/?", {:is_master => true}
#ask "MapMaker", :search_slave, "/Zones/?", {:is_master => false}
#know? "MapMaker", :k1, "/Zones"
#know? "MapMaker", :k2, "/prout"
on_error do
lib/cyborghood-librarian/interface/0_base.rb
end
attr_search_node do |criterias|
object_list.call(:search, :criterias => criterias, :format => :data_hash)
{
:post_filter => false,
:list => object_list.call(:search, :criterias => criterias, :format => :data_hash)
}
end
node object_list do
lib/cyborghood-librarian/records.rb
filter = (filter_parts.size == 1) ? filter_parts.first : '(&' + filter_parts.join + ')'
list = klass.find(:all, :filter => filter)
index_result(list, primary_attr) if options[:indexed]
list = index_result(list, primary_attr)
format_result(list, options[:format])
elsif obj_name == :all
list = klass.find(:all)
index_result(list, primary_attr) if options[:indexed]
list = index_result(list, primary_attr)
format_result(list, options[:format])
else
list = klass.find(:all, :attribute => primary_attr, :value => obj_name)
lib/cyborghood/cyborg/botnet/interface.rb
end
def search_among_children(request, lookup_node)
node_names_list = []
criterias = request.args.first
return {} unless criterias.is_a? Hash
node_names_list = {}
lookup_node.__send__(:visible_nodes).each do |match, node|
if match.is_a? String
......
result = node.__send__(:request, request.session)
next unless result.respond_to? :to_hash
if hash_match_criterias(result.to_hash, request.args.first)
node_names_list << child_node_name
child_node_attrs = result.to_hash
if hash_match_criterias(child_node_attrs, criterias)
node_names_list[child_node_name] = child_node_attrs
end
end
end
......
def search_in_list(request, lookup_node, list)
criterias = request.args.first
return [] unless criterias.is_a? Hash
return {} unless criterias.is_a? Hash
if list.is_a? Proc
list = list.call(criterias)
# if result is an array, then a final list of names is given, return it
return list if list.is_a? Array
# else it must be a Hash which needs to be filtered
data = list.call(criterias)
return data[:list] unless data[:post_filter]
end
node_names_list = []
node_names_list = {}
data[:list].each do |element_name, element|
element_attrs = element.to_hash
list.each do |element_name, element|
if hash_match_criterias(element.to_hash, criterias)
node_names_list << element_name
if hash_match_criterias(element_attrs, criterias)
node_names_list[element_name] = element_attrs
end
end

Also available in: Unified diff