From 9928d47fa21d51ce9d836684b825cdec05c7e1b5 Mon Sep 17 00:00:00 2001 From: Olivier Lambert Date: Mon, 21 Dec 2015 19:00:36 +0100 Subject: [PATCH] PR comment review --- src/api/vbd.coffee | 4 ++-- src/xapi.js | 7 ++++--- src/xo.js | 10 ++++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/api/vbd.coffee b/src/api/vbd.coffee index 4a80e01e6..e82e58008 100644 --- a/src/api/vbd.coffee +++ b/src/api/vbd.coffee @@ -26,7 +26,7 @@ exports.delete = delete_ disconnect = $coroutine ({vbd}) -> xapi = @getXAPI vbd - yield xapi.disconnectVBD(vbd._xapiRef) + yield xapi.disconnectVbd(vbd._xapiRef) return disconnect.params = { @@ -43,7 +43,7 @@ exports.disconnect = disconnect connect = $coroutine ({vbd}) -> xapi = @getXAPI vbd - yield xapi.connectVBD(vbd._xapiRef) + yield xapi.connectVbd(vbd._xapiRef) return connect.params = { diff --git a/src/xapi.js b/src/xapi.js index 7e7dd4a83..1a0289395 100644 --- a/src/xapi.js +++ b/src/xapi.js @@ -1026,6 +1026,7 @@ export default class Xapi extends XapiBase { let host let snapshotRef + // It's not needed to snapshot the VM to get the metadata if (isVmRunning(vm) && !onlyMetadata) { host = vm.$resident_on snapshotRef = await this._snapshotVm(vm) @@ -1514,11 +1515,11 @@ export default class Xapi extends XapiBase { ) } - async connectVBD (vbdId) { + async connectVbd (vbdId) { await this.call('VBD.plug', vbdId) } - async disconnectVBD (vbdId) { + async disconnectVbd (vbdId) { // TODO: check if VBD is attached before await this.call('VBD.unplug_force', vbdId) } @@ -1526,7 +1527,7 @@ export default class Xapi extends XapiBase { async destroyVbdsFromVm (vmId) { await Promise.all( mapToArray(this.getObject(vmId).$VBDs, async vbd => { - await this.disconnectVBD(vbd.$ref).catch(noop) + await this.disconnectVbd(vbd.$ref).catch(noop) return this.call('VBD.destroy', vbd.$ref) }) ) diff --git a/src/xo.js b/src/xo.js index df6596294..e9b092372 100644 --- a/src/xo.js +++ b/src/xo.js @@ -782,7 +782,7 @@ export default class Xo extends EventEmitter { const files = await fs.readdir(`${path}/${deltaDir}`) const deltaBackups = filter(files, xvaFilter) - Array.prototype.push.apply(backups, mapToArray(deltaBackups, deltaBackup => `${deltaDir}/${deltaBackup}`)) + backups.push(...mapToArray(deltaBackups, deltaBackup => `${deltaDir}/${deltaBackup}`)) } return backups @@ -951,7 +951,7 @@ export default class Xo extends EventEmitter { }) const targetStream = fs.createWriteStream(backupFullPath, { flags: 'wx' }) - sourceStream.on('error', () => targetStream.emit('error')) + sourceStream.on('error', error => targetStream.emit('error', error)) await eventToPromise(sourceStream.pipe(targetStream), 'finish') } catch (e) { // Remove backup. (corrupt) @@ -974,7 +974,8 @@ export default class Xo extends EventEmitter { async _importVdiBackupContent (xapi, file, vdiId) { const [ stream, length ] = await this._openAndwaitReadableFile( - file, 'VDI to import not found in this remote') + file, 'VDI to import not found in this remote' + ) await xapi.importVdiContent(vdiId, stream, { length, @@ -1097,7 +1098,8 @@ export default class Xo extends EventEmitter { async _importVmMetadata (xapi, file) { const [ stream, length ] = await this._openAndwaitReadableFile( - file, 'VM metadata to import not found in this remote') + file, 'VM metadata to import not found in this remote' + ) return await xapi.importVm(stream, length, { onlyMetadata: true }) }