Compare commits

...

2 Commits

Author SHA1 Message Date
MelissaFrncJrg
4f0e5fdfdc changelog entry 2026-01-19 15:50:17 +01:00
MelissaFrncJrg
1ee3c0b0ca feat(@xen-orchestra/rest-api): add VM secure boot handling 2026-01-19 15:47:15 +01:00
7 changed files with 38 additions and 2 deletions

View File

@@ -202,6 +202,7 @@ export interface Xapi {
forceDeleteDefaultTemplate?: boolean
}
): Promise<void>
VM_set_platform(vmRef: XenApiVm['$ref'], key: string, value: string | null): Promise<void>
getResource(
pathname: string,
params?: { host?: XenApiHost; query?: Record<string, unknown>; task?: boolean | XenApiTask['$ref'] }

View File

@@ -58,6 +58,7 @@ export type CreateVmBody = Omit<
/** VDI ID for cdrom method. Empty string for network method */
repository: string | ''
}
secureBoot?: boolean
} & CreateVmAfterCreateParams
export type PoolDashboard = {

View File

@@ -1,6 +1,7 @@
import {
Example,
Get,
Patch,
Path,
Post,
Query,
@@ -13,8 +14,9 @@ import {
Body,
Put,
Delete,
Middlewares,
} from 'tsoa'
import { Request as ExRequest } from 'express'
import { Request as ExRequest, json } from 'express'
import { inject } from 'inversify'
import { incorrectState, invalidParameters } from 'xo-common/api-errors.js'
import { provide } from 'inversify-binding-decorators'
@@ -58,7 +60,7 @@ import { BackupJobService } from '../backup-jobs/backup-job.service.mjs'
import type { UnbrandXoVmBackupJob } from '../backup-jobs/backup-job.type.mjs'
import { partialVmBackupJobs, vmBackupJobIds } from '../open-api/oa-examples/backup-job.oa-example.mjs'
import { messageIds, partialMessages } from '../open-api/oa-examples/message.oa-example.mjs'
import type { UnbrandedVmDashboard } from './vm.type.mjs'
import type { UnbrandedVmDashboard, UpdateVmBody } from './vm.type.mjs'
import type { CreateActionReturnType } from '../abstract-classes/base-controller.mjs'
const IGNORED_VDIS_TAG = '[NOSNAP]'
@@ -151,6 +153,19 @@ export class VmController extends XapiXoController<XoVm> {
await xapiVm.$xapi.VM_destroy(xapiVm.$ref)
}
/**
* @example id "f07ab729-c0e8-721c-45ec-f11276377030"
* @example body { "secureBoot": true }
*/
@Patch('{id}/secureboot')
@Middlewares(json())
@SuccessResponse(noContentResp.status, noContentResp.description)
@Response(notFoundResp.status, notFoundResp.description)
@Response(forbiddenOperationResp.status, forbiddenOperationResp.description)
async updateVmSecureBoot(@Path() id: string, @Body() body: UpdateVmBody): Promise<void> {
await this.#vmService.updateVmSecureBoot(id as XoVm['id'], body.secureBoot ?? false)
}
/**
*
* VM must be running

View File

@@ -416,4 +416,10 @@ export class VmService {
},
}
}
async updateVmSecureBoot(id: XoVm['id'], secureBoot: boolean): Promise<void> {
const vm = this.#restApi.getXapiObject<XoVm>(id, 'VM')
const value = secureBoot ? 'true' : null
await vm.$xapi.VM_set_platform(vm.$ref, 'secureboot', value)
}
}

View File

@@ -1,6 +1,10 @@
import type { XoAlarm, XoHost, XoSr, XoUser, XoVm, XoVmBackupArchive, XoVmBackupJob } from '@vates/types'
import { Unbrand } from '../open-api/common/response.common.mjs'
export interface UpdateVmBody {
secureBoot?: boolean
}
type VmDashboardRun = { backupJobId: XoVmBackupJob['id']; timestamp: number; status: string }
type VmDashboardBackupArchive = {
id: XoVmBackupArchive['id']

View File

@@ -794,6 +794,14 @@ class Vm {
await this.callAsync(`VM.${force ? 'hard' : 'clean'}_reboot`, vmRef)
}
async set_platform(vmRef, key, value) {
await this.call('VM.remove_from_platform', vmRef, key)
if (value !== null) {
await this.call('VM.add_to_platform', vmRef, key, value)
}
}
}
export default Vm

View File

@@ -15,6 +15,7 @@
- [REST API] Update `/dashboard` endpoint to also return disconnected servers, disabled hosts, the status of all VMs, and compute `jobs` from the last seven days (PR [#9207](https://github.com/vatesfr/xen-orchestra/pull/9207))
- [vhd-cli] Prevent using invalid options (PR [#9386](https://github.com/vatesfr/xen-orchestra/pull/9386))
- [REST API] Add endpoints to reconfigure management interface for hosts and pools (PR [#9369](https://github.com/vatesfr/xen-orchestra/pull/9369))
- [REST API] Add VM secure boot handling (PR [#9409](https://github.com/vatesfr/xen-orchestra/pull/9409))
### Bug fixes