mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
parent
882cd1c6da
commit
5054cb7ec3
@ -13,28 +13,29 @@
|
||||
* See the License for the specific language governing permissions and *
|
||||
* limitations under the License. *
|
||||
* ------------------------------------------------------------------------- */
|
||||
import { string, number, boolean, lazy, ObjectSchema } from 'yup'
|
||||
import { ObjectSchema, boolean, lazy, number, string } from 'yup'
|
||||
|
||||
import {
|
||||
HYPERVISORS,
|
||||
INPUT_TYPES,
|
||||
NUMA_MEMORY_ACCESS,
|
||||
NUMA_PIN_POLICIES,
|
||||
T,
|
||||
} from 'client/constants'
|
||||
import { useGetHostsQuery } from 'client/features/OneApi/host'
|
||||
import { getHugepageSizes } from 'client/models/Host'
|
||||
import {
|
||||
T,
|
||||
INPUT_TYPES,
|
||||
NUMA_PIN_POLICIES,
|
||||
NUMA_MEMORY_ACCESS,
|
||||
HYPERVISORS,
|
||||
} from 'client/constants'
|
||||
import {
|
||||
Field,
|
||||
arrayToOptions,
|
||||
filterFieldsByHypervisor,
|
||||
getFactorsOfNumber,
|
||||
sentenceCase,
|
||||
prettyBytes,
|
||||
arrayToOptions,
|
||||
getObjectSchemaFromFields,
|
||||
prettyBytes,
|
||||
sentenceCase,
|
||||
} from 'client/utils'
|
||||
|
||||
const { kvm, vcenter, firecracker } = HYPERVISORS
|
||||
const numaPinPolicies = Object.keys(NUMA_PIN_POLICIES)
|
||||
|
||||
const ENABLE_NUMA = {
|
||||
name: 'TOPOLOGY.ENABLE_NUMA',
|
||||
@ -51,9 +52,9 @@ const ENABLE_NUMA = {
|
||||
const PIN_POLICY = {
|
||||
name: 'TOPOLOGY.PIN_POLICY',
|
||||
label: T.PinPolicy,
|
||||
tooltip: [T.PinPolicyConcept, NUMA_PIN_POLICIES.join(', ')],
|
||||
tooltip: [T.PinPolicyConcept, numaPinPolicies.join(', ')],
|
||||
type: INPUT_TYPES.SELECT,
|
||||
values: arrayToOptions(NUMA_PIN_POLICIES, {
|
||||
values: arrayToOptions(numaPinPolicies, {
|
||||
addEmpty: false,
|
||||
getText: sentenceCase,
|
||||
}),
|
||||
@ -62,18 +63,48 @@ const PIN_POLICY = {
|
||||
string()
|
||||
.trim()
|
||||
.notRequired()
|
||||
.default(
|
||||
() =>
|
||||
context?.general?.HYPERVISOR === firecracker
|
||||
? NUMA_PIN_POLICIES[2] // SHARED
|
||||
: NUMA_PIN_POLICIES[0] // NONE
|
||||
)
|
||||
.default(() => {
|
||||
const { general, extra } = context || {}
|
||||
|
||||
return general?.HYPERVISOR === firecracker
|
||||
? NUMA_PIN_POLICIES.SHARED
|
||||
: ![vcenter].includes(general?.HYPERVISOR) &&
|
||||
extra?.TOPOLOGY?.NODE_AFFINITY
|
||||
? NUMA_PIN_POLICIES.NODE_AFFINITY
|
||||
: NUMA_PIN_POLICIES.NONE
|
||||
})
|
||||
),
|
||||
fieldProps: (hypervisor) => ({
|
||||
disabled: [vcenter, firecracker].includes(hypervisor),
|
||||
}),
|
||||
}
|
||||
|
||||
/** @type {Field} NODE_AFFINITY field */
|
||||
const NODE_AFFINITY = {
|
||||
name: 'TOPOLOGY.NODE_AFFINITY',
|
||||
label: T.NodeAffinity,
|
||||
tooltip: T.NodeAffinityConcept,
|
||||
dependOf: ['$general.HYPERVISOR', PIN_POLICY.name],
|
||||
type: INPUT_TYPES.TEXT,
|
||||
htmlType: (_, context) => {
|
||||
const values = context?.getValues() || {}
|
||||
const { general, extra } = values || {}
|
||||
|
||||
return ![vcenter, firecracker].includes(general?.HYPERVISOR) &&
|
||||
extra?.TOPOLOGY?.PIN_POLICY === NUMA_PIN_POLICIES.NODE_AFFINITY
|
||||
? 'number'
|
||||
: INPUT_TYPES.HIDDEN
|
||||
},
|
||||
validation: lazy((_, { context }) => {
|
||||
const { general, extra } = context || {}
|
||||
|
||||
return ![vcenter, firecracker].includes(general?.HYPERVISOR) &&
|
||||
extra?.TOPOLOGY?.PIN_POLICY === NUMA_PIN_POLICIES.NODE_AFFINITY
|
||||
? string().trim().required()
|
||||
: string().trim().notRequired()
|
||||
}),
|
||||
}
|
||||
|
||||
/** @type {Field} Cores field */
|
||||
const CORES = {
|
||||
name: 'TOPOLOGY.CORES',
|
||||
@ -190,7 +221,15 @@ const MEMORY_ACCESS = {
|
||||
*/
|
||||
const NUMA_FIELDS = (hypervisor) =>
|
||||
filterFieldsByHypervisor(
|
||||
[PIN_POLICY, CORES, SOCKETS, THREADS, HUGEPAGES, MEMORY_ACCESS],
|
||||
[
|
||||
PIN_POLICY,
|
||||
NODE_AFFINITY,
|
||||
CORES,
|
||||
SOCKETS,
|
||||
THREADS,
|
||||
HUGEPAGES,
|
||||
MEMORY_ACCESS,
|
||||
],
|
||||
hypervisor
|
||||
)
|
||||
|
||||
@ -211,17 +250,25 @@ const NUMA_SCHEMA = (hypervisor) =>
|
||||
const { ENABLE_NUMA: isEnabled, ...restOfTopology } = TOPOLOGY
|
||||
const hyperv = context?.general?.HYPERVISOR
|
||||
|
||||
![vcenter, kvm].includes(hyperv) &&
|
||||
isEnabled &&
|
||||
(ensuredResult.TOPOLOGY = { ...restOfTopology })
|
||||
if ([vcenter, kvm].includes(hyperv) && isEnabled) {
|
||||
if (
|
||||
restOfTopology?.NODE_AFFINITY &&
|
||||
restOfTopology.PIN_POLICY === NUMA_PIN_POLICIES.NODE_AFFINITY
|
||||
) {
|
||||
delete restOfTopology.PIN_POLICY
|
||||
} else {
|
||||
delete restOfTopology.NODE_AFFINITY
|
||||
}
|
||||
ensuredResult.TOPOLOGY = { ...restOfTopology }
|
||||
}
|
||||
|
||||
return { ...ensuredResult }
|
||||
}
|
||||
)
|
||||
|
||||
export {
|
||||
NUMA_FIELDS,
|
||||
SCHEMA_FIELDS as FIELDS,
|
||||
NUMA_SCHEMA as SCHEMA,
|
||||
ENABLE_NUMA,
|
||||
SCHEMA_FIELDS as FIELDS,
|
||||
NUMA_FIELDS,
|
||||
NUMA_SCHEMA as SCHEMA,
|
||||
}
|
||||
|
@ -1024,6 +1024,8 @@ module.exports = {
|
||||
NumaTopologyConcept:
|
||||
'These settings will help you to fine tune the performance of VMs',
|
||||
PinPolicy: 'Pin Policy',
|
||||
NodeAffinity: 'Numa Affinity',
|
||||
NodeAffinityConcept: 'Number of NUMA nodes (node affinity)',
|
||||
NumaNodeItem: 'Node #%s',
|
||||
NumaNodeTitle: 'Cores & CPUS',
|
||||
PinPolicyConcept: 'Virtual CPU pinning preference: %s',
|
||||
|
@ -63,7 +63,13 @@ export const VM_TEMPLATE_ACTIONS = {
|
||||
CHANGE_GROUP: ACTIONS.CHANGE_GROUP,
|
||||
}
|
||||
|
||||
export const NUMA_PIN_POLICIES = ['NONE', 'THREAD', 'SHARED', 'CORE']
|
||||
export const NUMA_PIN_POLICIES = {
|
||||
NONE: 'NONE',
|
||||
THREAD: 'THREAD',
|
||||
SHARED: 'SHARED',
|
||||
CORE: 'CORE',
|
||||
NODE_AFFINITY: 'NODE_AFFINITY',
|
||||
}
|
||||
|
||||
export const NUMA_MEMORY_ACCESS = ['shared', 'private']
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user