2011-08-24 21:11:42 -04:00
|
|
|
require 'fog/vcloud/models/compute/vdc'
|
2011-05-23 21:17:16 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Vcloud
|
|
|
|
class Compute
|
|
|
|
|
|
|
|
class Vdcs < Collection
|
|
|
|
|
|
|
|
model Fog::Vcloud::Compute::Vdc
|
|
|
|
|
|
|
|
undef_method :create
|
|
|
|
|
2011-09-27 05:38:09 -04:00
|
|
|
attribute :href
|
|
|
|
|
2011-05-23 21:17:16 -04:00
|
|
|
def all
|
2012-12-22 18:22:50 -05:00
|
|
|
data = service.get_organization(org_uri).links.select { |link| link[:type] == "application/vnd.vmware.vcloud.vdc+xml" }
|
2011-05-23 21:17:16 -04:00
|
|
|
data.each { |link| link.delete_if { |key, value| [:rel].include?(key) } }
|
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(uri)
|
2012-12-22 18:22:50 -05:00
|
|
|
service.get_vdc(uri)
|
2011-05-23 21:17:16 -04:00
|
|
|
rescue Fog::Errors::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2011-09-27 05:38:09 -04:00
|
|
|
def org_uri
|
2012-12-22 18:22:50 -05:00
|
|
|
self.href ||= service.default_organization_uri
|
2011-05-23 21:17:16 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|