Performance mode: The worst host is removed of hosts array after optimization.

This commit is contained in:
wescoeur 2016-03-17 12:11:34 +01:00
parent 12e0759711
commit 99e046ddea

View File

@ -434,9 +434,9 @@ class PerformancePlan extends Plan {
const { const {
averages, averages,
hosts,
toOptimize toOptimize
} = results } = results
let { hosts } = results
toOptimize.sort((a, b) => { toOptimize.sort((a, b) => {
a = averages[a.id] a = averages[a.id]
@ -449,11 +449,12 @@ class PerformancePlan extends Plan {
const { id } = exceededHost const { id } = exceededHost
debug(`Try to optimize Host (${exceededHost.id}).`) debug(`Try to optimize Host (${exceededHost.id}).`)
hosts = filter(hosts, host => host.id !== id)
// Search bests combinations for the worst host. // Search bests combinations for the worst host.
await this._optimize({ await this._optimize({
exceededHost, exceededHost,
hosts: filter(hosts, host => host.id !== id), hosts,
hostsAverages: averages hostsAverages: averages
}) })
} }
@ -463,7 +464,7 @@ class PerformancePlan extends Plan {
const vms = await this._getVms(exceededHost.id) const vms = await this._getVms(exceededHost.id)
const vmsAverages = await this._getVmsAverages(vms, exceededHost) const vmsAverages = await this._getVmsAverages(vms, exceededHost)
// Sort vms by cpu usage. (higher to lower) // Sort vms by cpu usage. (lower to higher)
vms.sort((a, b) => vms.sort((a, b) =>
vmsAverages[b.id].cpu - vmsAverages[a.id].cpu vmsAverages[b.id].cpu - vmsAverages[a.id].cpu
) )