Skip to content

Commit

Permalink
feat(xo-server): expose nbd settings in rest api vdi exports
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeauchamp committed Dec 20, 2023
1 parent b427f0d commit e310ebb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- [Backup]Use multiple link to speedup NBD backup (PR [#7216](https://github.com/vatesfr/xen-orchestra/pull/7216))
- [Backup] Show if disk is differential or full in incremental backups (PR [#7222](https://github.com/vatesfr/xen-orchestra/pull/7222))
- [VDI] Create XAPI task during NBD export (PR [#7228](https://github.com/vatesfr/xen-orchestra/pull/7228))
- [VDI/Export] Expose NBD settings in the XO and REST APIs api (PR [#7251](https://github.com/vatesfr/xen-orchestra/pull/7251))

### Bug fixes

Expand Down
5 changes: 5 additions & 0 deletions packages/xo-server/docs/rest-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 3 additions & 1 deletion packages/xo-server/src/xo-mixins/rest-api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e310ebb

Please sign in to comment.