2013-08-27 05:19:54 -04:00
|
|
|
require 'fog/vcloud_director/compute'
|
2013-08-16 06:00:52 -04:00
|
|
|
|
2013-08-20 07:55:32 -04:00
|
|
|
def boolean?(item)
|
|
|
|
[TrueClass, FalseClass].include?(item.class)
|
|
|
|
end
|
|
|
|
|
2013-09-13 14:17:42 -04:00
|
|
|
def vcloud_director
|
|
|
|
@vcloud_director ||= Fog::Compute::VcloudDirector.new(
|
|
|
|
:connection_options => {
|
|
|
|
:ssl_verify_peer => false,
|
|
|
|
:connect_timeout => 200,
|
|
|
|
:read_timeout => 200
|
|
|
|
}
|
|
|
|
)
|
2013-08-16 06:00:52 -04:00
|
|
|
end
|
2013-08-19 10:04:25 -04:00
|
|
|
|
2013-09-13 14:17:42 -04:00
|
|
|
def organizations
|
2013-08-27 05:19:54 -04:00
|
|
|
@organizations ||= vcloud_director.organizations
|
2013-08-19 10:04:25 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def organization
|
2013-10-01 11:23:23 -04:00
|
|
|
@organization ||= organizations.get_by_name(vcloud_director.org_name)
|
2013-08-19 10:04:25 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def catalogs
|
|
|
|
@catalogs ||= organization.catalogs
|
|
|
|
end
|
|
|
|
|
|
|
|
def catalog
|
|
|
|
catalogs.first
|
|
|
|
end
|
|
|
|
|
|
|
|
def vdcs
|
|
|
|
@vdcs ||= organization.vdcs
|
|
|
|
end
|
|
|
|
|
|
|
|
def vdc
|
|
|
|
vdcs.first
|
|
|
|
end
|
|
|
|
|
|
|
|
def vapps
|
|
|
|
@vapps ||= vdc.vapps
|
|
|
|
end
|
|
|
|
|
|
|
|
def vapp
|
2014-05-22 21:40:43 -04:00
|
|
|
vapps.find {|vapp| vapp.vms.size >= 1 }
|
2013-08-20 07:55:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def the_network
|
|
|
|
@network ||= organization.networks.get_by_name(NETWORK_NAME)
|
2013-09-13 14:17:42 -04:00
|
|
|
end
|
|
|
|
|
2013-08-20 07:55:32 -04:00
|
|
|
def the_catalog
|
|
|
|
@catalog ||= organization.catalogs.get_by_name(CATALOG_NAME)
|
|
|
|
end
|
2013-09-13 14:17:42 -04:00
|
|
|
|
2013-08-20 07:55:32 -04:00
|
|
|
def the_catalog_item
|
|
|
|
return nil unless the_catalog
|
|
|
|
@catalog_item ||= the_catalog.catalog_items.get_by_name(CATALOG_ITEM_NAME)
|
2013-09-04 05:20:07 -04:00
|
|
|
end
|