Merge pull request #188 from vatesfr/olivierlambert-cpu-weight

Ability to set vCPU weight
This commit is contained in:
Julien Fontanet 2016-02-01 16:00:21 +01:00
commit c03a0e857e
3 changed files with 14 additions and 0 deletions

View File

@ -325,6 +325,9 @@ set = $coroutine (params) ->
else
yield xapi.call 'VM.remove_from_other_config', ref, 'auto_poweron'
if 'cpuWeight' of params
yield xapi.setVcpuWeight(vm._xapiId, params.cpuWeight)
# Other fields.
for param, fields of {
'name_label'
@ -362,6 +365,8 @@ set.params = {
# Kernel arguments for PV VM.
PV_args: { type: 'string', optional: true }
cpuWeight: { type: 'integer', optional: true}
}
set.resolve = {

View File

@ -308,6 +308,10 @@ const TRANSFORMS = {
}
}
if (obj.VCPUs_params && obj.VCPUs_params.weight) {
vm.cpuWeight = obj.VCPUs_params.weight
}
if (!isHvm) {
vm.PV_args = obj.PV_args
}

View File

@ -1657,6 +1657,11 @@ export default class Xapi extends XapiBase {
)
}
async setVcpuWeight (vmId, weight) {
const vm = this.getObject(vmId)
await this._updateObjectMapProperty(vm, 'VCPUs_params', {weight})
}
_startVm (vm) {
debug(`Starting VM ${vm.name_label}`)