fix(Xapi#createCloudInitConfigDrive): delete VDI on failure
This commit is contained in:
@@ -2079,13 +2079,16 @@ export default class Xapi extends XapiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generic Config Drive
|
// Generic Config Drive
|
||||||
async createCloudInitConfigDrive (vmId, srId, config) {
|
@deferrable.onFailure
|
||||||
|
async createCloudInitConfigDrive ($onFailure, vmId, srId, config) {
|
||||||
const vm = this.getObject(vmId)
|
const vm = this.getObject(vmId)
|
||||||
const sr = this.getObject(srId)
|
const sr = this.getObject(srId)
|
||||||
|
|
||||||
// First, create a small VDI (10MB) which will become the ConfigDrive
|
// First, create a small VDI (10MB) which will become the ConfigDrive
|
||||||
const buffer = fatfsBufferInit()
|
const buffer = fatfsBufferInit()
|
||||||
const vdi = await this.createVdi(buffer.length, { name_label: 'XO CloudConfigDrive', name_description: undefined, sr: sr.$ref })
|
const vdi = await this.createVdi(buffer.length, { name_label: 'XO CloudConfigDrive', name_description: undefined, sr: sr.$ref })
|
||||||
|
$onFailure(() => this._deleteVdi(vdi))
|
||||||
|
|
||||||
// Then, generate a FAT fs
|
// Then, generate a FAT fs
|
||||||
const fs = promisifyAll(fatfs.createFileSystem(fatfsBuffer(buffer)))
|
const fs = promisifyAll(fatfs.createFileSystem(fatfsBuffer(buffer)))
|
||||||
// Create Cloud config folders
|
// Create Cloud config folders
|
||||||
|
|||||||
Reference in New Issue
Block a user