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/vdcs.rb
2013-06-18 20:50:37 +02:00

28 lines
No EOL
802 B
Ruby

require 'fog/core/collection'
require 'fog/vcloudng/models/compute/vdc'
module Fog
module Compute
class Vcloudng
class Vdcs < Fog::Collection
model Fog::Compute::Vcloudng::Vdc
attribute :organization
def all(organization_id = organization.id)
data = service.get_organization(organization_id).body
vdcs = data["Links"].select { |link| link["type"] == "application/vnd.vmware.vcloud.vdc+xml" }
vdc_ids = vdcs.map {|vdc| vdc['href'].split('/').last }
vdc_ids.map{ |vdc_id| get(vdc_id)}
end
def get(vdc_id)
data = service.get_vdc(vdc_id).body
%w(VdcItems Links).each {|key_to_delete| data.delete(key_to_delete) }
new(data)
end
end
end
end
end