feat(xo-server/rest-api): expose NBD settings in VDI exports

This commit is contained in:
Florent Beauchamp 2023-12-20 13:35:27 +00:00 committed by Julien Fontanet
parent 5d80a58754
commit d36e10e73f
4 changed files with 15 additions and 1 deletions

View File

@ -8,6 +8,8 @@
> Users must be able to say: “Nice enhancement, I'm eager to test it”
- [SR] show an icon on SR during VDI coalescing (with XCP-ng 8.3+) (PR [#7241](https://github.com/vatesfr/xen-orchestra/pull/7241))
- [VDI/Export] Expose NBD settings in the XO and REST APIs api (PR [#7251](https://github.com/vatesfr/xen-orchestra/pull/7251))
### Bug fixes
> Users must be able to say: “I had this issue, happy to know it's fixed”

View File

@ -199,6 +199,11 @@ curl \
> myDisk.vhd
```
The following optional query parameters are supported for VDI export:
- `preferNbd`: will use NBD for export if available
- `nbdConcurrency=<integer>`: set the number of concurrent stream per disk if NBD is enabled, default 1
## VM Import
A VM can be imported by posting to `/rest/v0/pools/:id/vms`.

View File

@ -210,6 +210,11 @@ curl \
A VDI can be exported in VHD format at `/rest/v0/vdis/<uuid>.vhd` or the raw content at `/rest/v0/vdis/<uuid>.raw`.
The following optional query parameters are supported:
- `preferNbd`: will use NBD for export if available
- `nbdConcurrency=<integer>`: set the number of concurrent stream per disk if NBD is enabled, default 1
```sh
curl \
-b authenticationToken=KQxQdm2vMiv7jBIK0hgkmgxKzemd8wSJ7ugFGKFkTbs \

View File

@ -470,7 +470,9 @@ export default class RestApi {
api.get(
'/:collection(vdis|vdi-snapshots)/:object.:format(vhd|raw)',
wrap(async (req, res) => {
const stream = await req.xapiObject.$exportContent({ format: req.params.format })
const preferNbd = Object.hasOwn(req.query, 'preferNbd')
const nbdConcurrency = req.query.nbdConcurrency && parseInt(req.query.nbdConcurrency)
const stream = await req.xapiObject.$exportContent({ format: req.params.format, preferNbd, nbdConcurrency })
// stream can be an HTTP response, in this case, extract interesting data
const { headers = {}, length, statusCode = 200, statusMessage = 'OK' } = stream