@xen-orchestra/backups 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ImportVmBackup.js +6 -1
- package/RemoteAdapter.js +6 -4
- package/_deltaVm.js +23 -12
- package/package.json +8 -4
package/ImportVmBackup.js
CHANGED
|
@@ -30,7 +30,12 @@ exports.ImportVmBackup = class ImportVmBackup {
|
|
|
30
30
|
} else {
|
|
31
31
|
assert.strictEqual(metadata.mode, 'delta')
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const ignoredVdis = new Set(
|
|
34
|
+
Object.entries(this._importDeltaVmSettings.mapVdisSrs)
|
|
35
|
+
.filter(([_, srUuid]) => srUuid === null)
|
|
36
|
+
.map(([vdiUuid]) => vdiUuid)
|
|
37
|
+
)
|
|
38
|
+
backup = await adapter.readDeltaVmBackup(metadata, ignoredVdis)
|
|
34
39
|
Object.values(backup.streams).forEach(stream => watchStreamSize(stream, sizeContainer))
|
|
35
40
|
}
|
|
36
41
|
|
package/RemoteAdapter.js
CHANGED
|
@@ -6,6 +6,7 @@ const fromCallback = require('promise-toolbox/fromCallback')
|
|
|
6
6
|
const fromEvent = require('promise-toolbox/fromEvent')
|
|
7
7
|
const pDefer = require('promise-toolbox/defer')
|
|
8
8
|
const groupBy = require('lodash/groupBy.js')
|
|
9
|
+
const pickBy = require('lodash/pickBy.js')
|
|
9
10
|
const { dirname, join, normalize, resolve } = require('path')
|
|
10
11
|
const { createLogger } = require('@xen-orchestra/log')
|
|
11
12
|
const { Constants, createVhdDirectoryFromStream, openVhd, VhdAbstract, VhdDirectory, VhdSynthetic } = require('vhd-lib')
|
|
@@ -576,14 +577,15 @@ class RemoteAdapter {
|
|
|
576
577
|
return stream
|
|
577
578
|
}
|
|
578
579
|
|
|
579
|
-
async readDeltaVmBackup(metadata) {
|
|
580
|
+
async readDeltaVmBackup(metadata, ignoredVdis) {
|
|
580
581
|
const handler = this._handler
|
|
581
|
-
const { vbds,
|
|
582
|
+
const { vbds, vhds, vifs, vm } = metadata
|
|
582
583
|
const dir = dirname(metadata._filename)
|
|
584
|
+
const vdis = ignoredVdis === undefined ? metadata.vdis : pickBy(metadata.vdis, vdi => !ignoredVdis.has(vdi.uuid))
|
|
583
585
|
|
|
584
586
|
const streams = {}
|
|
585
|
-
await asyncMapSettled(Object.keys(vdis), async
|
|
586
|
-
streams[`${
|
|
587
|
+
await asyncMapSettled(Object.keys(vdis), async ref => {
|
|
588
|
+
streams[`${ref}.vhd`] = await this._createSyntheticStream(handler, join(dir, vhds[ref]))
|
|
587
589
|
})
|
|
588
590
|
|
|
589
591
|
return {
|
package/_deltaVm.js
CHANGED
|
@@ -11,6 +11,8 @@ const { createVhdStreamWithLength } = require('vhd-lib')
|
|
|
11
11
|
const { defer } = require('golike-defer')
|
|
12
12
|
|
|
13
13
|
const { cancelableMap } = require('./_cancelableMap.js')
|
|
14
|
+
const { Task } = require('./Task.js')
|
|
15
|
+
const { pick } = require('lodash')
|
|
14
16
|
|
|
15
17
|
const TAG_BASE_DELTA = 'xo:base_delta'
|
|
16
18
|
exports.TAG_BASE_DELTA = TAG_BASE_DELTA
|
|
@@ -20,6 +22,9 @@ exports.TAG_COPY_SRC = TAG_COPY_SRC
|
|
|
20
22
|
|
|
21
23
|
const ensureArray = value => (value === undefined ? [] : Array.isArray(value) ? value : [value])
|
|
22
24
|
const resolveUuid = async (xapi, cache, uuid, type) => {
|
|
25
|
+
if (uuid == null) {
|
|
26
|
+
return uuid
|
|
27
|
+
}
|
|
23
28
|
let ref = cache.get(uuid)
|
|
24
29
|
if (ref === undefined) {
|
|
25
30
|
ref = await xapi.call(`${type}.get_by_uuid`, uuid)
|
|
@@ -195,19 +200,25 @@ exports.importDeltaVm = defer(async function importDeltaVm(
|
|
|
195
200
|
let suspendVdi
|
|
196
201
|
if (vmRecord.power_state === 'Suspended') {
|
|
197
202
|
const vdi = vdiRecords[vmRecord.suspend_VDI]
|
|
198
|
-
|
|
199
|
-
'VDI',
|
|
200
|
-
|
|
201
|
-
...vdi,
|
|
202
|
-
other_config: {
|
|
203
|
-
...vdi.other_config,
|
|
204
|
-
[TAG_BASE_DELTA]: undefined,
|
|
205
|
-
[TAG_COPY_SRC]: vdi.uuid,
|
|
206
|
-
},
|
|
207
|
-
sr: mapVdisSrRefs[vdi.uuid] ?? sr.$ref,
|
|
203
|
+
if (vdi === undefined) {
|
|
204
|
+
Task.warning('Suspend VDI not available for this suspended VM', {
|
|
205
|
+
vm: pick(vmRecord, 'uuid', 'name_label'),
|
|
208
206
|
})
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
} else {
|
|
208
|
+
suspendVdi = await xapi.getRecord(
|
|
209
|
+
'VDI',
|
|
210
|
+
await xapi.VDI_create({
|
|
211
|
+
...vdi,
|
|
212
|
+
other_config: {
|
|
213
|
+
...vdi.other_config,
|
|
214
|
+
[TAG_BASE_DELTA]: undefined,
|
|
215
|
+
[TAG_COPY_SRC]: vdi.uuid,
|
|
216
|
+
},
|
|
217
|
+
sr: mapVdisSrRefs[vdi.uuid] ?? sr.$ref,
|
|
218
|
+
})
|
|
219
|
+
)
|
|
220
|
+
$defer.onFailure(() => suspendVdi.$destroy())
|
|
221
|
+
}
|
|
211
222
|
}
|
|
212
223
|
|
|
213
224
|
// 1. Create the VM.
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/vatesfr/xen-orchestra.git"
|
|
10
10
|
},
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.21.0",
|
|
12
12
|
"engines": {
|
|
13
13
|
"node": ">=14.6"
|
|
14
14
|
},
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@vates/compose": "^2.1.0",
|
|
20
|
-
"@vates/decorate-with": "^
|
|
20
|
+
"@vates/decorate-with": "^2.0.0",
|
|
21
21
|
"@vates/disposable": "^0.1.1",
|
|
22
22
|
"@vates/parse-duration": "^0.1.1",
|
|
23
23
|
"@xen-orchestra/async-map": "^0.1.2",
|
|
24
|
-
"@xen-orchestra/fs": "^0.
|
|
24
|
+
"@xen-orchestra/fs": "^1.0.0",
|
|
25
25
|
"@xen-orchestra/log": "^0.3.0",
|
|
26
26
|
"@xen-orchestra/template": "^0.1.0",
|
|
27
27
|
"compare-versions": "^4.0.1",
|
|
@@ -39,8 +39,12 @@
|
|
|
39
39
|
"vhd-lib": "^3.1.0",
|
|
40
40
|
"yazl": "^2.5.1"
|
|
41
41
|
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"rimraf": "^3.0.2",
|
|
44
|
+
"tmp": "^0.2.1"
|
|
45
|
+
},
|
|
42
46
|
"peerDependencies": {
|
|
43
|
-
"@xen-orchestra/xapi": "^0.
|
|
47
|
+
"@xen-orchestra/xapi": "^0.10.0"
|
|
44
48
|
},
|
|
45
49
|
"license": "AGPL-3.0-or-later",
|
|
46
50
|
"author": {
|