From 69751aa415a66f2d32427a6b2fabfed736e96f8d Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Wed, 30 Sep 2015 17:36:25 +0200 Subject: [PATCH] Expose XAPI error messages in pool.mergeInto(). --- src/api/pool.js | 8 +++++++- src/xo.js | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/api/pool.js b/src/api/pool.js index e00c7eee5..08e414946 100644 --- a/src/api/pool.js +++ b/src/api/pool.js @@ -1,3 +1,4 @@ +import {JsonRpcError} from '../api-errors' import {extractProperty} from '../utils' // =================================================================== @@ -80,7 +81,12 @@ export {uploadPatch as patch} // ------------------------------------------------------------------- export async function mergeInto ({ source, target, force }) { - await this.mergeXenPools(source.id, target.id, force) + try { + await this.mergeXenPools(source.id, target.id, force) + } catch (e) { + // FIXME: should we expose plain XAPI error messages? + throw new JsonRpcError(e.message) + } } mergeInto.params = { diff --git a/src/xo.js b/src/xo.js index a3cfb79ea..c54a0c54d 100644 --- a/src/xo.js +++ b/src/xo.js @@ -881,10 +881,10 @@ export default class Xo extends EventEmitter { return xapi } - async mergeXenPools (sourceId, targetId) { + async mergeXenPools (sourceId, targetId, force = false) { const sourceXapi = this.getXAPI(sourceId) const { - _auth: { username, password }, + _auth: { user, password }, _url: { hostname } } = this.getXAPI(targetId) @@ -903,7 +903,7 @@ export default class Xo extends EventEmitter { } try { - await sourceXapi.joinPool(hostname, username, password) + await sourceXapi.joinPool(hostname, user, password, force) } finally { await this.disconnectXenServer(sourceId) }