@xen-orchestra/backups 0.28.1 → 0.29.1

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/Backup.js CHANGED
@@ -43,6 +43,7 @@ const DEFAULT_VM_SETTINGS = {
43
43
  offlineSnapshot: false,
44
44
  snapshotRetention: 0,
45
45
  timeout: 0,
46
+ useNbd: false,
46
47
  unconditionalSnapshot: false,
47
48
  vmTimeout: 0,
48
49
  }
package/RemoteAdapter.js CHANGED
@@ -537,10 +537,6 @@ class RemoteAdapter {
537
537
  }
538
538
  }
539
539
 
540
- async invalidateVmBackupListCache(vmUuid) {
541
- await this.handler.unlink(this.#getVmBackupsCache(vmUuid))
542
- }
543
-
544
540
  async #getCachabledDataListVmBackups(dir) {
545
541
  debug('generating cache', { path: dir })
546
542
 
@@ -659,9 +655,8 @@ class RemoteAdapter {
659
655
  return path
660
656
  }
661
657
 
662
- async writeVhd(path, input, { checksum = true, validator = noop, writeBlockConcurrency } = {}) {
658
+ async writeVhd(path, input, { checksum = true, validator = noop, writeBlockConcurrency, nbdClient } = {}) {
663
659
  const handler = this._handler
664
-
665
660
  if (this.#useVhdDirectory()) {
666
661
  const dataPath = `${dirname(path)}/data/${uuidv4()}.vhd`
667
662
  await createVhdDirectoryFromStream(handler, dataPath, input, {
@@ -671,6 +666,7 @@ class RemoteAdapter {
671
666
  await input.task
672
667
  return validator.apply(this, arguments)
673
668
  },
669
+ nbdClient,
674
670
  })
675
671
  await VhdAbstract.createAlias(handler, path, dataPath)
676
672
  } else {
package/package.json CHANGED
@@ -8,24 +8,26 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/vatesfr/xen-orchestra.git"
10
10
  },
11
- "version": "0.28.1",
11
+ "version": "0.29.1",
12
12
  "engines": {
13
13
  "node": ">=14.6"
14
14
  },
15
15
  "scripts": {
16
- "postversion": "npm publish --access public"
16
+ "postversion": "npm publish --access public",
17
+ "test": "node--test"
17
18
  },
18
19
  "dependencies": {
19
20
  "@vates/async-each": "^1.0.0",
20
21
  "@vates/cached-dns.lookup": "^1.0.0",
21
22
  "@vates/compose": "^2.1.0",
22
23
  "@vates/decorate-with": "^2.0.0",
23
- "@vates/disposable": "^0.1.2",
24
+ "@vates/disposable": "^0.1.3",
24
25
  "@vates/fuse-vhd": "^1.0.0",
26
+ "@vates/nbd-client": "*",
25
27
  "@vates/parse-duration": "^0.1.1",
26
28
  "@xen-orchestra/async-map": "^0.1.2",
27
- "@xen-orchestra/fs": "^3.1.0",
28
- "@xen-orchestra/log": "^0.4.0",
29
+ "@xen-orchestra/fs": "^3.3.0",
30
+ "@xen-orchestra/log": "^0.5.0",
29
31
  "@xen-orchestra/template": "^0.1.0",
30
32
  "compare-versions": "^5.0.1",
31
33
  "d3-time-format": "^3.0.0",
@@ -40,15 +42,17 @@
40
42
  "promise-toolbox": "^0.21.0",
41
43
  "proper-lockfile": "^4.1.2",
42
44
  "uuid": "^9.0.0",
43
- "vhd-lib": "^4.1.0",
45
+ "vhd-lib": "^4.2.0",
44
46
  "yazl": "^2.5.1"
45
47
  },
46
48
  "devDependencies": {
47
49
  "rimraf": "^3.0.2",
50
+ "sinon": "^14.0.1",
51
+ "test": "^3.2.1",
48
52
  "tmp": "^0.2.1"
49
53
  },
50
54
  "peerDependencies": {
51
- "@xen-orchestra/xapi": "^1.5.0"
55
+ "@xen-orchestra/xapi": "^1.5.2"
52
56
  },
53
57
  "license": "AGPL-3.0-or-later",
54
58
  "author": {
@@ -19,8 +19,9 @@ const { AbstractDeltaWriter } = require('./_AbstractDeltaWriter.js')
19
19
  const { checkVhd } = require('./_checkVhd.js')
20
20
  const { packUuid } = require('./_packUuid.js')
21
21
  const { Disposable } = require('promise-toolbox')
22
+ const NbdClient = require('@vates/nbd-client')
22
23
 
23
- const { warn } = createLogger('xo:backups:DeltaBackupWriter')
24
+ const { debug, warn } = createLogger('xo:backups:DeltaBackupWriter')
24
25
 
25
26
  exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(AbstractDeltaWriter) {
26
27
  async checkBaseVdis(baseUuidToSrcVdi) {
@@ -199,12 +200,30 @@ exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(Ab
199
200
  await checkVhd(handler, parentPath)
200
201
  }
201
202
 
203
+ const vdiRef = vm.$xapi.getObject(vdi.uuid).$ref
204
+
205
+ let nbdClient
206
+ if (!this._backup.config.useNbd) {
207
+ // get nbd if possible
208
+ try {
209
+ // this will always take the first host in the list
210
+ const [nbdInfo] = await vm.$xapi.call('VDI.get_nbd_info', vdiRef)
211
+ nbdClient = new NbdClient(nbdInfo)
212
+ await nbdClient.connect()
213
+ debug(`got nbd connection `, { vdi: vdi.uuid })
214
+ } catch (error) {
215
+ nbdClient = undefined
216
+ debug(`can't connect to nbd server or no server available`, { error })
217
+ }
218
+ }
219
+
202
220
  await adapter.writeVhd(path, deltaExport.streams[`${id}.vhd`], {
203
221
  // no checksum for VHDs, because they will be invalidated by
204
222
  // merges and chainings
205
223
  checksum: false,
206
224
  validator: tmpPath => checkVhd(handler, tmpPath),
207
225
  writeBlockConcurrency: this._backup.config.writeBlockConcurrency,
226
+ nbdClient,
208
227
  })
209
228
 
210
229
  if (isDelta) {
@@ -49,7 +49,6 @@ exports.FullBackupWriter = class FullBackupWriter extends MixinBackupWriter(Abst
49
49
  const dataBasename = basename + '.xva'
50
50
  const dataFilename = backupDir + '/' + dataBasename
51
51
 
52
- const metadataFilename = `${backupDir}/${basename}.json`
53
52
  const metadata = {
54
53
  jobId: job.id,
55
54
  mode: job.mode,