Expose XAPI error messages in pool.mergeInto().
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import {JsonRpcError} from '../api-errors'
|
||||||
import {extractProperty} from '../utils'
|
import {extractProperty} from '../utils'
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
@@ -80,7 +81,12 @@ export {uploadPatch as patch}
|
|||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
export async function mergeInto ({ source, target, force }) {
|
export async function mergeInto ({ source, target, force }) {
|
||||||
|
try {
|
||||||
await this.mergeXenPools(source.id, target.id, force)
|
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 = {
|
mergeInto.params = {
|
||||||
|
|||||||
@@ -881,10 +881,10 @@ export default class Xo extends EventEmitter {
|
|||||||
return xapi
|
return xapi
|
||||||
}
|
}
|
||||||
|
|
||||||
async mergeXenPools (sourceId, targetId) {
|
async mergeXenPools (sourceId, targetId, force = false) {
|
||||||
const sourceXapi = this.getXAPI(sourceId)
|
const sourceXapi = this.getXAPI(sourceId)
|
||||||
const {
|
const {
|
||||||
_auth: { username, password },
|
_auth: { user, password },
|
||||||
_url: { hostname }
|
_url: { hostname }
|
||||||
} = this.getXAPI(targetId)
|
} = this.getXAPI(targetId)
|
||||||
|
|
||||||
@@ -903,7 +903,7 @@ export default class Xo extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await sourceXapi.joinPool(hostname, username, password)
|
await sourceXapi.joinPool(hostname, user, password, force)
|
||||||
} finally {
|
} finally {
|
||||||
await this.disconnectXenServer(sourceId)
|
await this.disconnectXenServer(sourceId)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user