fix(vm.rollingDrCopy): avoid duplicates in VMs list (#387)
Fixes vatesfr/xo-web#1464
This commit is contained in:
parent
7bb73bee67
commit
cb1b37326e
@ -690,12 +690,12 @@ export default class {
|
|||||||
const sourceXapi = this._xo.getXapi(vm)
|
const sourceXapi = this._xo.getXapi(vm)
|
||||||
vm = sourceXapi.getObject(vm._xapiId)
|
vm = sourceXapi.getObject(vm._xapiId)
|
||||||
|
|
||||||
const vms = []
|
const vms = {}
|
||||||
forEach(sr.$VDIs, vdi => {
|
forEach(sr.$VDIs, vdi => {
|
||||||
const vbds = vdi.$VBDs
|
const vbds = vdi.$VBDs
|
||||||
const vm = vbds && vbds[0] && vbds[0].$VM
|
const vm = vbds && vbds[0] && vbds[0].$VM
|
||||||
if (vm && reg.test(vm.name_label)) {
|
if (vm && reg.test(vm.name_label)) {
|
||||||
vms.push(vm)
|
vms[vm.$id] = vm
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const olderCopies = sortBy(vms, 'name_label')
|
const olderCopies = sortBy(vms, 'name_label')
|
||||||
@ -706,7 +706,7 @@ export default class {
|
|||||||
})
|
})
|
||||||
await targetXapi.addTag(drCopy.$id, 'Disaster Recovery')
|
await targetXapi.addTag(drCopy.$id, 'Disaster Recovery')
|
||||||
|
|
||||||
await Promise.all(mapToArray(olderCopies.slice(0, -depth), vm =>
|
await Promise.all(mapToArray(olderCopies.slice(0, 1 - depth), vm =>
|
||||||
// Do not consider a failure to delete an old copy as a fatal error.
|
// Do not consider a failure to delete an old copy as a fatal error.
|
||||||
targetXapi.deleteVm(vm.$id)::pCatch(noop)
|
targetXapi.deleteVm(vm.$id)::pCatch(noop)
|
||||||
))
|
))
|
||||||
|
Loading…
Reference in New Issue
Block a user