chore: eslint instead of standard

This commit is contained in:
Julien Fontanet
2017-11-17 17:42:48 +01:00
parent 4a6ba998d4
commit 5dfefe8d35
51 changed files with 603 additions and 896 deletions

View File

@@ -21,11 +21,11 @@ export default class DensityPlan extends Plan {
const {
hosts,
toOptimize
toOptimize,
} = results
let {
averages: hostsAverages
averages: hostsAverages,
} = results
const pools = await this._getPlanPools()
@@ -34,11 +34,11 @@ export default class DensityPlan extends Plan {
for (const hostToOptimize of toOptimize) {
const {
id: hostId,
$poolId: poolId
$poolId: poolId,
} = hostToOptimize
const {
master: masterId
master: masterId,
} = pools[poolId]
// Avoid master optimization.
@@ -60,7 +60,7 @@ export default class DensityPlan extends Plan {
for (const dest of hosts) {
const {
id: destId,
$poolId: destPoolId
$poolId: destPoolId,
} = dest
// Destination host != Host to optimize!
@@ -87,9 +87,9 @@ export default class DensityPlan extends Plan {
[ poolMaster ],
poolHosts,
masters,
otherHosts
otherHosts,
],
hostsAverages: clone(hostsAverages)
hostsAverages: clone(hostsAverages),
})
if (simulResults) {
@@ -127,7 +127,7 @@ export default class DensityPlan extends Plan {
const simulResults = {
hostsAverages,
moves: []
moves: [],
}
// Try to find a destination for each VM.
@@ -140,7 +140,7 @@ export default class DensityPlan extends Plan {
vm,
destinations: subDestinations,
hostsAverages,
vmsAverages
vmsAverages,
})
// Destination found.
@@ -164,8 +164,8 @@ export default class DensityPlan extends Plan {
_testMigration ({ vm, destinations, hostsAverages, vmsAverages }) {
const {
_thresholds: {
critical: criticalThreshold
}
critical: criticalThreshold,
},
} = this
// Sort the destinations by available memory. (- -> +)
@@ -192,7 +192,7 @@ export default class DensityPlan extends Plan {
// Available movement.
return {
vm,
destination
destination,
}
}
}
@@ -206,7 +206,7 @@ export default class DensityPlan extends Plan {
mapToArray(moves, move => {
const {
vm,
destination
destination,
} = move
const xapiDest = this.xo.getXapi(destination)
debug(`Migrate VM (${vm.id}) to Host (${destination.id}) from Host (${vm.$container}).`)

View File

@@ -7,11 +7,11 @@ import DensityPlan from './density-plan'
import PerformancePlan from './performance-plan'
import {
DEFAULT_CRITICAL_THRESHOLD_CPU,
DEFAULT_CRITICAL_THRESHOLD_MEMORY_FREE
DEFAULT_CRITICAL_THRESHOLD_MEMORY_FREE,
} from './plan'
import {
EXECUTION_DELAY,
debug
debug,
} from './utils'
// ===================================================================
@@ -37,12 +37,12 @@ export const configurationSchema = {
properties: {
name: {
type: 'string',
title: 'Name'
title: 'Name',
},
mode: {
enum: [ 'Performance mode', 'Density mode' ],
title: 'Mode'
title: 'Mode',
},
pools: {
@@ -51,8 +51,8 @@ export const configurationSchema = {
items: {
type: 'string',
$type: 'Pool'
}
$type: 'Pool',
},
},
thresholds: {
@@ -63,14 +63,14 @@ export const configurationSchema = {
cpu: {
type: 'integer',
title: 'CPU (%)',
default: DEFAULT_CRITICAL_THRESHOLD_CPU
default: DEFAULT_CRITICAL_THRESHOLD_CPU,
},
memoryFree: {
type: 'integer',
title: 'RAM, Free memory (MB)',
default: DEFAULT_CRITICAL_THRESHOLD_MEMORY_FREE
}
}
default: DEFAULT_CRITICAL_THRESHOLD_MEMORY_FREE,
},
},
},
excludedHosts: {
@@ -80,19 +80,19 @@ export const configurationSchema = {
items: {
type: 'string',
$type: 'Host'
}
}
$type: 'Host',
},
},
},
required: [ 'name', 'mode', 'pools' ]
required: [ 'name', 'mode', 'pools' ],
},
minItems: 1
}
minItems: 1,
},
},
additionalProperties: false
additionalProperties: false,
}
// ===================================================================
@@ -102,7 +102,7 @@ export const configurationSchema = {
const makeJob = (cronPattern, fn) => {
const job = {
running: false,
emitter: new EventEmitter()
emitter: new EventEmitter(),
}
job.cron = new CronJob(cronPattern, async () => {

View File

@@ -54,7 +54,7 @@ export default class PerformancePlan extends Plan {
const {
averages,
toOptimize
toOptimize,
} = results
let { hosts } = results
@@ -75,7 +75,7 @@ export default class PerformancePlan extends Plan {
await this._optimize({
exceededHost,
hosts,
hostsAverages: averages
hostsAverages: averages,
})
}
}

View File

@@ -2,7 +2,7 @@ import { filter, includes, map as mapToArray } from 'lodash'
import {
EXECUTION_DELAY,
debug
debug,
} from './utils'
const MINUTES_OF_HISTORICAL_DATA = 30
@@ -58,7 +58,7 @@ function computeRessourcesAverage (objects, objectsStats, nPoints) {
),
nCpus: stats.cpus.length,
memoryFree: computeAverage(stats.memoryFree, nPoints),
memory: computeAverage(stats.memory, nPoints)
memory: computeAverage(stats.memory, nPoints),
}
}
@@ -91,7 +91,7 @@ function setRealCpuAverageOfVms (vms, vmsAverages, nCpus) {
export default class Plan {
constructor (xo, name, poolIds, {
excludedHosts,
thresholds
thresholds,
} = {}) {
this.xo = xo
this._name = name
@@ -99,11 +99,11 @@ export default class Plan {
this._excludedHosts = excludedHosts
this._thresholds = {
cpu: {
critical: numberOrDefault(thresholds && thresholds.cpu, DEFAULT_CRITICAL_THRESHOLD_CPU)
critical: numberOrDefault(thresholds && thresholds.cpu, DEFAULT_CRITICAL_THRESHOLD_CPU),
},
memoryFree: {
critical: numberOrDefault(thresholds && thresholds.memoryFree, DEFAULT_CRITICAL_THRESHOLD_MEMORY_FREE) * 1024
}
critical: numberOrDefault(thresholds && thresholds.memoryFree, DEFAULT_CRITICAL_THRESHOLD_MEMORY_FREE) * 1024,
},
}
for (const key in this._thresholds) {
@@ -157,7 +157,7 @@ export default class Plan {
return {
toOptimize,
averages: avgWithRatio,
hosts
hosts,
}
}
@@ -213,7 +213,7 @@ export default class Plan {
hostsStats[host.id] = {
nPoints: hostStats.stats.cpus[0].length,
stats: hostStats.stats,
averages: {}
averages: {},
}
})
))
@@ -229,7 +229,7 @@ export default class Plan {
vmsStats[vm.id] = {
nPoints: vmStats.stats.cpus[0].length,
stats: vmStats.stats,
averages: {}
averages: {},
}
})
))