@xen-orchestra/backups 0.19.1 → 0.20.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 +2 -2
- package/_deltaVm.js +16 -2
- package/package.json +1 -1
package/ImportVmBackup.js
CHANGED
|
@@ -8,9 +8,9 @@ const { Task } = require('./Task.js')
|
|
|
8
8
|
const { watchStreamSize } = require('./_watchStreamSize.js')
|
|
9
9
|
|
|
10
10
|
exports.ImportVmBackup = class ImportVmBackup {
|
|
11
|
-
constructor({ adapter, metadata, srUuid, xapi, settings: { newMacAddresses } = {} }) {
|
|
11
|
+
constructor({ adapter, metadata, srUuid, xapi, settings: { newMacAddresses, mapVdisSrs } = {} }) {
|
|
12
12
|
this._adapter = adapter
|
|
13
|
-
this._importDeltaVmSettings = { newMacAddresses }
|
|
13
|
+
this._importDeltaVmSettings = { newMacAddresses, mapVdisSrs }
|
|
14
14
|
this._metadata = metadata
|
|
15
15
|
this._srUuid = srUuid
|
|
16
16
|
this._xapi = xapi
|
package/_deltaVm.js
CHANGED
|
@@ -19,6 +19,14 @@ const TAG_COPY_SRC = 'xo:copy_of'
|
|
|
19
19
|
exports.TAG_COPY_SRC = TAG_COPY_SRC
|
|
20
20
|
|
|
21
21
|
const ensureArray = value => (value === undefined ? [] : Array.isArray(value) ? value : [value])
|
|
22
|
+
const resolveUuid = async (xapi, cache, uuid, type) => {
|
|
23
|
+
let ref = cache.get(uuid)
|
|
24
|
+
if (ref === undefined) {
|
|
25
|
+
ref = await xapi.call(`${type}.get_by_uuid`, uuid)
|
|
26
|
+
cache.set(uuid, ref)
|
|
27
|
+
}
|
|
28
|
+
return ref
|
|
29
|
+
}
|
|
22
30
|
|
|
23
31
|
exports.exportDeltaVm = async function exportDeltaVm(
|
|
24
32
|
vm,
|
|
@@ -167,6 +175,12 @@ exports.importDeltaVm = defer(async function importDeltaVm(
|
|
|
167
175
|
}
|
|
168
176
|
}
|
|
169
177
|
|
|
178
|
+
const cache = new Map()
|
|
179
|
+
const mapVdisSrRefs = {}
|
|
180
|
+
for (const [vdiUuid, srUuid] of Object.entries(mapVdisSrs)) {
|
|
181
|
+
mapVdisSrRefs[vdiUuid] = await resolveUuid(xapi, cache, srUuid, 'SR')
|
|
182
|
+
}
|
|
183
|
+
|
|
170
184
|
const baseVdis = {}
|
|
171
185
|
baseVm &&
|
|
172
186
|
baseVm.$VBDs.forEach(vbd => {
|
|
@@ -190,7 +204,7 @@ exports.importDeltaVm = defer(async function importDeltaVm(
|
|
|
190
204
|
[TAG_BASE_DELTA]: undefined,
|
|
191
205
|
[TAG_COPY_SRC]: vdi.uuid,
|
|
192
206
|
},
|
|
193
|
-
sr:
|
|
207
|
+
sr: mapVdisSrRefs[vdi.uuid] ?? sr.$ref,
|
|
194
208
|
})
|
|
195
209
|
)
|
|
196
210
|
$defer.onFailure(() => suspendVdi.$destroy())
|
|
@@ -257,7 +271,7 @@ exports.importDeltaVm = defer(async function importDeltaVm(
|
|
|
257
271
|
[TAG_BASE_DELTA]: undefined,
|
|
258
272
|
[TAG_COPY_SRC]: vdi.uuid,
|
|
259
273
|
},
|
|
260
|
-
SR:
|
|
274
|
+
SR: mapVdisSrRefs[vdi.uuid] ?? sr.$ref,
|
|
261
275
|
})
|
|
262
276
|
)
|
|
263
277
|
$defer.onFailure(() => newVdi.$destroy())
|