Compare commits

..

1 Commits

Author SHA1 Message Date
Julien Fontanet
42cc6d4dd6 WiP 2024-02-12 13:14:26 +01:00
7 changed files with 57 additions and 8 deletions

View File

@@ -218,16 +218,16 @@ export class IncrementalRemoteWriter extends MixinRemoteWriter(AbstractIncrement
})
transferSize += transferSizeOneDisk
if (isDifferencing) {
await chainVhd(handler, parentPath, handler, path)
}
// set the correct UUID in the VHD
await Disposable.use(openVhd(handler, path), async vhd => {
vhd.footer.uuid = packUuid(vdi.uuid)
await vhd.readBlockAllocationTable() // required by writeFooter()
await vhd.writeFooter()
})
if (isDifferencing) {
await chainVhd(handler, parentPath, handler, path)
}
},
{
concurrency: settings.diskPerVmConcurrency,

View File

@@ -399,6 +399,16 @@ class Vm {
return ref
}
async createFull($defer, { clone = true, boot = false, name_label, name_description, template: templateRef }) {
// Clones the template.
const vmRef = await (
clone
? this.callAsync('VM.clone', templateRef, name_label)
: this.callAsync('VM.copy', templateRef, name_label, '')
).then(extractOpaqueRef)
$defer.onFailure(() => this.VM_destroy(vmRef))
}
async destroy(
vmRef,
{ deleteDisks = true, force = false, bypassBlockedOperation = force, forceDeleteDefaultTemplate = force } = {}
@@ -699,6 +709,7 @@ export default Vm
decorateClass(Vm, {
checkpoint: defer,
create: defer,
createFull: defer,
export: defer,
snapshot: defer,
})

View File

@@ -15,7 +15,6 @@
- [Settings/XO Config] Sort backups from newest to oldest
- [Plugins/audit] Don't log `tag.getAllConfigured` calls
- [Remotes] Correctly clear error when the remote is tested with success
### Packages to release

View File

@@ -1,6 +1,4 @@
{
"name": "xen-orchestra",
"version": "0.0.0",
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/eslint-parser": "^7.13.8",

View File

@@ -32,6 +32,9 @@ const methods = {
name_label, // eslint-disable-line camelcase
nameLabel = name_label, // eslint-disable-line camelcase
cloudConfig,
networkConfig,
clone = true,
installRepository = undefined,
vdis = undefined,
@@ -217,6 +220,35 @@ const methods = {
await this.createVgpu(vm, gpuGroup, vgpuType)
}
// create cloud config drive
let cloudConfigVdiUuid
if (params.cloudConfig != null) {
// Find the SR of the first VDI.
let srId
forEach(vm.$VBDs, vbdId => {
const vbd = this.getObject(vbdId)
const vdiId = vbd.VDI
if (!vbd.is_cd_drive && vdiId !== undefined) {
srId = this.getObject(vdiId).$SR
return false
}
})
try {
cloudConfigVdiUuid = params.coreOs
? await xapi.createCoreOsCloudInitConfigDrive(vm.id, srId, params.cloudConfig)
: await xapi.createCloudInitConfigDrive(vm.id, srId, params.cloudConfig, params.networkConfig)
} catch (error) {
log.warn('vm.create', { vmId: vm.id, srId, error })
throw error
}
}
if (params.createVtpm) {
const vtpmRef = await xapi.VTPM_create({ VM: xapiVm.$ref })
$defer.onFailure(() => xapi.call('VTPM.destroy', vtpmRef))
}
// wait for the record with all the VBDs and VIFs
return this.barrier(vm.$ref)
},

View File

@@ -297,6 +297,15 @@ export default class RestApi {
auto_poweron: { type: 'boolean', optional: true },
boot: { type: 'boolean', default: false },
clone: { type: 'boolean', default: true },
cloud_init: {
type: 'object',
default: {},
properties: {
cloud_config: { type: 'string', optional: true },
destroy_after_boot: { type: 'boolean', default: false },
network_config: { type: 'string', optional: true },
},
},
install: {
type: 'object',
optional: true,

View File

@@ -33,7 +33,7 @@ const formatError = error => (typeof error === 'string' ? error : JSON.stringify
const _changeUrlElement = (value, { remote, element }) =>
editRemote(remote, {
url: format({ ...parse(remote.url), [element]: value === null ? undefined : value }),
url: format({ ...remote, [element]: value === null ? undefined : value }),
})
const _showError = remote => alert(_('remoteConnectionFailed'), <pre>{formatError(remote.error)}</pre>)
const _editRemoteName = (name, { remote }) => editRemote(remote, { name })