Class: Egi::Fedcloud::Cloudhound::AppdbSite

Inherits:
Object
  • Object
show all
Defined in:
lib/egi/fedcloud/cloudhound/appdb_site.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element) ⇒ AppdbSite

Returns a new instance of AppdbSite.



8
9
10
11
12
13
14
15
16
17
# File 'lib/egi/fedcloud/cloudhound/appdb_site.rb', line 8

def initialize(element)
  Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] Initializing with #{element.inspect}"

  @services = self.class.extract_services(element)
  @gocdb_link = self.class.extract_gocdb_link(element)
  @name = element.name
  @type = @services.empty? ? 'grid' : 'cloud'
  @status = element.status
  @infrastructure = element.infrastructure
end

Instance Attribute Details

Returns the value of attribute gocdb_link.



4
5
6
# File 'lib/egi/fedcloud/cloudhound/appdb_site.rb', line 4

def gocdb_link
  @gocdb_link
end

#infrastructureObject (readonly)

Returns the value of attribute infrastructure.



4
5
6
# File 'lib/egi/fedcloud/cloudhound/appdb_site.rb', line 4

def infrastructure
  @infrastructure
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/egi/fedcloud/cloudhound/appdb_site.rb', line 4

def name
  @name
end

#servicesObject (readonly)

Returns the value of attribute services.



5
6
7
# File 'lib/egi/fedcloud/cloudhound/appdb_site.rb', line 5

def services
  @services
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/egi/fedcloud/cloudhound/appdb_site.rb', line 4

def status
  @status
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/egi/fedcloud/cloudhound/appdb_site.rb', line 4

def type
  @type
end

Class Method Details



44
45
46
47
48
# File 'lib/egi/fedcloud/cloudhound/appdb_site.rb', line 44

def extract_gocdb_link(element)
  urls = (element.locate('url') || [])
  portals = urls.select { |url| url.text && url.type('portal') }
  portals.first ? portals.first.text : nil
end

.extract_services(element) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/egi/fedcloud/cloudhound/appdb_site.rb', line 33

def extract_services(element)
  services = (element.locate('service') || [])
  services.map do |service|
    srv = {}
    srv['type'] = service.type
    srv['host'] = service.host
    srv
  end
end

Instance Method Details

#contactsObject



20
21
22
23
24
25
26
27
28
# File 'lib/egi/fedcloud/cloudhound/appdb_site.rb', line 20

def contacts
  {
    name: name,
    type: type,
    status: status,
    csirt: nil,
    ngi: nil
  }
end