mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[vcloud|compute] method to find catalog item by name across all catalogs
This commit is contained in:
parent
9aeeb5abe1
commit
c865ec6d16
2 changed files with 12 additions and 1 deletions
|
@ -22,6 +22,17 @@ module Fog
|
|||
@organization_uri ||= connection.default_organization_uri
|
||||
end
|
||||
|
||||
def item_by_name(name)
|
||||
res = nil
|
||||
items = all.collect { |catalog| catalog.catalog_items }
|
||||
items.each do |i|
|
||||
i.collect do |ii|
|
||||
res = ii if ii.name == name
|
||||
end
|
||||
end
|
||||
res
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ class Vcloud
|
|||
def self.template
|
||||
template_name = ENV['VCLOUD_TEMPLATE']
|
||||
raise "Specify VApp template name in VCLOUD_TEMPLATE env var" unless template_name
|
||||
template_res = Vcloud.catalogs.first.catalog_items.select {|ci| ci.name == template_name }[0]
|
||||
template_res = Vcloud.catalogs.item_by_name template_name
|
||||
raise "URI Not found for specified template - check template name" unless template_res
|
||||
template_res.href
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue