Compare commits

...

3 Commits

Author SHA1 Message Date
Julien Fontanet
d7e4a65ba7 WiP 2023-11-23 16:28:16 +01:00
Julien Fontanet
f26919cca7 chore(xapi/VM_import): typo snapshots → snapshot 2023-11-23 14:47:38 +01:00
Julien Fontanet
78afe122a6 chore(xo-server/proxy.checkHealth): call checkProxyHealth 2023-11-23 14:05:02 +01:00
3 changed files with 33 additions and 15 deletions

View File

@@ -200,6 +200,18 @@ class Vm {
}
}
_safeSetIsATemplate(ref) {
return pCatch.call(
this.setField('VM', ref, 'is_a_template', false),
// Ignore if this fails due to license restriction
//
// see https://bugs.xenserver.org/browse/XSO-766
{ code: 'LICENSE_RESTRICTION' },
noop
)
}
async assertHealthyVdiChains(vmRef, tolerance = this._maxUncoalescedVdis) {
const vdiRefs = {}
;(await this.getRecords('VBD', await this.getField('VM', vmRef, 'VBDs'))).forEach(({ VDI: ref }) => {
@@ -486,12 +498,13 @@ class Vm {
if (useSnapshot === undefined) {
useSnapshot = isVmRunning(vm)
}
let exportedVmRef, destroySnapshot
let exportedVmRef, destroySnapshot, isSnapshot
if (useSnapshot) {
exportedVmRef = await this.VM_snapshot(vmRef, { cancelToken, name_label: `[XO Export] ${vm.name_label}` })
isSnapshot = true
destroySnapshot = () =>
this.VM_destroy(exportedVmRef).catch(error => {
warn('VM_export: failed to destroy snapshots', {
warn('VM_export: failed to destroy snapshot', {
error,
snapshotRef: exportedVmRef,
vmRef,
@@ -500,8 +513,13 @@ class Vm {
$defer.onFailure(destroySnapshot)
} else {
exportedVmRef = vmRef
isSnapshot = vm.is_a_snapshot
}
try {
// VM snapshots are marked as templates, unfortunately it does not play well with XVA export/import
// which will import them as templates and not VM snapshots or plain VMs
await this._safeSetIsATemplate(exportedVmRef, false)
const stream = await this.getResource(cancelToken, '/export/', {
query: {
ref: exportedVmRef,
@@ -510,6 +528,16 @@ class Vm {
task: taskRef,
})
if (isSnapshot) {
// FIXME: VM_IS_SNAPSHOT(OpaqueRef:757d6cfd-a185-4114-bfc8-fb9fdd279bf2, make_into_template)
this._safeSetIsATemplate(exportedVmRef, true).catch(error => {
warn('VM_export: failed to reset is_a_template on snapshot', {
error,
snapshotRef: exportedVmRef,
vmRef,
})
})
}
if (useSnapshot) {
stream.once('end', destroySnapshot).once('error', destroySnapshot)
}
@@ -665,18 +693,6 @@ class Vm {
// detached async
this._httpHook(vm, '/post-sync').catch(noop)
// VM snapshots are marked as templates, unfortunately it does not play well with XVA export/import
// which will import them as templates and not VM snapshots or plain VMs
await pCatch.call(
this.setField('VM', ref, 'is_a_template', false),
// Ignore if this fails due to license restriction
//
// see https://bugs.xenserver.org/browse/XSO-766
{ code: 'LICENSE_RESTRICTION' },
noop
)
if (destroyNobakVdis) {
await asyncMap(await listNobakVbds(this, await this.getField('VM', ref, 'VBDs')), async vbd => {
try {

View File

@@ -21,6 +21,7 @@
- [Import/ESXi] Handle `Cannot read properties of undefined (reading 'perDatastoreUsage')` error when importing VM without storage (PR [#7168](https://github.com/vatesfr/xen-orchestra/pull/7168))
- [Export/OVA] Handle export with resulting disk larger than 8.2GB (PR [#7183](https://github.com/vatesfr/xen-orchestra/pull/7183))
- [Self Service] Fix error displayed after adding a VM to a resource set (PR [#7144](https://github.com/vatesfr/xen-orchestra/pull/7144))
- VMs snapshotted with XO will no longer appear as regular VMs in other clients like `xe`
### Packages to release
@@ -42,6 +43,7 @@
- @xen-orchestra/backups minor
- @xen-orchestra/cr-seed-cli major
- @xen-orchestra/vmware-explorer patch
- @xen-orchestra/xapi patch
- xen-api major
- xo-server patch
- xo-server-netbox minor

View File

@@ -181,7 +181,7 @@ getApplianceUpdaterState.params = {
export async function checkHealth({ id }) {
try {
await this.callProxyMethod(id, 'system.getServerVersion')
await this.checkProxyHealth(id)
return {
success: true,
}