mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-09-10 22:14:48 -05:00
feat(rest-api): add createVtpm parameter to VM creation endpoint (#9412)
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
XenApiVdi,
|
||||
XenApiVm,
|
||||
XenApiVmWrapped,
|
||||
XenApiVtpm,
|
||||
} from '../xen-api.mjs'
|
||||
import type { OPAQUE_REF_NULL, VBD_MODE, VBD_TYPE } from '../common.mjs'
|
||||
import type { PassThrough, Readable } from 'node:stream'
|
||||
@@ -222,4 +223,5 @@ export interface Xapi {
|
||||
params?: { host?: XenApiHost; query?: Record<string, unknown>; task?: boolean | XenApiTask['$ref'] }
|
||||
): Promise<{ body: Readable }>
|
||||
isHyperThreadingEnabled(hostId: XoHost['id']): Promise<boolean | null>
|
||||
VTPM_create(params: { VM: XenApiVm['$ref']; is_unique?: boolean; contents?: string }): Promise<XenApiVtpm['$ref']>
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ export type CreateVmAfterCreateParams = {
|
||||
network_config?: string
|
||||
boot?: boolean
|
||||
destroy_cloud_config_vdi?: boolean
|
||||
createVtpm?: boolean
|
||||
}
|
||||
export type CreateVmBody = Omit<
|
||||
CreateVmParams,
|
||||
|
||||
@@ -56,7 +56,7 @@ export class VmService {
|
||||
template: XoVmTemplate['uuid']
|
||||
}
|
||||
): Promise<XoVm['id']> {
|
||||
const { pool, template, cloud_config, boot, destroy_cloud_config_vdi, network_config, ...rest } = params
|
||||
const { pool, template, cloud_config, boot, destroy_cloud_config_vdi, network_config, createVtpm, ...rest } = params
|
||||
const xoApp = this.#restApi.xoApp
|
||||
const xapi = xoApp.getXapi(pool)
|
||||
const currentUser = this.#restApi.getCurrentUser()
|
||||
@@ -65,6 +65,11 @@ export class VmService {
|
||||
$defer.onFailure(() => xapi.VM_destroy(xapiVm.$ref))
|
||||
const xoVm = this.#restApi.getObject<XoVm>(xapiVm.uuid as XoVm['id'], 'VM')
|
||||
|
||||
if (createVtpm) {
|
||||
const vtpmRef = await xapi.VTPM_create({ VM: xapiVm.$ref })
|
||||
$defer.onFailure(() => xapi.call('VTPM.destroy', vtpmRef))
|
||||
}
|
||||
|
||||
let cloudConfigVdi: XenApiVdiWrapped | undefined
|
||||
if (cloud_config !== undefined) {
|
||||
const cloudConfigVdiUuid = await xapi.VM_createCloudInitConfig(xapiVm.$ref, cloud_config, {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
- [VM] Add "Change state" button on VM view (PR [#9317](https://github.com/vatesfr/xen-orchestra/pull/9317))
|
||||
- [REST API] Add `POST /vbds` endpoint to create a VBD (attach a VDI to a VM) (PR [#9391](https://github.com/vatesfr/xen-orchestra/pull/9391))
|
||||
- [TreeView] Scroll to current item in list view (PR [#9268](https://github.com/vatesfr/xen-orchestra/pull/9268))
|
||||
- [REST API] Add `createVtpm` parameter to VM creation endpoint (PR [#9412](https://github.com/vatesfr/xen-orchestra/pull/9412))
|
||||
|
||||
### Bug fixes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user