parent
56cf6fba2f
commit
a43dfc62c2
@ -211,7 +211,7 @@ create.params = {
|
||||
resourceSet: {
|
||||
type: 'string',
|
||||
optional: true
|
||||
},
|
||||
}
|
||||
|
||||
installation: {
|
||||
type: 'object'
|
||||
@ -222,6 +222,16 @@ create.params = {
|
||||
}
|
||||
}
|
||||
|
||||
vgpuType: {
|
||||
type: 'string',
|
||||
optional: true
|
||||
}
|
||||
|
||||
gpuGroup: {
|
||||
type: 'string',
|
||||
optional: true
|
||||
}
|
||||
|
||||
# Name/description of the new VM.
|
||||
name_label: { type: 'string' }
|
||||
name_description: { type: 'string', optional: true }
|
||||
@ -310,6 +320,8 @@ create.params = {
|
||||
|
||||
create.resolve = {
|
||||
template: ['template', 'VM-template', ''],
|
||||
vgpuType: ['vgpuType', 'vgpuType', ''],
|
||||
gpuGroup: ['gpuGroup', 'gpuGroup', ''],
|
||||
}
|
||||
|
||||
exports.create = create
|
||||
@ -1352,6 +1364,43 @@ createCloudInitConfigDrive.resolve = {
|
||||
}
|
||||
exports.createCloudInitConfigDrive = createCloudInitConfigDrive
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
createVgpu = $coroutine ({ vm, gpuGroup, vgpuType }) ->
|
||||
# TODO: properly handle device. Can a VM have 2 vGPUS?
|
||||
yield @getXapi(vm).createVgpu(vm._xapiId, gpuGroup._xapiId, vgpuType._xapiId)
|
||||
|
||||
return true
|
||||
|
||||
createVgpu.params = {
|
||||
vm: { type: 'string' },
|
||||
gpuGroup: { type: 'string' },
|
||||
vgpuType: { type: 'string' }
|
||||
}
|
||||
|
||||
createVgpu.resolve = {
|
||||
vm: ['vm', 'VM', 'administrate'],
|
||||
gpuGroup: ['gpuGroup', 'gpuGroup', ''],
|
||||
vgpuType: ['vgpuType', 'vgpuType', '']
|
||||
}
|
||||
exports.createVgpu = createVgpu
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
deleteVgpu = $coroutine ({ vgpu }) ->
|
||||
yield @getXapi(vgpu).deleteVgpu(vgpu._xapiId)
|
||||
|
||||
return true
|
||||
|
||||
deleteVgpu.params = {
|
||||
vgpu: { type: 'string' }
|
||||
}
|
||||
|
||||
deleteVgpu.resolve = {
|
||||
vgpu: ['vgpu', 'vgpu', '']
|
||||
}
|
||||
exports.deleteVgpu = deleteVgpu
|
||||
|
||||
#=====================================================================
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
|
@ -675,6 +675,7 @@ const TRANSFORMS = {
|
||||
|
||||
dom0Access: obj.dom0_access,
|
||||
enabledVgpuTypes: link(obj, 'enabled_VGPU_types'),
|
||||
gpuGroup: link(obj, 'GPU_group'),
|
||||
isSystemDisplayDevice: Boolean(obj.is_system_display_device),
|
||||
pci: link(obj, 'PCI'),
|
||||
supportedVgpuMaxCapcities: link(obj, 'supported_VGPU_max_capacities'),
|
||||
@ -692,7 +693,7 @@ const TRANSFORMS = {
|
||||
|
||||
vgpu (obj) {
|
||||
return {
|
||||
type: 'VGPU',
|
||||
type: 'vgpu',
|
||||
|
||||
currentlyAttached: Boolean(obj.currently_attached),
|
||||
device: obj.device,
|
||||
@ -730,12 +731,12 @@ const TRANSFORMS = {
|
||||
|
||||
experimental: Boolean(obj.experimental),
|
||||
framebufferSize: obj.framebuffer_size,
|
||||
gpuGroup: link(obj, 'GPU_group'),
|
||||
gpuGroups: link(obj, 'enabled_on_GPU_groups'),
|
||||
maxHeads: obj.max_heads,
|
||||
maxResolutionX: obj.max_resolution_x,
|
||||
maxResolutionY: obj.max_resolution_y,
|
||||
modelName: obj.model_name,
|
||||
pgpu: link(obj, 'PGPU'),
|
||||
pgpus: link(obj, 'enabled_on_PGPUs'),
|
||||
vendorName: obj.vendor_name,
|
||||
vgpus: link(obj, 'VGPUs')
|
||||
}
|
||||
|
9
src/xapi/mixins/gpu.js
Normal file
9
src/xapi/mixins/gpu.js
Normal file
@ -0,0 +1,9 @@
|
||||
export default {
|
||||
createVgpu (vm, gpuGroup, vgpuType) {
|
||||
// TODO: properly handle device. Can a VM have 2 vGPUS?
|
||||
return this.call('VGPU.create', this.getObject(vm).$ref, this.getObject(gpuGroup).$ref, '0', {}, this.getObject(vgpuType).$ref)
|
||||
},
|
||||
deleteVgpu (vgpu) {
|
||||
return this.call('VGPU.destroy', this.getObject(vgpu).$ref)
|
||||
}
|
||||
}
|
@ -41,6 +41,9 @@ export default {
|
||||
coreOs = false,
|
||||
cloudConfig = undefined,
|
||||
|
||||
vgpuType = undefined,
|
||||
gpuGroup = undefined,
|
||||
|
||||
...props
|
||||
} = {}, checkLimits) {
|
||||
const installMethod = (() => {
|
||||
@ -187,7 +190,9 @@ export default {
|
||||
)))
|
||||
}
|
||||
|
||||
// TODO: Assign VGPUs.
|
||||
if (vgpuType !== undefined && gpuGroup !== undefined) {
|
||||
await this.createVgpu(vm, gpuGroup, vgpuType)
|
||||
}
|
||||
|
||||
if (cloudConfig != null) {
|
||||
// Refresh the record.
|
||||
|
Loading…
Reference in New Issue
Block a user