various changes

This commit is contained in:
heafalan
2019-08-05 16:27:15 +02:00
parent 9114aa5b11
commit 23fb486a40
3 changed files with 24 additions and 7 deletions

View File

@@ -11,6 +11,7 @@
[vms]
default = ''
vmToBackup = ''
[templates]
default = ''

View File

@@ -166,11 +166,10 @@ class XoConnection extends Xo {
const backupsByRemote = await xo.call('backupNg.listVmBackups', {
remotes,
})
forOwn(backupsByRemote, (remote, remoteId) => {
forOwn(backupsByRemote, (backupsByVm, remoteId) => {
backups[remoteId] = []
forOwn(remote, backupsByVm => {
forOwn(
backupsByVm,
forOwn(backupsByVm, vmBackups => {
vmBackups.forEach(
({ jobId: backupJobId, scheduleId: backupScheduleId, id }) => {
if (jobId === backupJobId && scheduleId === backupScheduleId) {
this._tempResourceDisposers.push('backupNg.deleteVmBackup', {

View File

@@ -507,14 +507,22 @@ describe('backupNg', () => {
message: 'backup',
status: 'success',
})
let vmTaskValidated = false
const numberOfTasks = {
export: 0,
merge: 0,
snapshot: 0,
transfer: 0,
VM: 0,
}
tasks.forEach(({ tasks, ...vmTask }) => {
if (vmTask.data !== undefined && vmTask.data.type === 'VM') {
expect(vmTaskValidated).toBe(false)
validateVmTask(vmTask, vmId, { status: 'success' })
numberOfTasks.VM++
tasks.forEach(({ tasks, ...subTask }) => {
if (subTask.message === 'snapshot') {
validateSnapshotTask(subTask, { status: 'success' })
numberOfTasks.snapshot++
}
if (subTask.message === 'export') {
validateExportTask(subTask, remotes, {
@@ -525,6 +533,7 @@ describe('backupNg', () => {
},
status: 'success',
})
numberOfTasks.export++
let mergeTaskKey, transferTaskKey
tasks.forEach((operationTask, key) => {
if (
@@ -537,8 +546,10 @@ describe('backupNg', () => {
})
if (operationTask.message === 'transfer') {
mergeTaskKey = key
numberOfTasks.merge++
} else {
transferTaskKey = key
numberOfTasks.transfer++
}
}
})
@@ -549,9 +560,15 @@ describe('backupNg', () => {
).toBe(true)
}
})
vmTaskValidated = true
}
})
expect(numberOfTasks).toEqual({
export: 1,
merge: 1,
snapshot: 1,
transfer: 1,
VM: 1,
})
})
})
})