2012-04-11 19:50:01 -04:00
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Ecloud
|
|
|
|
class ComputePool < Fog::Ecloud::Model
|
|
|
|
|
2012-06-07 12:50:11 -04:00
|
|
|
identity :href
|
2012-04-11 19:50:01 -04:00
|
|
|
|
2012-11-27 19:57:16 -05:00
|
|
|
attribute :href, :aliases => :Href
|
|
|
|
attribute :name, :aliases => :Name
|
|
|
|
attribute :type, :aliases => :Type
|
|
|
|
attribute :other_links, :aliases => :Links, :squash => :Link
|
|
|
|
attribute :all_servers, :aliases => :VirtualMachines
|
|
|
|
attribute :purchased, :aliases => :Purchased
|
|
|
|
attribute :cpu_burst, :aliases => :CpuBurst
|
2012-06-07 12:50:11 -04:00
|
|
|
attribute :memory_burst, :aliases => :MemoryBurst
|
|
|
|
|
|
|
|
def servers
|
2012-12-22 18:27:38 -05:00
|
|
|
@servers ||= Fog::Compute::Ecloud::Servers.new( :service => service, :href => "/cloudapi/ecloud/virtualMachines/computePools/#{id}" )
|
2012-06-07 12:50:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def layout
|
2012-12-22 18:27:38 -05:00
|
|
|
@layout ||= Fog::Compute::Ecloud::Layouts.new(:service => service, :href => "/cloudapi/ecloud/layout/computePools/#{id}").first
|
2012-06-07 12:50:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def cpu_usage
|
|
|
|
# time ? query = "/details?time=#{Time.parse(time).utc.strftime('%Y-%m-%dT%H:%M:%SZ')}" : query = ""
|
2012-12-22 18:27:38 -05:00
|
|
|
@cpu_usage ||= Fog::Compute::Ecloud::CpuUsageDetailSummary.new(:service => service, :href => "/cloudapi/ecloud/computePools/#{id}/usage/cpu")
|
2012-06-07 12:50:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def memory_usage
|
|
|
|
# time ? query = "/details?time=#{Time.parse(time).utc.strftime('%Y-%m-%dT%H:%M:%SZ')}" : query = ""
|
2012-12-22 18:27:38 -05:00
|
|
|
@memory_usage ||= Fog::Compute::Ecloud::MemoryUsageDetailSummary.new(:service => service, :href => "/cloudapi/ecloud/computePools/#{id}/usage/memory")
|
2012-06-07 12:50:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def storage_usage
|
2012-12-22 18:27:38 -05:00
|
|
|
@storage_usage ||= Fog::Compute::Ecloud::StorageUsageDetailSummary.new(:service => service, :href => "/cloudapi/ecloud/computePools/#{id}/usage/storage")
|
2012-06-07 12:50:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def operating_system_families
|
2012-12-22 18:27:38 -05:00
|
|
|
@operating_system_families ||= Fog::Compute::Ecloud::OperatingSystemFamilies.new(:service => service, :href => "/cloudapi/ecloud/operatingSystemFamilies/computePools/#{id}")
|
2012-06-07 12:50:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def templates
|
2012-12-22 18:27:38 -05:00
|
|
|
@templates ||= self.service.templates(:href => "/cloudapi/ecloud/templates/computePools/#{id}")
|
2012-11-27 19:57:16 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def detached_disks
|
2012-12-22 18:27:38 -05:00
|
|
|
@detached_disks ||= self.service.detached_disks(:href => "/cloudapi/ecloud/detacheddisks/computepools/#{id}")
|
2012-11-27 19:57:16 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def environment
|
|
|
|
@environment ||= begin
|
|
|
|
reload unless other_links
|
|
|
|
environment_link = other_links.find{|l| l[:type] == "application/vnd.tmrk.cloud.environment"}
|
2012-12-22 18:27:38 -05:00
|
|
|
self.service.environments.get(environment_link[:href])
|
2012-11-27 19:57:16 -05:00
|
|
|
end
|
2012-06-07 12:50:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit(options)
|
|
|
|
options[:uri] = href
|
2012-12-22 18:27:38 -05:00
|
|
|
data = service.compute_pool_edit(options).body
|
2012-06-07 12:50:11 -04:00
|
|
|
pool = collection.from_data(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def id
|
|
|
|
href.scan(/\d+/)[0]
|
|
|
|
end
|
2012-04-11 19:50:01 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|