From ee1105b6dd4528b8107dd115e4ca2ab8a9e73b6b Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Wed, 27 Apr 2016 09:37:30 +0200 Subject: [PATCH] fix(Xapi#importVdiContent): find first attached PBD (#279) --- src/xapi.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/xapi.js b/src/xapi.js index 0b42358cd..405fb9f7c 100644 --- a/src/xapi.js +++ b/src/xapi.js @@ -2164,14 +2164,17 @@ export default class Xapi extends XapiBase { vdi: vdi.$ref } - const host = vdi.$SR.$PBDs[0].$host + const pbd = find(vdi.$SR.$PBDs, 'currently_attached') + if (!pbd) { + throw new Error('no valid PBDs found') + } const task = this._watchTask(taskRef) await Promise.all([ stream.checksumVerified, task, put(stream, { - hostname: host.address, + hostname: pbd.$host.address, method: 'put', path: '/import_raw_vdi/', query