mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-09-10 22:14:48 -05:00
feat(@xen-orchestra/rest-api): expose vm suspend
This commit is contained in:
@@ -263,6 +263,7 @@ type XenApiVmCallMethods = {
|
||||
(method: 'clean_reboot'): Promise<void>
|
||||
(method: 'hard_reboot'): Promise<void>
|
||||
(method: 'pause'): Promise<void>
|
||||
(method: 'suspend'): Promise<void>
|
||||
(method: 'record_data_source', dataSource: string): Promise<void>
|
||||
(method: 'forget_data_source_archives', dataSource: string): Promise<void>
|
||||
}
|
||||
|
||||
@@ -309,6 +309,33 @@ export class VmController extends XapiXoController<XoVm> {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* The VM must be running
|
||||
*
|
||||
* @example id "f07ab729-c0e8-721c-45ec-f11276377030"
|
||||
*/
|
||||
@Example(taskLocation)
|
||||
@Post('{id}/actions/suspend')
|
||||
@SuccessResponse(asynchronousActionResp.status, asynchronousActionResp.description, asynchronousActionResp.produce)
|
||||
@Response(noContentResp.status, noContentResp.description)
|
||||
@Response(notFoundResp.status, notFoundResp.description)
|
||||
@Response(internalServerErrorResp.status, internalServerErrorResp.description)
|
||||
async suspendVm(@Path() id: string, @Query() sync?: boolean): Promise<void | string> {
|
||||
const vmId = id as XoVm['id']
|
||||
const action = async () => {
|
||||
await this.getXapiObject(vmId).$callAsync('suspend')
|
||||
}
|
||||
|
||||
return this.createAction<void>(action, {
|
||||
sync,
|
||||
statusCode: noContentResp.status,
|
||||
taskProperties: {
|
||||
name: 'suspend VM',
|
||||
objectId: vmId,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @example id "f07ab729-c0e8-721c-45ec-f11276377030"
|
||||
* @example body { "name_label": "my_awesome_snapshot" }
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
- [REST API] Expose `GET /rest/v0/sms` and `GET /rest/v0/sms/<sm-id>` (PR [#8696](https://github.com/vatesfr/xen-orchestra/pull/8696))
|
||||
- [XO5/Tasks] hide pending/successful xo tasks (PR [#8676](https://github.com/vatesfr/xen-orchestra/pull/8676))
|
||||
- [REST API] Expose `POST /rest/v0/vms/<vm-id>/actions/pause` (PR [#8744](https://github.com/vatesfr/xen-orchestra/pull/8744))
|
||||
- [REST API] Expose `POST /rest/v0/vms/<vm-id>/actions/suspend` (PR [#8744](https://github.com/vatesfr/xen-orchestra/pull/8744))
|
||||
|
||||
### Bug fixes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user