mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Switch from casting to_f to using fdiv dividing floats
This commit updates places where previously we were casting both terms in a float division into floats in order to ensure that float division occurs to use the `fdiv` method, which will always do float division and is available on both `Floats` and `Integers` because they are both `Numeric`.
This commit is contained in:
parent
532ca96131
commit
367565a3ee
2 changed files with 3 additions and 3 deletions
|
|
@ -216,7 +216,7 @@ module Vmpooler
|
|||
capacity[:current] = get_total_across_pools_redis_scard(pools, 'vmpooler__ready__', backend)
|
||||
|
||||
if capacity[:total] > 0
|
||||
capacity[:percent] = ((capacity[:current].to_f / capacity[:total].to_f) * 100.0).round(1)
|
||||
capacity[:percent] = (capacity[:current].fdiv(capacity[:total]) * 100.0).round(1)
|
||||
end
|
||||
|
||||
capacity
|
||||
|
|
|
|||
|
|
@ -759,7 +759,7 @@ module Vmpooler
|
|||
return nil if cpu_usage.nil?
|
||||
|
||||
cpu_size = host.summary.hardware.cpuMhz * host.summary.hardware.numCpuCores
|
||||
(cpu_usage.to_f / cpu_size.to_f) * 100
|
||||
cpu_usage.fdiv(cpu_size) * 100
|
||||
end
|
||||
|
||||
def memory_utilization_for(host)
|
||||
|
|
@ -767,7 +767,7 @@ module Vmpooler
|
|||
return nil if memory_usage.nil?
|
||||
|
||||
memory_size = host.summary.hardware.memorySize / 1024 / 1024
|
||||
(memory_usage.to_f / memory_size.to_f) * 100
|
||||
memory_usage.fdiv(memory_size) * 100
|
||||
end
|
||||
|
||||
def get_average_cluster_utilization(hosts)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue