diff --git a/package.json b/package.json index 3c7973cc3..d2d65a64e 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,7 @@ "tmp": "^0.0.31", "uuid": "^3.0.1", "ws": "^3.0.0", - "xen-api": "^0.13.7", + "xen-api": "^0.14.0", "xml2js": "~0.4.17", "xo-acl-resolver": "^0.2.3", "xo-collection": "^0.4.1", diff --git a/src/xapi/index.js b/src/xapi/index.js index 5bfa79934..c41c1f673 100644 --- a/src/xapi/index.js +++ b/src/xapi/index.js @@ -653,6 +653,8 @@ export default class Xapi extends XapiBase { await this.call('VM.hard_shutdown', vm.$ref) } + await this.barrier('VM', vm.$ref) + if (deleteDisks) { // Compute the VDIs list without duplicates. const vdis = {} @@ -999,29 +1001,29 @@ export default class Xapi extends XapiBase { await Promise.all([ // Create VBDs. - Promise.all(mapToArray( + asyncMap( delta.vbds, vbd => this._createVbd(vm, newVdis[vbd.VDI], vbd) - )), + ), // Import VDI contents. - Promise.all(mapToArray( + asyncMap( newVdis, async (vdi, id) => { for (const stream of ensureArray(streams[`${id}.vhd`])) { await this._importVdiContent(vdi, stream, VDI_FORMAT_VHD) } } - )), + ), // Wait for VDI export tasks (if any) termination. - Promise.all(mapToArray( + asyncMap( streams, stream => stream.task - )), + ), // Create VIFs. - Promise.all(mapToArray(delta.vifs, vif => { + asyncMap(delta.vifs, vif => { const network = (vif.$network$uuid && this.getObject(vif.$network$uuid, null)) || networksOnPoolMasterByDevice[vif.device] || @@ -1034,7 +1036,7 @@ export default class Xapi extends XapiBase { vif ) } - })) + }) ]) if (deleteBase && baseVm) { @@ -1867,6 +1869,7 @@ export default class Xapi extends XapiBase { } await Promise.all([ + body.task, body.checksumVerified, this.putResource(body, '/import_raw_vdi/', { host: pbd.host, diff --git a/yarn.lock b/yarn.lock index 4ee76ccea..9742822c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7093,9 +7093,9 @@ xdg-basedir@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" -xen-api@^0.13.7: - version "0.13.7" - resolved "https://registry.yarnpkg.com/xen-api/-/xen-api-0.13.7.tgz#75da4d60e15820501186c816ed993182c4019627" +xen-api@^0.14.0: + version "0.14.0" + resolved "https://registry.yarnpkg.com/xen-api/-/xen-api-0.14.0.tgz#93bfb9f35daca1092237f1a0dfb211005a8e7916" dependencies: babel-polyfill "^6.23.0" blocked "^1.2.1"