feat(xo-server/rest-api): expose VDI snapshots

This commit is contained in:
Julien Fontanet 2022-11-07 17:09:20 +01:00
parent df3df18690
commit 131643a91b
2 changed files with 5 additions and 2 deletions

View File

@ -10,6 +10,7 @@
- [API] `proxy.register` accepts `vmUuid` parameter which can be used when not connected to the XAPI containing the XO Proxy VM
- [Proxy] Can now upgrade proxies in VMs not connected to XO
- [REST API] Expose VM snapshots and templates
- [REST API] Expose VDI snapshots
### Bug fixes

View File

@ -85,6 +85,7 @@ export default class RestApi {
{ id: 'pools', type: 'pool' },
{ id: 'srs', type: 'SR' },
{ id: 'vbds', type: 'VBD' },
{ id: 'vdi-snapshots', type: 'VDI-snapshot' },
{ id: 'vdis', type: 'VDI' },
{ id: 'vifs', type: 'VIF' },
{ id: 'vm-snapshots', type: 'VM-snapshot' },
@ -144,9 +145,10 @@ export default class RestApi {
}
})
api.get('/vdis/:uuid.vhd', async (req, res, next) => {
api.get('/vdi:subtype(|-snapshot)s/:uuid.vhd', async (req, res, next) => {
try {
const vdi = app.getXapiObject(req.params.uuid, 'VDI')
const { subtype, uuid } = req.params
const vdi = app.getXapiObject(uuid, 'VDI' + subtype)
const stream = await vdi.$exportContent({ format: 'vhd' })
stream.headers['content-disposition'] = 'attachment'