Compare commits
1 Commits
fix_vmware
...
restApi-cr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42cc6d4dd6 |
@@ -399,6 +399,16 @@ class Vm {
|
|||||||
return ref
|
return ref
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async createFull($defer, { clone = true, boot = false, name_label, name_description, template: templateRef }) {
|
||||||
|
// Clones the template.
|
||||||
|
const vmRef = await (
|
||||||
|
clone
|
||||||
|
? this.callAsync('VM.clone', templateRef, name_label)
|
||||||
|
: this.callAsync('VM.copy', templateRef, name_label, '')
|
||||||
|
).then(extractOpaqueRef)
|
||||||
|
$defer.onFailure(() => this.VM_destroy(vmRef))
|
||||||
|
}
|
||||||
|
|
||||||
async destroy(
|
async destroy(
|
||||||
vmRef,
|
vmRef,
|
||||||
{ deleteDisks = true, force = false, bypassBlockedOperation = force, forceDeleteDefaultTemplate = force } = {}
|
{ deleteDisks = true, force = false, bypassBlockedOperation = force, forceDeleteDefaultTemplate = force } = {}
|
||||||
@@ -699,6 +709,7 @@ export default Vm
|
|||||||
decorateClass(Vm, {
|
decorateClass(Vm, {
|
||||||
checkpoint: defer,
|
checkpoint: defer,
|
||||||
create: defer,
|
create: defer,
|
||||||
|
createFull: defer,
|
||||||
export: defer,
|
export: defer,
|
||||||
snapshot: defer,
|
snapshot: defer,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ const methods = {
|
|||||||
name_label, // eslint-disable-line camelcase
|
name_label, // eslint-disable-line camelcase
|
||||||
nameLabel = name_label, // eslint-disable-line camelcase
|
nameLabel = name_label, // eslint-disable-line camelcase
|
||||||
|
|
||||||
|
cloudConfig,
|
||||||
|
networkConfig,
|
||||||
|
|
||||||
clone = true,
|
clone = true,
|
||||||
installRepository = undefined,
|
installRepository = undefined,
|
||||||
vdis = undefined,
|
vdis = undefined,
|
||||||
@@ -217,6 +220,35 @@ const methods = {
|
|||||||
await this.createVgpu(vm, gpuGroup, vgpuType)
|
await this.createVgpu(vm, gpuGroup, vgpuType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create cloud config drive
|
||||||
|
let cloudConfigVdiUuid
|
||||||
|
if (params.cloudConfig != null) {
|
||||||
|
// Find the SR of the first VDI.
|
||||||
|
let srId
|
||||||
|
forEach(vm.$VBDs, vbdId => {
|
||||||
|
const vbd = this.getObject(vbdId)
|
||||||
|
const vdiId = vbd.VDI
|
||||||
|
if (!vbd.is_cd_drive && vdiId !== undefined) {
|
||||||
|
srId = this.getObject(vdiId).$SR
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
try {
|
||||||
|
cloudConfigVdiUuid = params.coreOs
|
||||||
|
? await xapi.createCoreOsCloudInitConfigDrive(vm.id, srId, params.cloudConfig)
|
||||||
|
: await xapi.createCloudInitConfigDrive(vm.id, srId, params.cloudConfig, params.networkConfig)
|
||||||
|
} catch (error) {
|
||||||
|
log.warn('vm.create', { vmId: vm.id, srId, error })
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.createVtpm) {
|
||||||
|
const vtpmRef = await xapi.VTPM_create({ VM: xapiVm.$ref })
|
||||||
|
$defer.onFailure(() => xapi.call('VTPM.destroy', vtpmRef))
|
||||||
|
}
|
||||||
|
|
||||||
// wait for the record with all the VBDs and VIFs
|
// wait for the record with all the VBDs and VIFs
|
||||||
return this.barrier(vm.$ref)
|
return this.barrier(vm.$ref)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -297,6 +297,15 @@ export default class RestApi {
|
|||||||
auto_poweron: { type: 'boolean', optional: true },
|
auto_poweron: { type: 'boolean', optional: true },
|
||||||
boot: { type: 'boolean', default: false },
|
boot: { type: 'boolean', default: false },
|
||||||
clone: { type: 'boolean', default: true },
|
clone: { type: 'boolean', default: true },
|
||||||
|
cloud_init: {
|
||||||
|
type: 'object',
|
||||||
|
default: {},
|
||||||
|
properties: {
|
||||||
|
cloud_config: { type: 'string', optional: true },
|
||||||
|
destroy_after_boot: { type: 'boolean', default: false },
|
||||||
|
network_config: { type: 'string', optional: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
install: {
|
install: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
optional: true,
|
optional: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user