Class: Egi::Fedcloud::Cloudhound::Extractor
- Inherits:
-
Object
- Object
- Egi::Fedcloud::Cloudhound::Extractor
- Defined in:
- lib/egi/fedcloud/cloudhound/extractor.rb
Constant Summary collapse
- LOOKUP_ORDER =
%w(certified_production_sites production_sites sites)
Class Method Summary collapse
- .find_all(options = {}) ⇒ Object
- .find_by_appuri(uri, options = {}) ⇒ Object
- .find_by_ip(ip, options = {}) ⇒ Object
- .init(options) ⇒ Object
Class Method Details
.find_all(options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/egi/fedcloud/cloudhound/extractor.rb', line 20 def find_all( = {}) init Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Searching for all cloud-related contacts" sites = @@gocdb.cloud_sites sites.compact! Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Found #{sites.count} cloud sites" sites.collect { |site| site.contacts } end |
.find_by_appuri(uri, options = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/egi/fedcloud/cloudhound/extractor.rb', line 52 def find_by_appuri(uri, = {}) init Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Searching for contacts by MPURI: #{uri.inspect}" sites = @@appdb.appliance(uri).sites.collect { |site| site['name'] } Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Querying #{sites.inspect} for contact details" found = [] sites.each do |affected_site| LOOKUP_ORDER.each do |lookup_type| found << @@gocdb.send(lookup_type).select { |site| site.name == affected_site } found.flatten! found.compact! Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Found #{found.inspect} in #{lookup_type.inspect}" break unless found.blank? end end found.collect { |site| site.contacts } end |
.find_by_ip(ip, options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/egi/fedcloud/cloudhound/extractor.rb', line 34 def find_by_ip(ip, = {}) init Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Searching for contacts by IP: #{ip.inspect}" found = [] LOOKUP_ORDER.each do |lookup_type| found << @@gocdb.send(lookup_type).select { |site| site.in_range?(ip) } found.flatten! found.compact! Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Found #{found.inspect} in #{lookup_type.inspect}" break unless found.blank? end found.collect { |site| site.contacts } end |
.init(options) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/egi/fedcloud/cloudhound/extractor.rb', line 11 def init() # TODO: move upstream password = [:password] ? [:password] : ask("Enter PEM password: ") { |q| q.echo = false } @@gocdb ||= Egi::Fedcloud::Cloudhound::Gocdb.new(, password) @@appdb ||= Egi::Fedcloud::Cloudhound::Appdb.new(, password) end |