2013-06-20 13:36:34 -04:00
|
|
|
require 'fog/core/collection'
|
2013-08-27 05:19:54 -04:00
|
|
|
require 'fog/vcloud_director/models/compute/vapp'
|
2013-06-20 13:36:34 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
2013-08-27 05:19:54 -04:00
|
|
|
class VcloudDirector
|
2013-06-20 13:36:34 -04:00
|
|
|
|
2013-07-09 09:16:00 -04:00
|
|
|
class Vapps < Collection
|
2013-08-27 05:19:54 -04:00
|
|
|
model Fog::Compute::VcloudDirector::Vapp
|
2013-09-16 13:13:09 -04:00
|
|
|
|
2013-06-20 13:36:34 -04:00
|
|
|
attribute :vdc
|
2013-09-16 13:13:09 -04:00
|
|
|
|
2013-07-09 09:16:00 -04:00
|
|
|
private
|
2013-09-16 13:13:09 -04:00
|
|
|
|
2013-07-09 09:16:00 -04:00
|
|
|
def get_by_id(item_id)
|
|
|
|
item = service.get_vapp(item_id).body
|
|
|
|
%w(:Link).each {|key_to_delete| item.delete(key_to_delete) }
|
|
|
|
service.add_id_from_href!(item)
|
|
|
|
item
|
2013-06-20 13:36:34 -04:00
|
|
|
end
|
2013-09-16 13:13:09 -04:00
|
|
|
|
2013-07-09 09:16:00 -04:00
|
|
|
def item_list
|
|
|
|
data = service.get_vdc(vdc.id).body
|
2013-09-24 04:40:15 -04:00
|
|
|
return [] if data[:ResourceEntities].empty?
|
2013-10-15 07:41:15 -04:00
|
|
|
resource_entities = data[:ResourceEntities][:ResourceEntity]
|
2013-09-23 10:59:01 -04:00
|
|
|
items = resource_entities.select { |link| link[:type] == "application/vnd.vmware.vcloud.vApp+xml" }
|
2013-07-09 09:16:00 -04:00
|
|
|
items.each{|item| service.add_id_from_href!(item) }
|
|
|
|
items
|
2013-06-24 07:46:30 -04:00
|
|
|
end
|
2013-09-16 13:13:09 -04:00
|
|
|
|
2013-06-20 13:36:34 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-09-16 13:13:09 -04:00
|
|
|
end
|