1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/vcloud/terremark/ecloud/models/servers.rb

54 lines
1.2 KiB
Ruby

module Fog
class Vcloud
module Terremark
module Ecloud
class Servers < Fog::Vcloud::Collection
undef_method :create
model Fog::Vcloud::Terremark::Ecloud::Server
attribute :href, :aliases => :Href
def all
load(_vapps)
end
def get(uri)
if data = connection.get_vapp(uri)
new(data.body)
end
rescue Fog::Errors::NotFound
nil
end
def create( catalog_item_uri, options )
options[:vdc_uri] = href
options[:cpus] ||= 1
options[:memory] ||= 512
data = connection.instantiate_vapp_template( catalog_item_uri, options ).body
object = new(data)
object
end
private
def _resource_entities
connection.get_vdc(href).body[:ResourceEntities][:ResourceEntity]
end
def _vapps
resource_entities = _resource_entities
if resource_entities.nil?
[]
else
resource_entities
end
end
end
end
end
end
end