class OhBoshWillItFit::Limits
Attributes
fog_compute[R]
fog_volumes[R]
Public Class Methods
new(fog_compute, fog_volumes)
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 5 def initialize(fog_compute, fog_volumes) @fog_compute = fog_compute @fog_volumes = fog_volumes end
Public Instance Methods
compute_quotas()
click to toggle source
{
"metadata_items"=>128, "ram"=>204800, "floating_ips"=>10, "key_pairs"=>100, "instances"=>40, "security_group_rules"=>20, "injected_files"=>5, "cores"=>50, "fixed_ips"=>-1, "security_groups"=>10
}
# File lib/ohboshwillitfit/limits.rb, line 103 def compute_quotas @compute_quotas ||= fog_compute.get_quota(current_tenant_id).data[:body]["quota_set"] end
compute_servers()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 77 def compute_servers @compute_servers ||= fog_compute.servers end
cores_available()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 55 def cores_available max_total_cores - total_cores_used end
current_tenant_id()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 122 def current_tenant_id fog_compute.current_tenant["id"] end
flavor_for_server(server)
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 85 def flavor_for_server(server) flavor_id = server.flavor["id"] @flavors ||= {} @flavors[flavor_id] ||= fog_compute.flavors.get(flavor_id) end
instances_available()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 59 def instances_available max_total_instances - total_instances_used end
max_total_cores()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 10 def max_total_cores compute_quotas["cores"] end
max_total_instances()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 14 def max_total_instances compute_quotas["instances"] end
max_total_ram_size()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 18 def max_total_ram_size compute_quotas["ram"] end
max_total_volume_size()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 22 def max_total_volume_size volume_quotas["gigabytes"] end
max_total_volumes()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 26 def max_total_volumes volume_quotas["volumes"] end
ram_size_available()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 63 def ram_size_available max_total_ram_size - total_ram_size_used end
total_cores_used()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 31 def total_cores_used compute_servers.inject(0) { |total, server| total + flavor_for_server(server).vcpus } end
total_instances_used()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 35 def total_instances_used compute_servers.size end
total_ram_size_used()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 39 def total_ram_size_used compute_servers.inject(0) { |total, server| total + flavor_for_server(server).ram } end
total_volume_size_used()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 43 def total_volume_size_used @total_volume_size_used ||= volumes.inject(0) {|size, vol| size + vol.size } end
total_volumes_used()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 47 def total_volumes_used @total_volumes_used ||= volumes.size end
volume_quotas()
click to toggle source
{
"snapshots"=>10, "gigabytes"=>15000, "volumes"=>40,
}
# File lib/ohboshwillitfit/limits.rb, line 112 def volume_quotas @volume_quotas ||= fog_volumes.get_quota(current_tenant_id).data[:body]["quota_set"] rescue Fog::Compute::OpenStack::NotFound @volume_quotas = { "snapshots"=>nil, "gigabytes"=>nil, "volumes"=>nil, } end
volume_size_available()
click to toggle source
return nil if target OpenStack doesn't support volumes.get_quota
# File lib/ohboshwillitfit/limits.rb, line 68 def volume_size_available max_total_volume_size ? (max_total_volume_size - total_volume_size_used) : nil end
volumes()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 81 def volumes @volumes ||= fog_volumes.volumes end
volumes_available()
click to toggle source
return nil if target OpenStack doesn't support volumes.get_quota
# File lib/ohboshwillitfit/limits.rb, line 73 def volumes_available max_total_volumes ? (max_total_volumes - total_volumes_used) : nil end
volumes_limits_available?()
click to toggle source
# File lib/ohboshwillitfit/limits.rb, line 51 def volumes_limits_available? max_total_volume_size end