Expose XAPI error messages in pool.mergeInto().

This commit is contained in:
Julien Fontanet 2015-09-30 17:36:25 +02:00
parent 9ef0337807
commit 69751aa415
2 changed files with 10 additions and 4 deletions

View File

@ -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 = {

View File

@ -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)
}