1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

adapting vdc to the new parser

This commit is contained in:
Rodrigo Estebanez 2013-06-19 17:07:42 +02:00
parent d4e152b908
commit a8e7f99c76
3 changed files with 20 additions and 8 deletions

View file

@ -11,10 +11,21 @@ module Fog
attribute :name attribute :name
attribute :type attribute :type
attribute :href attribute :href
attribute :description, :aliases => 'Description' attribute :description, :aliases => :Description
attribute :available_networks, :aliases => 'AvailableNetworks' attribute :available_networks, :aliases => :AvailableNetworks
attribute :compute_capacity , :aliases => 'ComputeCapacity' attribute :compute_capacity , :aliases => :ComputeCapacity
attribute :storage_capacity , :aliases => 'StorageCapacity' attribute :storage_capacity , :aliases => :StorageCapacity
attribute :allocation_model, :aliases => :AllocationModel
attribute :capabilities, :aliases => :Capabilities
attribute :nic_quota, :aliases => :NicQuota, :type => :integer
attribute :network_quota ,:aliases => :NetworkQuota, :type => :integer
attribute :vm_quota ,:aliases => :VmQuota, :type => :integer
attribute :is_enabled ,:aliases => :IsEnabled, :type => :boolean
def vapps
requires :id
service.vdcs(:vdc => self)
end
end end
end end

View file

@ -12,14 +12,15 @@ module Fog
def all(organization_id = organization.id) def all(organization_id = organization.id)
data = service.get_organization(organization_id).body data = service.get_organization(organization_id).body
vdcs = data["Links"].select { |link| link["type"] == "application/vnd.vmware.vcloud.vdc+xml" } vdcs = data[:Link].select { |link| link[:type] == "application/vnd.vmware.vcloud.vdc+xml" }
vdc_ids = vdcs.map {|vdc| vdc['href'].split('/').last } vdc_ids = vdcs.map {|vdc| vdc[:href].split('/').last }
vdc_ids.map{ |vdc_id| get(vdc_id)} vdc_ids.map{ |vdc_id| get(vdc_id)}
end end
def get(vdc_id) def get(vdc_id)
data = service.get_vdc(vdc_id).body data = service.get_vdc(vdc_id).body
%w(VdcItems Links).each {|key_to_delete| data.delete(key_to_delete) } data[:id] = data[:href].split('/').last
%w(:VdcItems :Link :ResourceEntities).each {|key_to_delete| data.delete(key_to_delete) }
new(data) new(data)
end end
end end

View file

@ -35,7 +35,7 @@ module Fog
:expects => 200, :expects => 200,
:headers => { 'Accept' => 'application/*+xml;version=1.5' }, :headers => { 'Accept' => 'application/*+xml;version=1.5' },
:method => 'GET', :method => 'GET',
:parser => Fog::Parsers::Compute::Vcloudng::GetVdc.new, :parser => Fog::ToHashDocument.new,
:path => "vdc/#{vdc_id}" :path => "vdc/#{vdc_id}"
) )
end end