Class: Egi::Fedcloud::Cloudhound::AppdbAppliance

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element) ⇒ AppdbAppliance

Returns a new instance of AppdbAppliance.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/egi/fedcloud/cloudhound/appdb_appliance.rb', line 10

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

  @identifier = element['identifier']
  @version = element['version']
  @url = element['url']
  @checksum = element['checksum']
  @format = element['format']
  @owner = element['addedby'] ? element['addedby']['permalink'] : 'unknown'
  @published = element['published']
  @mpuri = element['mpuri']

  # and now the difficult part
  @sites = self.class.extract_sites(element['sites'])
end

Instance Attribute Details

#checksumObject (readonly)

Returns the value of attribute checksum.



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

def checksum
  @checksum
end

#formatObject (readonly)

Returns the value of attribute format.



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

def format
  @format
end

#identifierObject (readonly)

Returns the value of attribute identifier.



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

def identifier
  @identifier
end

#mpuriObject (readonly)

Returns the value of attribute mpuri.



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

def mpuri
  @mpuri
end

#ownerObject (readonly)

Returns the value of attribute owner.



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

def owner
  @owner
end

#publishedObject (readonly)

Returns the value of attribute published.



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

def published
  @published
end

#sitesObject (readonly)

Returns the value of attribute sites.



7
8
9
# File 'lib/egi/fedcloud/cloudhound/appdb_appliance.rb', line 7

def sites
  @sites
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Class Method Details

.extract_site_vos(element) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/egi/fedcloud/cloudhound/appdb_appliance.rb', line 41

def extract_site_vos(element)
  return [] if element.blank?

  vos = []
  element.each do |service|
    vos << service['vos'].collect { |vo| vo['name'] }
  end
  vos.flatten!
  vos.compact!
  vos.uniq!

  vos
end

.extract_sites(element) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/egi/fedcloud/cloudhound/appdb_appliance.rb', line 28

def extract_sites(element)
  return [] if element.blank?

  element.collect do |site|
    st = {}
    st['name'] = site['name']
    st['gocdb_link'] = site['url'] ? site['url']['portal'] : 'unknown'
    st['vos'] = extract_site_vos(site['services'])
    st
  end
end