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/vcloudng/models/compute/vapps.rb
Rodrigo Estebanez 60e8a5ec2a many changes...
2013-06-20 19:36:34 +02:00

29 lines
No EOL
838 B
Ruby

require 'fog/core/collection'
require 'fog/vcloudng/models/compute/vapp'
module Fog
module Compute
class Vcloudng
class Vapps < Fog::Collection
model Fog::Compute::Vcloudng::Vapp
attribute :vdc
def all(vdc_id = vdc.id)
data = service.get_vdc(vdc_id).body
vapps = data[:ResourceEntities][:ResourceEntity].select { |link| link[:type] == "application/vnd.vmware.vcloud.vApp+xml" }
vapp_ids = vapps.map {|vapp| vapp[:href].split('/').last }
vapp_ids.map{ |vapp_id| get(vapp_id)}
end
def get(vapp_id)
data = service.get_vapp(vapp_id).body
data[:id] = data[:href].split('/').last
%w(:Link).each {|key_to_delete| data.delete(key_to_delete) }
new(data)
end
end
end
end
end