mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[vcloud|compute] fix an issue if this is not parsed as an array
This commit is contained in:
parent
d4a1fa3a1e
commit
6a627c3532
3 changed files with 6 additions and 3 deletions
|
@ -20,7 +20,8 @@ module Fog
|
|||
data = [connection.get_vdc(self.href).body[:AvailableNetworks][:Network]].flatten.compact
|
||||
elsif self.href =~ /\/org\//
|
||||
check_href!("Org")
|
||||
data = connection.get_organization(self.href).body[:Link].select{|l| l[:type] == 'application/vnd.vmware.vcloud.network+xml' }
|
||||
links = (l=connection.get_organization(self.href).body[:Link]).is_a?(Array) ? l : [l].compact
|
||||
data = links.select{|l| l[:type] == 'application/vnd.vmware.vcloud.network+xml' }
|
||||
elsif self.href =~ /\/vApp\//
|
||||
check_href!("Vapp")
|
||||
data = [(connection.get_vapp(self.href).body[:NetworkConfigSection]||{})[:NetworkConfig]].flatten.compact.collect{|n| n[:Configuration][:ParentNetwork] unless n[:Configuration].nil? }.compact
|
||||
|
|
|
@ -13,7 +13,8 @@ module Fog
|
|||
attribute :href
|
||||
|
||||
def all
|
||||
data = connection.get_vdc(self.href).body[:ResourceEntities][:ResourceEntity].select { |re| re[:type] == "application/vnd.vmware.vcloud.vApp+xml" }
|
||||
resource_entities = (re=connection.get_vdc(self.href).body[:ResourceEntities][:ResourceEntity]).is_a?(Array) ? re : [re].compact
|
||||
data = resource_entities.select { |re| re[:type] == "application/vnd.vmware.vcloud.vApp+xml" }
|
||||
load(data)
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,8 @@ module Fog
|
|||
attribute :href
|
||||
|
||||
def all
|
||||
data = connection.get_organization(org_uri).body[:Link].select { |link| link[:type] == "application/vnd.vmware.vcloud.vdc+xml" }
|
||||
links = (l=connection.get_organization(org_uri).body[:Link]).is_a?(Array) ? l : [l].compact
|
||||
data = 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
|
||||
|
|
Loading…
Add table
Reference in a new issue