Skip to content

Commit 9d657ac

Browse files
feat(@xen-orchestra/rest-api): expose forget SR (#9505)
1 parent f4cc402 commit 9d657ac

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

@vates/types/src/lib/xen-orchestra-xapi.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export interface Xapi {
134134
nameLabel?: string
135135
}
136136
): Promise<{ vm: XenApiVmWrapped }>
137+
forgetSr(id: XoSr['id']): Promise<void>
137138
SR_importVdi(
138139
ref: XenApiSr['$ref'],
139140
stream: Readable,

@xen-orchestra/rest-api/src/srs/sr.controller.mts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,31 @@ export class SrController extends XapiXoController<XoSr> {
273273
},
274274
})
275275
}
276+
277+
/**
278+
* @example id "c4284e12-37c9-7967-b9e8-83ef229c3e03"
279+
*/
280+
@Example(taskLocation)
281+
@Post('{id}/actions/forget')
282+
@SuccessResponse(asynchronousActionResp.status, asynchronousActionResp.description)
283+
@Response(noContentResp.status, noContentResp.description)
284+
@Response(notFoundResp.status, notFoundResp.description)
285+
@Response(invalidParametersResp.status, invalidParametersResp.description)
286+
@Response(internalServerErrorResp.status, internalServerErrorResp.description)
287+
async forgetSr(@Path() id: string, @Query() sync?: boolean): CreateActionReturnType<void> {
288+
const srId = id as XoSr['id']
289+
const action = async () => {
290+
const xapiSr = this.getXapiObject(srId)
291+
await xapiSr.$xapi.forgetSr(srId)
292+
}
293+
294+
return this.createAction<void>(action, {
295+
sync,
296+
statusCode: noContentResp.status,
297+
taskProperties: {
298+
name: 'forget sr',
299+
objectId: srId,
300+
},
301+
})
302+
}
276303
}

CHANGELOG.unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- [Replication] Reuse the same VM as an incremental replication target (PR [#9524](https://github.com/vatesfr/xen-orchestra/pull/9524))
1616
- [S3] add configuration for max/minPartSize and maxPartNumber in the API (PR [#9561](https://github.com/vatesfr/xen-orchestra/pull/9561))
1717
- [REST API] Expose `/rest/v0/vms/:id/actions/clone` (PR [#9453](https://github.com/vatesfr/xen-orchestra/pull/9453))
18+
- [REST API] Expose POST `/rest/v0/srs/:id/actions/forget` (PR [#9505](https://github.com/vatesfr/xen-orchestra/pull/9505))
1819

1920
### Bug fixes
2021

0 commit comments

Comments
 (0)