fix(xo-server/{clone,copy}Vm): force is_a_template
to false
on the new VM (#5955)
See xoa-support#4137
This commit is contained in:
parent
5ec1092a83
commit
12153a414d
@ -18,6 +18,7 @@
|
|||||||
- [Backups] Delete unused snapshots related to other schedules (even no longer existing) (PR [#5949](https://github.com/vatesfr/xen-orchestra/pull/5949))
|
- [Backups] Delete unused snapshots related to other schedules (even no longer existing) (PR [#5949](https://github.com/vatesfr/xen-orchestra/pull/5949))
|
||||||
- [Jobs] Fix `job.runSequence` method (PR [#5944](https://github.com/vatesfr/xen-orchestra/pull/5944))
|
- [Jobs] Fix `job.runSequence` method (PR [#5944](https://github.com/vatesfr/xen-orchestra/pull/5944))
|
||||||
- [Netbox] Fix error when testing plugin on versions older than 2.10 (PR [#5963](https://github.com/vatesfr/xen-orchestra/pull/5963))
|
- [Netbox] Fix error when testing plugin on versions older than 2.10 (PR [#5963](https://github.com/vatesfr/xen-orchestra/pull/5963))
|
||||||
|
- [Snapshot] Fix "Create VM from snapshot" creating a template instead of a VM (PR [#5955](https://github.com/vatesfr/xen-orchestra/pull/5955))
|
||||||
|
|
||||||
### Packages to release
|
### Packages to release
|
||||||
|
|
||||||
|
@ -659,22 +659,28 @@ export const clone = defer(async function ($defer, { vm, name, full_copy: fullCo
|
|||||||
await checkPermissionOnSrs.call(this, vm)
|
await checkPermissionOnSrs.call(this, vm)
|
||||||
const xapi = this.getXapi(vm)
|
const xapi = this.getXapi(vm)
|
||||||
|
|
||||||
const { $id: cloneId, $ref: cloneRef } = await xapi.cloneVm(vm._xapiRef, {
|
const newVm = await xapi.cloneVm(vm._xapiRef, {
|
||||||
nameLabel: name,
|
nameLabel: name,
|
||||||
fast: !fullCopy,
|
fast: !fullCopy,
|
||||||
})
|
})
|
||||||
$defer.onFailure(() => xapi.VM_destroy(cloneRef))
|
$defer.onFailure(() => xapi.VM_destroy(newVm.$ref))
|
||||||
|
|
||||||
|
// A snapshot may have its `is_a_template` flag set to true, which isn't
|
||||||
|
// automatically set to false when cloning it
|
||||||
|
if (vm.type !== 'VM-template') {
|
||||||
|
await newVm.set_is_a_template(false)
|
||||||
|
}
|
||||||
|
|
||||||
const isAdmin = this.user.permission === 'admin'
|
const isAdmin = this.user.permission === 'admin'
|
||||||
if (!isAdmin) {
|
if (!isAdmin) {
|
||||||
await this.addAcl(this.user.id, cloneId, 'admin')
|
await this.addAcl(this.user.id, newVm.$id, 'admin')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.resourceSet !== undefined) {
|
if (vm.resourceSet !== undefined) {
|
||||||
await this.allocateLimitsInResourceSet(await this.computeVmResourcesUsage(vm), vm.resourceSet, isAdmin)
|
await this.allocateLimitsInResourceSet(await this.computeVmResourcesUsage(vm), vm.resourceSet, isAdmin)
|
||||||
}
|
}
|
||||||
|
|
||||||
return cloneId
|
return newVm.$id
|
||||||
})
|
})
|
||||||
|
|
||||||
clone.params = {
|
clone.params = {
|
||||||
@ -691,25 +697,32 @@ clone.resolve = {
|
|||||||
|
|
||||||
// TODO: implement resource sets
|
// TODO: implement resource sets
|
||||||
export async function copy({ compress, name: nameLabel, sr, vm }) {
|
export async function copy({ compress, name: nameLabel, sr, vm }) {
|
||||||
|
let newVm
|
||||||
if (vm.$pool === sr.$pool) {
|
if (vm.$pool === sr.$pool) {
|
||||||
if (vm.power_state === 'Running') {
|
if (vm.power_state === 'Running') {
|
||||||
await checkPermissionOnSrs.call(this, vm)
|
await checkPermissionOnSrs.call(this, vm)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getXapi(vm)
|
newVm = await this.getXapi(vm).copyVm(vm._xapiId, {
|
||||||
.copyVm(vm._xapiId, {
|
nameLabel,
|
||||||
|
srOrSrId: sr._xapiId,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
newVm = (
|
||||||
|
await this.getXapi(vm).remoteCopyVm(vm._xapiId, this.getXapi(sr), sr._xapiId, {
|
||||||
|
compress,
|
||||||
nameLabel,
|
nameLabel,
|
||||||
srOrSrId: sr._xapiId,
|
|
||||||
})
|
})
|
||||||
.then(vm => vm.$id)
|
).vm
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getXapi(vm)
|
// A snapshot may have its `is_a_template` flag set to true, which isn't
|
||||||
.remoteCopyVm(vm._xapiId, this.getXapi(sr), sr._xapiId, {
|
// automatically set to false when copying it
|
||||||
compress,
|
if (vm.type !== 'VM-template') {
|
||||||
nameLabel,
|
await newVm.set_is_a_template(false)
|
||||||
})
|
}
|
||||||
.then(({ vm }) => vm.$id)
|
|
||||||
|
return newVm.$id
|
||||||
}
|
}
|
||||||
|
|
||||||
copy.params = {
|
copy.params = {
|
||||||
|
Loading…
Reference in New Issue
Block a user