resourceSet.set(): better handling of limits.
This commit is contained in:
parent
c6f7290f92
commit
208ea04fd5
@ -69,8 +69,9 @@ create = $coroutine ({
|
||||
|
||||
limits = {
|
||||
cpus: template.CPUs.number,
|
||||
disk: 0,
|
||||
memory: template.memory.static[1],
|
||||
disk: 0
|
||||
vms: 1
|
||||
}
|
||||
objectIds = []
|
||||
|
||||
@ -384,7 +385,7 @@ set = $coroutine (params) ->
|
||||
yield xapi.call 'VM.set_memory_static_max', ref, "#{memory}"
|
||||
if resourceSet?
|
||||
yield @allocateLimitsInResourceSet({
|
||||
memory: memory - memoryVM.memory.size
|
||||
memory: memory - VM.memory.size
|
||||
}, resourceSet)
|
||||
yield xapi.call 'VM.set_memory_dynamic_max', ref, "#{memory}"
|
||||
|
||||
|
@ -125,10 +125,23 @@ export default class {
|
||||
set.objects = objects
|
||||
}
|
||||
if (limits) {
|
||||
set.limits = map(limits, (quantity, limit) => ({
|
||||
available: quantity,
|
||||
total: quantity
|
||||
}))
|
||||
const previousLimits = set.limits
|
||||
set.limits = map(limits, (quantity, id) => {
|
||||
const previous = previousLimits[id]
|
||||
if (!previous) {
|
||||
return {
|
||||
available: quantity,
|
||||
total: quantity
|
||||
}
|
||||
}
|
||||
|
||||
const { available, total } = previous
|
||||
|
||||
return {
|
||||
available: available - total + quantity,
|
||||
total: quantity
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
await this._save(set)
|
||||
|
Loading…
Reference in New Issue
Block a user