fix(vm.rollingDrCopy): avoid duplicates in VMs list (#387)

Fixes vatesfr/xo-web#1464
This commit is contained in:
Julien Fontanet 2016-09-05 13:41:20 +02:00 committed by GitHub
parent 7bb73bee67
commit cb1b37326e

View File

@ -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)
)) ))