feat(xo-web/new VM): only send memory param so that it doesn't enable DMC (#5729)

Fixes xoa-support#3591
See 70d1537ecc

- If only "RAM" field is filled: only send `memory` param
- If any of the advanced memory fields are filled:
  - only send those
  - if "Dynamic memory max" field is empty, use the "RAM" field value for
  `memoryDynamicMax` param
This commit is contained in:
Pierre Donias
2021-04-19 10:16:56 +02:00
committed by GitHub
parent 9102b4aa1b
commit 75e3e36aa8
2 changed files with 29 additions and 17 deletions

View File

@@ -7,6 +7,8 @@
> Users must be able to say: “Nice enhancement, I'm eager to test it”
- [VM] Don't make a VM use [DMC](https://docs.citrix.com/en-us/xencenter/7-1/dmc-about.html) on creation by default [#5729](https://github.com/vatesfr/xen-orchestra/issues/5729)
### Bug fixes
> Users must be able to say: “I had this issue, happy to know it's fixed”
@@ -34,3 +36,4 @@
- @xen-orchestra/backups-cli patch
- @xen-orchestra/mixins minor
- xo-server minor
- xo-web minor

View File

@@ -429,6 +429,15 @@ export default class NewVm extends BaseComponent {
const resourceSet = this._getResourceSet()
const { template } = this.props
// Either use `memory` OR `memory*` params
let { memory, memoryStaticMax, memoryDynamicMin, memoryDynamicMax } = state
if ((memoryStaticMax != null || memoryDynamicMin != null) && memoryDynamicMax == null) {
memoryDynamicMax = memory
}
if (memoryDynamicMax != null) {
memory = undefined
}
const data = {
affinityHost: state.affinityHost && state.affinityHost.id,
clone: !this.isDiskTemplate && state.fastClone,
@@ -446,9 +455,10 @@ export default class NewVm extends BaseComponent {
cpuWeight: state.cpuWeight === '' ? null : state.cpuWeight,
cpuCap: state.cpuCap === '' ? null : state.cpuCap,
name_description: state.name_description,
memoryStaticMax: state.memoryStaticMax,
memoryMin: state.memoryDynamicMin,
memoryMax: state.memoryDynamicMax,
memory,
memoryMax: memoryDynamicMax,
memoryMin: memoryDynamicMin,
memoryStaticMax,
pv_args: state.pv_args,
autoPoweron: state.autoPoweron,
bootAfterCreate: state.bootAfterCreate,
@@ -537,7 +547,7 @@ export default class NewVm extends BaseComponent {
cpuCap: '',
cpuWeight: '',
hvmBootFirmware: defined(() => template.boot.firmware, ''),
memoryDynamicMax: template.memory.dynamic[1],
memory: template.memory.dynamic[1],
// installation
installMethod: (template.install_methods != null && template.install_methods[0]) || 'noConfigDrive',
sshKeys: this.props.userSshKeys && this.props.userSshKeys.length && [0],
@@ -966,7 +976,7 @@ export default class NewVm extends BaseComponent {
)
_renderPerformances = () => {
const { coresPerSocket, CPUs, memoryDynamicMax } = this.state.state
const { coresPerSocket, CPUs, memory, memoryDynamicMax } = this.state.state
const { template } = this.props
const { pool } = this.props
const memoryThreshold = get(() => template.memory.static[0])
@@ -995,10 +1005,10 @@ export default class NewVm extends BaseComponent {
<Item label={_('newVmRamLabel')}>
<SizeInput
className={styles.sizeInput}
onChange={this._linkState('memoryDynamicMax')}
value={defined(memoryDynamicMax, null)}
onChange={this._linkState('memory')}
value={defined(memory, null)}
/>{' '}
{memoryDynamicMax < memoryThreshold && (
{memoryDynamicMax == null && memory != null && memory < memoryThreshold && (
<Tooltip
content={_('newVmRamWarning', {
threshold: formatSize(memoryThreshold),
@@ -1020,8 +1030,8 @@ export default class NewVm extends BaseComponent {
)
}
_isPerformancesDone = () => {
const { CPUs, memoryDynamicMax } = this.state.state
return CPUs && memoryDynamicMax != null
const { CPUs, memory, memoryDynamicMax } = this.state.state
return CPUs && (memory != null || memoryDynamicMax != null)
}
// INSTALL SETTINGS ------------------------------------------------------------
@@ -1720,12 +1730,10 @@ export default class NewVm extends BaseComponent {
)
}
_isAdvancedDone = () => {
const lowerThan = (small, big) => small == null || big == null || small <= big
const { memoryDynamicMin, memoryDynamicMax, memoryStaticMax } = this.state.state
return (
memoryDynamicMax != null &&
(memoryDynamicMin == null || memoryDynamicMin <= memoryDynamicMax) &&
(memoryStaticMax == null || memoryDynamicMax <= memoryStaticMax)
)
return lowerThan(memoryDynamicMin, memoryDynamicMax) && lowerThan(memoryDynamicMax, memoryStaticMax)
}
// SUMMARY ---------------------------------------------------------------------
@@ -1816,12 +1824,13 @@ export default class NewVm extends BaseComponent {
return true
}
const { CPUs, existingDisks, memoryDynamicMax, VDIs, multipleVms, nameLabels } = this.state.state
const { CPUs, existingDisks, memory, memoryDynamicMax, VDIs, multipleVms, nameLabels } = this.state.state
const _memory = memoryDynamicMax == null ? memory : memoryDynamicMax
const factor = multipleVms ? nameLabels.length : 1
return !(
CPUs * factor > get(() => resourceSet.limits.cpus.available) ||
memoryDynamicMax * factor > get(() => resourceSet.limits.memory.available) ||
_memory * factor > get(() => resourceSet.limits.memory.available) ||
(sumBy(VDIs, 'size') + sum(map(existingDisks, disk => disk.size))) * factor >
get(() => resourceSet.limits.disk.available)
)