feat(xo-server/rest-api): expose VM snapshots and templates

This commit is contained in:
Julien Fontanet
2022-11-07 16:45:18 +01:00
parent 5401d17610
commit df3df18690
2 changed files with 6 additions and 2 deletions

View File

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

View File

@@ -87,6 +87,8 @@ export default class RestApi {
{ id: 'vbds', type: 'VBD' }, { id: 'vbds', type: 'VBD' },
{ id: 'vdis', type: 'VDI' }, { id: 'vdis', type: 'VDI' },
{ id: 'vifs', type: 'VIF' }, { id: 'vifs', type: 'VIF' },
{ id: 'vm-snapshots', type: 'VM-snapshot' },
{ id: 'vm-templates', type: 'VM-template' },
{ id: 'vms', type: 'VM' }, { id: 'vms', type: 'VM' },
] ]
@@ -160,9 +162,10 @@ export default class RestApi {
} }
}) })
api.get('/vms/:uuid.xva', async (req, res, next) => { api.get('/vm:subtype(|-snapshot|-template)s/:uuid.xva', async (req, res, next) => {
try { try {
const vm = app.getXapiObject(req.params.uuid, 'VM') const { subtype, uuid } = req.params
const vm = app.getXapiObject(uuid, 'VM' + subtype)
const stream = await vm.$export({ compress: req.query.compress }) const stream = await vm.$export({ compress: req.query.compress })
stream.headers['content-disposition'] = 'attachment' stream.headers['content-disposition'] = 'attachment'