Merge pull request #274 from vatesfr/abhamonr-set-vm-ram-min-max-values

api.vm: Set the min/max ram values.
This commit is contained in:
Julien Fontanet 2016-04-07 10:08:34 +02:00
commit 71741e144e

View File

@ -407,6 +407,15 @@ set = $coroutine (params) ->
resourceSet = xapi.xo.getData(ref, 'resourceSet') resourceSet = xapi.xo.getData(ref, 'resourceSet')
if 'memoryMin' of params
memoryMin = parseSize(params.memoryMin)
yield xapi.call 'VM.set_memory_static_min', ref, "#{memoryMin}"
yield xapi.call 'VM.set_memory_dynamic_min', ref, "#{memoryMin}"
if 'memoryMax' of params
memoryMax = parseSize(params.memoryMax)
yield xapi.call 'VM.set_memory_static_max', ref, "#{memoryMax}"
# Memory. # Memory.
if 'memory' of params if 'memory' of params
memory = parseSize(params.memory) memory = parseSize(params.memory)
@ -424,9 +433,7 @@ set = $coroutine (params) ->
"for a running VM" "for a running VM"
) )
if memory < VM.memory.dynamic[0] if memory > VM.memory.static[1]
yield xapi.call 'VM.set_memory_dynamic_min', ref, "#{memory}"
else if memory > VM.memory.static[1]
yield xapi.call 'VM.set_memory_static_max', ref, "#{memory}" yield xapi.call 'VM.set_memory_static_max', ref, "#{memory}"
if resourceSet? if resourceSet?
yield @allocateLimitsInResourceSet({ yield @allocateLimitsInResourceSet({
@ -519,6 +526,12 @@ set.params = {
# Note: static_min dynamic_min dynamic_max static_max # Note: static_min dynamic_min dynamic_max static_max
memory: { type: ['integer', 'string'], optional: true } memory: { type: ['integer', 'string'], optional: true }
# Set static_min & dynamic_min
memoryMin: { type: ['integer', 'string'], optional: true }
# Set static_max
memoryMax: { type: ['integer', 'string'], optional: true }
# Kernel arguments for PV VM. # Kernel arguments for PV VM.
PV_args: { type: 'string', optional: true } PV_args: { type: 'string', optional: true }