feat(xo-server/rest-api): possibility to import a VM
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
> Users must be able to say: “Nice enhancement, I'm eager to test it”
|
||||
|
||||
- [VM/Disks] Display task information when importing VDIs (PR [#7197](https://github.com/vatesfr/xen-orchestra/pull/7197))
|
||||
- [REST API] Support VM import using the XVA format
|
||||
|
||||
### Bug fixes
|
||||
|
||||
@@ -30,6 +31,7 @@
|
||||
<!--packages-start-->
|
||||
|
||||
- @xen-orchestra/backups patch
|
||||
- xo-server minor
|
||||
- xo-web minor
|
||||
|
||||
<!--packages-end-->
|
||||
|
||||
@@ -199,6 +199,23 @@ curl \
|
||||
> myDisk.vhd
|
||||
```
|
||||
|
||||
## VM Import
|
||||
|
||||
A VM can be imported by posting to `/rest/v0/pools/:id/vms`.
|
||||
|
||||
```sh
|
||||
curl \
|
||||
-X POST \
|
||||
-b authenticationToken=KQxQdm2vMiv7jBIK0hgkmgxKzemd8wSJ7ugFGKFkTbs \
|
||||
-T myDisk.raw \
|
||||
'https://xo.example.org/rest/v0/pools/355ee47d-ff4c-4924-3db2-fd86ae629676/vms?sr=357bd56c-71f9-4b2a-83b8-3451dec04b8f' \
|
||||
| cat
|
||||
```
|
||||
|
||||
The `sr` query parameter can be used to specify on which SR the VM should be imported, if not specified, the default SR will be used.
|
||||
|
||||
> Note: the final `| cat` ensures cURL's standard output is not a TTY, which is necessary for upload stats to be dislayed.
|
||||
|
||||
## VDI Import
|
||||
|
||||
### Existing VDI
|
||||
|
||||
@@ -180,6 +180,23 @@ curl \
|
||||
> myVM.xva
|
||||
```
|
||||
|
||||
## VM Import
|
||||
|
||||
A VM can be imported by posting to `/rest/v0/pools/:id/vms`.
|
||||
|
||||
```sh
|
||||
curl \
|
||||
-X POST \
|
||||
-b authenticationToken=KQxQdm2vMiv7jBIK0hgkmgxKzemd8wSJ7ugFGKFkTbs \
|
||||
-T myDisk.raw \
|
||||
'https://xo.company.lan/rest/v0/pools/355ee47d-ff4c-4924-3db2-fd86ae629676/vms?sr=357bd56c-71f9-4b2a-83b8-3451dec04b8f' \
|
||||
| cat
|
||||
```
|
||||
|
||||
The `sr` query parameter can be used to specify on which SR the VM should be imported, if not specified, the default SR will be used.
|
||||
|
||||
> Note: the final `| cat` ensures cURL's standard output is not a TTY, which is necessary for upload stats to be dislayed.
|
||||
|
||||
## VDI destruction
|
||||
|
||||
```sh
|
||||
|
||||
@@ -576,6 +576,22 @@ export default class RestApi {
|
||||
})
|
||||
)
|
||||
|
||||
api.post(
|
||||
'/:collection(pools)/:object/vms',
|
||||
wrap(async (req, res) => {
|
||||
let srRef
|
||||
const { sr } = req.params
|
||||
if (sr !== undefined) {
|
||||
srRef = app.getXapiObject(sr, 'SR').$ref
|
||||
}
|
||||
|
||||
const { $xapi } = req.xapiObject
|
||||
const ref = await $xapi.VM_import(req, srRef)
|
||||
|
||||
res.end(await $xapi.getField('VM', ref, 'uuid'))
|
||||
})
|
||||
)
|
||||
|
||||
api.post(
|
||||
'/:collection(srs)/:object/vdis',
|
||||
wrap(async (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user