|
|
@ -166,7 +166,13 @@ type UpdateLimitsFunction = (options?: { |
|
|
|
memory?: bigint; |
|
|
|
memory?: bigint; |
|
|
|
storageGroupUUIDMapToFree?: StorageGroupUUIDMapToFree; |
|
|
|
storageGroupUUIDMapToFree?: StorageGroupUUIDMapToFree; |
|
|
|
virtualDisks?: VirtualDiskStates; |
|
|
|
virtualDisks?: VirtualDiskStates; |
|
|
|
}) => Partial<ReturnType<FilterAnvilsFunction>>; |
|
|
|
}) => Pick< |
|
|
|
|
|
|
|
ReturnType<FilterAnvilsFunction>, |
|
|
|
|
|
|
|
'maxCPUCores' | 'maxMemory' | 'maxVirtualDiskSizes' |
|
|
|
|
|
|
|
> & { |
|
|
|
|
|
|
|
formattedMaxMemory: string; |
|
|
|
|
|
|
|
formattedMaxVDSizes: string[]; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const MOCK_DATA = { |
|
|
|
const MOCK_DATA = { |
|
|
|
anvils: [ |
|
|
|
anvils: [ |
|
|
@ -780,12 +786,15 @@ const createVirtualDiskForm = ( |
|
|
|
const changeVDSize = (cvsValue: bigint = BIGINT_ZERO) => { |
|
|
|
const changeVDSize = (cvsValue: bigint = BIGINT_ZERO) => { |
|
|
|
set('sizes', cvsValue); |
|
|
|
set('sizes', cvsValue); |
|
|
|
|
|
|
|
|
|
|
|
const { maxVirtualDiskSizes } = updateLimits({ virtualDisks }); |
|
|
|
const { formattedMaxVDSizes, maxVirtualDiskSizes } = updateLimits({ |
|
|
|
|
|
|
|
virtualDisks, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
testInput({ |
|
|
|
testInput({ |
|
|
|
inputs: { |
|
|
|
inputs: { |
|
|
|
[`vd${vdIndex}Size`]: { |
|
|
|
[`vd${vdIndex}Size`]: { |
|
|
|
max: maxVirtualDiskSizes?.[vdIndex], |
|
|
|
displayMax: `${formattedMaxVDSizes[vdIndex]}`, |
|
|
|
|
|
|
|
max: maxVirtualDiskSizes[vdIndex], |
|
|
|
value: cvsValue, |
|
|
|
value: cvsValue, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1096,9 +1105,9 @@ const ProvisionServerDialog = ({ |
|
|
|
test: testMax, |
|
|
|
test: testMax, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
onFailure: ({ max, min }) => { |
|
|
|
onFailure: ({ displayMax, displayMin }) => { |
|
|
|
setInputCPUCoresMessage({ |
|
|
|
setInputCPUCoresMessage({ |
|
|
|
text: `The number of CPU cores is expected to be between ${min} and ${max}.`, |
|
|
|
text: `The number of CPU cores is expected to be between ${displayMin} and ${displayMax}.`, |
|
|
|
type: 'warning', |
|
|
|
type: 'warning', |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1108,6 +1117,8 @@ const ProvisionServerDialog = ({ |
|
|
|
}, |
|
|
|
}, |
|
|
|
memory: { |
|
|
|
memory: { |
|
|
|
defaults: { |
|
|
|
defaults: { |
|
|
|
|
|
|
|
displayMax: `${inputMemoryMax} ${inputMemoryUnit}`, |
|
|
|
|
|
|
|
displayMin: '1 B', |
|
|
|
max: memoryMax, |
|
|
|
max: memoryMax, |
|
|
|
min: 1, |
|
|
|
min: 1, |
|
|
|
onSuccess: () => { |
|
|
|
onSuccess: () => { |
|
|
@ -1123,9 +1134,9 @@ const ProvisionServerDialog = ({ |
|
|
|
test: testMax, |
|
|
|
test: testMax, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
onFailure: ({ max, min }) => { |
|
|
|
onFailure: ({ displayMax, displayMin }) => { |
|
|
|
setInputMemoryMessage({ |
|
|
|
setInputMemoryMessage({ |
|
|
|
text: `Memory is expected to be between ${min} B and ${max} B.`, |
|
|
|
text: `Memory is expected to be between ${displayMin} and ${displayMax}.`, |
|
|
|
type: 'warning', |
|
|
|
type: 'warning', |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1170,6 +1181,8 @@ const ProvisionServerDialog = ({ |
|
|
|
virtualDisks.inputSizeMessages.forEach((message, vdIndex) => { |
|
|
|
virtualDisks.inputSizeMessages.forEach((message, vdIndex) => { |
|
|
|
inputTests[`vd${vdIndex}Size`] = { |
|
|
|
inputTests[`vd${vdIndex}Size`] = { |
|
|
|
defaults: { |
|
|
|
defaults: { |
|
|
|
|
|
|
|
displayMax: `${virtualDisks.inputMaxes[vdIndex]} ${virtualDisks.inputUnits[vdIndex]}`, |
|
|
|
|
|
|
|
displayMin: '1 B', |
|
|
|
max: virtualDisks.maxes[vdIndex], |
|
|
|
max: virtualDisks.maxes[vdIndex], |
|
|
|
min: 1, |
|
|
|
min: 1, |
|
|
|
onSuccess: () => { |
|
|
|
onSuccess: () => { |
|
|
@ -1191,9 +1204,9 @@ const ProvisionServerDialog = ({ |
|
|
|
test: testMax, |
|
|
|
test: testMax, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
onFailure: ({ max, min }) => { |
|
|
|
onFailure: ({ displayMax, displayMin }) => { |
|
|
|
virtualDisks.inputSizeMessages[vdIndex] = { |
|
|
|
virtualDisks.inputSizeMessages[vdIndex] = { |
|
|
|
text: `Virtual disk ${vdIndex} size is expected to be between ${min} B and ${max} B.`, |
|
|
|
text: `Virtual disk ${vdIndex} size is expected to be between ${displayMin} and ${displayMax}.`, |
|
|
|
type: 'warning', |
|
|
|
type: 'warning', |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1256,13 +1269,16 @@ const ProvisionServerDialog = ({ |
|
|
|
setInputCPUCoresMax(maxCPUCores); |
|
|
|
setInputCPUCoresMax(maxCPUCores); |
|
|
|
setMemoryMax(maxMemory); |
|
|
|
setMemoryMax(maxMemory); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const formattedMaxVDSizes: string[] = []; |
|
|
|
|
|
|
|
|
|
|
|
ulVirtualDisks.maxes = maxVirtualDiskSizes; |
|
|
|
ulVirtualDisks.maxes = maxVirtualDiskSizes; |
|
|
|
ulVirtualDisks.maxes.forEach((vdMaxSize, vdIndex) => { |
|
|
|
ulVirtualDisks.maxes.forEach((vdMaxSize, vdIndex) => { |
|
|
|
dSize(vdMaxSize, { |
|
|
|
dSize(vdMaxSize, { |
|
|
|
fromUnit: 'B', |
|
|
|
fromUnit: 'B', |
|
|
|
onSuccess: { |
|
|
|
onSuccess: { |
|
|
|
string: (value) => { |
|
|
|
string: (value, unit) => { |
|
|
|
ulVirtualDisks.inputMaxes[vdIndex] = value; |
|
|
|
ulVirtualDisks.inputMaxes[vdIndex] = value; |
|
|
|
|
|
|
|
formattedMaxVDSizes[vdIndex] = `${value} ${unit}`; |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
toUnit: ulVirtualDisks.inputUnits[vdIndex], |
|
|
|
toUnit: ulVirtualDisks.inputUnits[vdIndex], |
|
|
@ -1274,15 +1290,22 @@ const ProvisionServerDialog = ({ |
|
|
|
setIncludeFileUUIDs(fileUUIDs); |
|
|
|
setIncludeFileUUIDs(fileUUIDs); |
|
|
|
setIncludeStorageGroupUUIDs(storageGroupUUIDs); |
|
|
|
setIncludeStorageGroupUUIDs(storageGroupUUIDs); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let formattedMaxMemory = ''; |
|
|
|
|
|
|
|
|
|
|
|
dSize(maxMemory, { |
|
|
|
dSize(maxMemory, { |
|
|
|
fromUnit: 'B', |
|
|
|
fromUnit: 'B', |
|
|
|
onSuccess: { |
|
|
|
onSuccess: { |
|
|
|
string: (value) => setInputMemoryMax(value), |
|
|
|
string: (value, unit) => { |
|
|
|
|
|
|
|
setInputMemoryMax(value); |
|
|
|
|
|
|
|
formattedMaxMemory = `${value} ${unit}`; |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
toUnit: ulInputMemoryUnit, |
|
|
|
toUnit: ulInputMemoryUnit, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
|
|
|
|
formattedMaxMemory, |
|
|
|
|
|
|
|
formattedMaxVDSizes, |
|
|
|
maxCPUCores, |
|
|
|
maxCPUCores, |
|
|
|
maxMemory, |
|
|
|
maxMemory, |
|
|
|
maxVirtualDiskSizes, |
|
|
|
maxVirtualDiskSizes, |
|
|
@ -1302,12 +1325,20 @@ const ProvisionServerDialog = ({ |
|
|
|
}: { cmValue?: bigint; cmUnit?: DataSizeUnit } = {}) => { |
|
|
|
}: { cmValue?: bigint; cmUnit?: DataSizeUnit } = {}) => { |
|
|
|
setMemory(cmValue); |
|
|
|
setMemory(cmValue); |
|
|
|
|
|
|
|
|
|
|
|
const { maxMemory } = updateLimits({ |
|
|
|
const { formattedMaxMemory, maxMemory } = updateLimits({ |
|
|
|
inputMemoryUnit: cmUnit, |
|
|
|
inputMemoryUnit: cmUnit, |
|
|
|
memory: cmValue, |
|
|
|
memory: cmValue, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
testInput({ inputs: { memory: { max: maxMemory, value: cmValue } } }); |
|
|
|
testInput({ |
|
|
|
|
|
|
|
inputs: { |
|
|
|
|
|
|
|
memory: { |
|
|
|
|
|
|
|
displayMax: formattedMaxMemory, |
|
|
|
|
|
|
|
max: maxMemory, |
|
|
|
|
|
|
|
value: cmValue, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const handleInputMemoryValueChange = ({ |
|
|
|
const handleInputMemoryValueChange = ({ |
|
|
@ -1330,7 +1361,7 @@ const ProvisionServerDialog = ({ |
|
|
|
unit, |
|
|
|
unit, |
|
|
|
(convertedMemory) => |
|
|
|
(convertedMemory) => |
|
|
|
changeMemory({ cmValue: convertedMemory, cmUnit: unit }), |
|
|
|
changeMemory({ cmValue: convertedMemory, cmUnit: unit }), |
|
|
|
() => changeMemory(), |
|
|
|
() => changeMemory({ cmUnit: unit }), |
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|