feat(xo-server/RestApi): add VDI import
Related to zammad#7036
This commit is contained in:
@@ -141,6 +141,23 @@ curl \
|
||||
> myDisk.vhd
|
||||
```
|
||||
|
||||
## VDI Import
|
||||
|
||||
A VHD can be imported on an SR to create a VDI at `/rest/v0/srs/<sr uuid>/vdis`.
|
||||
|
||||
```bash
|
||||
curl \
|
||||
-b authenticationToken=KQxQdm2vMiv7jBIK0hgkmgxKzemd8wSJ7ugFGKFkTbs \
|
||||
--progress-bar \
|
||||
--data-binary @myDisk.vhd \
|
||||
'https://xo.example.org/rest/v0/srs/357bd56c-71f9-4b2a-83b8-3451dec04b8f/vdis'
|
||||
```
|
||||
|
||||
The following query parameters are supported to customize the created VDI:
|
||||
|
||||
- `name_label`
|
||||
- `name_description`
|
||||
|
||||
## The future
|
||||
|
||||
We are adding features and improving the REST API step by step. If you have interesting use cases or feedback, please ask directly at <https://xcp-ng.org/forum/category/12/xen-orchestra>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
- [Collections](#collections)
|
||||
- [VM Export](#vm-export)
|
||||
- [VDI Export](#vdi-export)
|
||||
- [VDI Import](#vdi-import)
|
||||
- [The future](#the-future)
|
||||
|
||||
> This [REST](https://en.wikipedia.org/wiki/Representational_state_transfer)-oriented API is experimental. Non-backward compatible changes or removal may occur in any future release. Use of the feature is not recommended in production environments.
|
||||
@@ -137,6 +138,23 @@ curl \
|
||||
> myDisk.vhd
|
||||
```
|
||||
|
||||
## VDI Import
|
||||
|
||||
A VHD can be imported on an SR to create a VDI at `/rest/v0/srs/<sr uuid>/vdis`.
|
||||
|
||||
```bash
|
||||
curl \
|
||||
-b authenticationToken=KQxQdm2vMiv7jBIK0hgkmgxKzemd8wSJ7ugFGKFkTbs \
|
||||
--progress-bar \
|
||||
--data-binary @myDisk.vhd \
|
||||
'https://xo.company.lan/rest/v0/srs/357bd56c-71f9-4b2a-83b8-3451dec04b8f/vdis'
|
||||
```
|
||||
|
||||
The following query parameters are supported to customize the created VDI:
|
||||
|
||||
- `name_label`
|
||||
- `name_description`
|
||||
|
||||
## The future
|
||||
|
||||
We are adding features and improving the REST API step by step. If you have interesting use cases or feedback, please ask directly at <https://xcp-ng.org/forum/category/12/xen-orchestra>
|
||||
|
||||
@@ -119,6 +119,24 @@ export default class RestApi {
|
||||
})
|
||||
}
|
||||
|
||||
api.post('/srs/:uuid/vdis', async (req, res, next) => {
|
||||
try {
|
||||
const sr = await app.getXapiObject(req.params.uuid, 'SR')
|
||||
req.length = +req.headers['content-length']
|
||||
|
||||
const { name_label, name_description } = req.query
|
||||
const vdiRef = await sr.$importVdi(req, { name_label, name_description })
|
||||
|
||||
res.end(vdiRef)
|
||||
} catch (error) {
|
||||
if (noSuchObject.is(error)) {
|
||||
next()
|
||||
} else {
|
||||
next(error)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
api.get('/vdis/:uuid.vhd', async (req, res, next) => {
|
||||
try {
|
||||
const vdi = await app.getXapiObject(req.params.uuid, 'VDI')
|
||||
|
||||
Reference in New Issue
Block a user