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/models/compute/vdcs.rb
Peter Meier 3e240474ac [vcloud|compute] improve models + additional tests
vCloud has also the concept of links in the responses. So we should
make use of them to navigate through the tree of resources in the
vCloud.
Furthermore, we can make various calls a bit easier by directly
returning the specific resource object than the plain xml response.

Adjust tests to work with the new changes, and also test the added
parts.
2012-01-30 18:57:13 +01:00

35 lines
737 B
Ruby

require 'fog/vcloud/models/compute/vdc'
module Fog
module Vcloud
class Compute
class Vdcs < Collection
model Fog::Vcloud::Compute::Vdc
undef_method :create
attribute :href
def all
data = connection.get_organization(org_uri).links.select { |link| link[:type] == "application/vnd.vmware.vcloud.vdc+xml" }
data.each { |link| link.delete_if { |key, value| [:rel].include?(key) } }
load(data)
end
def get(uri)
connection.get_vdc(uri)
rescue Fog::Errors::NotFound
nil
end
private
def org_uri
self.href ||= connection.default_organization_uri
end
end
end
end
end