From 873d195ddd8aa4874d892763adc5f8ade8210043 Mon Sep 17 00:00:00 2001 From: rsalm Date: Wed, 18 Sep 2013 20:59:35 +0300 Subject: [PATCH] [vcloud_director] Fix listing catalog items when only a single item exists. --- lib/fog/vcloud_director/models/compute/catalog_items.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/fog/vcloud_director/models/compute/catalog_items.rb b/lib/fog/vcloud_director/models/compute/catalog_items.rb index cb6f33564..2ea18c42f 100644 --- a/lib/fog/vcloud_director/models/compute/catalog_items.rb +++ b/lib/fog/vcloud_director/models/compute/catalog_items.rb @@ -12,9 +12,13 @@ module Fog private + def ensure_list(items) + items.is_a?(Hash) ? [items] : items + end + def item_list data = service.get_catalog(catalog.id).body - items = data[:CatalogItems][:CatalogItem].select { |link| link[:type] == "application/vnd.vmware.vcloud.catalogItem+xml" } + items = ensure_list(data[:CatalogItems][:CatalogItem]).select { |link| link[:type] == "application/vnd.vmware.vcloud.catalogItem+xml" } items.each{|item| service.add_id_from_href!(item) } items end