feat(xo-server): add AMAP data on VDI export/import errors (#3172)

Fixes #3157
This commit is contained in:
Julien Fontanet 2018-07-12 11:07:28 +02:00 committed by GitHub
parent 961babe6a3
commit 3241c426a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1930,7 +1930,8 @@ export default class Xapi extends XapiBase {
@concurrency(12, stream => stream.then(stream => fromEvent(stream, 'end'))) @concurrency(12, stream => stream.then(stream => fromEvent(stream, 'end')))
@cancelable @cancelable
_exportVdi ($cancelToken, vdi, base, format = VDI_FORMAT_VHD) { _exportVdi ($cancelToken, vdi, base, format = VDI_FORMAT_VHD) {
const host = vdi.$SR.$PBDs[0].$host const sr = vdi.$SR
const host = sr.$PBDs[0].$host
const query = { const query = {
format, format,
@ -1950,29 +1951,46 @@ export default class Xapi extends XapiBase {
host, host,
query, query,
task: this.createTask('VDI Export', vdi.name_label), task: this.createTask('VDI Export', vdi.name_label),
}).catch(error => {
// augment the error with as much relevant info as possible
error.host = host
error.SR = sr
error.VDI = vdi
throw error
}) })
} }
// ----------------------------------------------------------------- // -----------------------------------------------------------------
async _importVdiContent (vdi, body, format = VDI_FORMAT_VHD) { async _importVdiContent (vdi, body, format = VDI_FORMAT_VHD) {
const pbd = find(vdi.$SR.$PBDs, 'currently_attached') const sr = vdi.$SR
const pbd = find(sr.$PBDs, 'currently_attached')
if (pbd === undefined) { if (pbd === undefined) {
throw new Error('no valid PBDs found') throw new Error('no valid PBDs found')
} }
const host = pbd.$HOST
await Promise.all([ await Promise.all([
body.task, body.task,
body.checksumVerified, body.checksumVerified,
this.putResource(body, '/import_raw_vdi/', { this.putResource(body, '/import_raw_vdi/', {
host: pbd.host, host,
query: { query: {
format, format,
vdi: vdi.$ref, vdi: vdi.$ref,
}, },
task: this.createTask('VDI Content Import', vdi.name_label), task: this.createTask('VDI Content Import', vdi.name_label),
}), }),
]) ]).catch(error => {
// augment the error with as much relevant info as possible
error.host = host
error.SR = sr
error.VDI = vdi
throw error
})
} }
importVdiContent (vdiId, body, { format } = {}) { importVdiContent (vdiId, body, { format } = {}) {