Class: Fog::Terremark::Shared::Servers

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/terremark/models/shared/servers.rb

Instance Attribute Summary

Attributes inherited from Collection

#connection

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Collection

Instance Method Details

#allObject



24
25
26
27
28
29
30
# File 'lib/fog/terremark/models/shared/servers.rb', line 24

def all
  data = []
  connection.get_vdc(vdc_id).body['ResourceEntities'].select do |entity|
      data << connection.servers.get(entity["href"].split('/').last)
  end
  data
end

#get(server_id) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/fog/terremark/models/shared/servers.rb', line 32

def get(server_id)
  if server_id
    new(connection.get_vapp(server_id).body)
  else
    nil
  end
end

#vdc_idObject



40
41
42
# File 'lib/fog/terremark/models/shared/servers.rb', line 40

def vdc_id
  @vdc_id ||= connection.default_vdc_id
end