Class: OpenldapMonitorExtractor::Core
- Inherits:
-
Object
- Object
- OpenldapMonitorExtractor::Core
- Defined in:
- lib/openldap_monitor_extractor/core.rb
Instance Method Summary collapse
- #get(key = :all) ⇒ Object
- #get_monitor_parameter(dn, attribute, options = { }) ⇒ Object
-
#initialize(config, options = { }) ⇒ Core
constructor
A new instance of Core.
Constructor Details
#initialize(config, options = { }) ⇒ Core
Returns a new instance of Core.
10 11 12 13 14 15 16 17 18 |
# File 'lib/openldap_monitor_extractor/core.rb', line 10 def initialize(config, ={ }) = { :mapper =>Mapper }.merge() @connection = Connection.new(config).connection @mapper = [:mapper] self end |
Instance Method Details
#get(key = :all) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/openldap_monitor_extractor/core.rb', line 32 def get(key=:all) raise ArgumentError.new("Monitor invalid key: #{key}") unless @mapper.validate_key(key) result = MonitorData.new() key_list = (key == :all) ? @mapper::dns() : [key] key_list.each do |k| dn = @mapper.dn(k) attribute = @mapper.attribute(k) entry = get_monitor_parameter(dn, attribute) raise StandardError.new("Problems getting Monitor for data: #{dn}") unless entry result.add(k, entry) end result end |
#get_monitor_parameter(dn, attribute, options = { }) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/openldap_monitor_extractor/core.rb', line 21 def get_monitor_parameter(dn, attribute, ={ }) = { :filter =>Net::LDAP::Filter.eq("objectClass", "*") }.merge() @connection.search( :filter =>[:filter], :base =>dn, :attributes =>[attribute]) end |