mirror of
https://github.com/OpenNebula/one.git
synced 2026-12-01 20:56:42 +09:00
F OpenNebula/one#7153: Expose DS cache options in Sunstone (#3841)
Signed-off-by: Victor Hansson <vhansson@opennebula.io> Co-authored-by: Tino Vázquez <cvazquez@opennebula.io>
This commit is contained in:
1 parent
9839819ca0
commit
4f523bf3df
3 files changed
+136
-1
No files matched your search
+124
-1
@@ -14,6 +14,7 @@
|
||||
* limitations under the License. *
|
||||
* ------------------------------------------------------------------------- */
|
||||
import { DATASTORE_TYPES, INPUT_TYPES, T } from '@ConstantsModule'
|
||||
import { InputAdornment } from '@mui/material'
|
||||
import { Field } from '@UtilsModule'
|
||||
import { array, boolean, number, string } from 'yup'
|
||||
import { isCeph, isLvm, isShared, isSsh, typeIsOneOf } from '../../functions'
|
||||
@@ -111,7 +112,7 @@ const NO_DECOMPRESS = {
|
||||
dependOf: '$general.STORAGE_BACKEND',
|
||||
htmlType: (type) =>
|
||||
!typeIsOneOf(type, [isShared, isSsh, isCeph, isLvm]) && INPUT_TYPES.HIDDEN,
|
||||
grid: { xs: 12, md: 6 },
|
||||
grid: { md: 6 },
|
||||
}
|
||||
|
||||
/** @type {Field} - Check capacity field */
|
||||
@@ -271,6 +272,123 @@ const NFS_AUTO_OPTS = {
|
||||
grid: { xs: 12, md: 6 },
|
||||
}
|
||||
|
||||
/* Distributed cache options */
|
||||
|
||||
const ENABLE_CACHE = {
|
||||
name: 'ENABLE_CACHE',
|
||||
label: T.EnableDistributedCache,
|
||||
type: INPUT_TYPES.SWITCH,
|
||||
validation: boolean().yesOrNo().default(false),
|
||||
dependOf: ['$general.STORAGE_BACKEND', '$general.TYPE'],
|
||||
htmlType: ([STORAGE_BACKEND, TYPE] = []) => {
|
||||
if (
|
||||
!typeIsOneOf(STORAGE_BACKEND, [isSsh]) ||
|
||||
TYPE !== DATASTORE_TYPES?.IMAGE?.value
|
||||
) {
|
||||
return INPUT_TYPES.HIDDEN
|
||||
}
|
||||
},
|
||||
grid: { md: 6 },
|
||||
}
|
||||
|
||||
const CACHE_PATH = {
|
||||
name: 'CACHE_PATH',
|
||||
label: T.CachePath,
|
||||
type: INPUT_TYPES.TEXT,
|
||||
validation: string()
|
||||
.trim()
|
||||
.notRequired()
|
||||
.default(() => '/var/lib/one/cache'),
|
||||
dependOf: ['$general.STORAGE_BACKEND', '$general.TYPE', ENABLE_CACHE.name],
|
||||
htmlType: ([STORAGE_BACKEND, TYPE, CACHE_ENABLED] = []) => {
|
||||
if (
|
||||
!typeIsOneOf(STORAGE_BACKEND, [isSsh]) ||
|
||||
TYPE !== DATASTORE_TYPES?.IMAGE?.value ||
|
||||
!CACHE_ENABLED
|
||||
) {
|
||||
return INPUT_TYPES.HIDDEN
|
||||
}
|
||||
},
|
||||
grid: { md: 6.125 },
|
||||
}
|
||||
|
||||
const CACHE_MAX_SIZE = {
|
||||
name: 'CACHE_MAX_SIZE',
|
||||
label: T.CacheMaxSize,
|
||||
type: INPUT_TYPES.SLIDER,
|
||||
validation: number()
|
||||
.positive()
|
||||
.min(0)
|
||||
.max(100)
|
||||
.default(() => 10),
|
||||
dependOf: ['$general.STORAGE_BACKEND', '$general.TYPE', ENABLE_CACHE.name],
|
||||
htmlType: ([STORAGE_BACKEND, TYPE, CACHE_ENABLED] = []) => {
|
||||
if (
|
||||
!typeIsOneOf(STORAGE_BACKEND, [isSsh]) ||
|
||||
TYPE !== DATASTORE_TYPES?.IMAGE?.value ||
|
||||
!CACHE_ENABLED
|
||||
) {
|
||||
return INPUT_TYPES.HIDDEN
|
||||
}
|
||||
},
|
||||
grid: { md: 12 },
|
||||
fieldProps: {
|
||||
min: 0,
|
||||
max: 100,
|
||||
step: 1,
|
||||
endAdornment: <InputAdornment position="end">%</InputAdornment>,
|
||||
},
|
||||
}
|
||||
|
||||
const CACHE_UPSTREAMS = {
|
||||
name: 'CACHE_UPSTREAMS',
|
||||
label: T.CacheUpstreams,
|
||||
tooltip: [T.PressKeysToAddAValue, ['ENTER']],
|
||||
type: INPUT_TYPES.AUTOCOMPLETE,
|
||||
multiple: true,
|
||||
validation: array(string().trim()).default(() => []),
|
||||
dependOf: ['$general.STORAGE_BACKEND', '$general.TYPE', ENABLE_CACHE.name],
|
||||
htmlType: ([STORAGE_BACKEND, TYPE, CACHE_ENABLED] = []) => {
|
||||
if (
|
||||
!typeIsOneOf(STORAGE_BACKEND, [isSsh]) ||
|
||||
TYPE !== DATASTORE_TYPES?.IMAGE?.value ||
|
||||
!CACHE_ENABLED
|
||||
) {
|
||||
return INPUT_TYPES.HIDDEN
|
||||
}
|
||||
},
|
||||
fieldProps: {
|
||||
freeSolo: true,
|
||||
},
|
||||
grid: { md: 12 },
|
||||
}
|
||||
|
||||
const CACHE_MIN_AGE = {
|
||||
name: 'CACHE_MIN_AGE',
|
||||
label: T.CacheMinAge,
|
||||
type: INPUT_TYPES.TEXT,
|
||||
validation: number()
|
||||
.positive()
|
||||
.min(0)
|
||||
.default(() => 0),
|
||||
dependOf: ['$general.STORAGE_BACKEND', '$general.TYPE', ENABLE_CACHE.name],
|
||||
htmlType: ([STORAGE_BACKEND, TYPE, CACHE_ENABLED] = []) => {
|
||||
if (
|
||||
!typeIsOneOf(STORAGE_BACKEND, [isSsh]) ||
|
||||
TYPE !== DATASTORE_TYPES?.IMAGE?.value ||
|
||||
!CACHE_ENABLED
|
||||
) {
|
||||
return INPUT_TYPES.HIDDEN
|
||||
}
|
||||
},
|
||||
grid: { md: 5.875 },
|
||||
fieldProps: {
|
||||
InputProps: {
|
||||
endAdornment: <InputAdornment position="end">{T.Seconds}</InputAdornment>,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
/** @type {Field[]} - Common fields */
|
||||
export const COMMON_FIELDS = [
|
||||
RESTRICTED_DIRS,
|
||||
@@ -281,6 +399,11 @@ export const COMMON_FIELDS = [
|
||||
LIMIT_TRANSFER_BW,
|
||||
LVM_THIN_ENABLE,
|
||||
NO_DECOMPRESS,
|
||||
ENABLE_CACHE,
|
||||
CACHE_PATH,
|
||||
CACHE_MIN_AGE,
|
||||
CACHE_MAX_SIZE,
|
||||
CACHE_UPSTREAMS,
|
||||
DATASTORE_CAPACITY_CHECK,
|
||||
QCOW2_STANDALONE,
|
||||
NFS_AUTO_ENABLE,
|
||||
|
||||
@@ -80,6 +80,7 @@ const Steps = createSteps(
|
||||
[CLUSTER_ID]: [cluster] = [],
|
||||
[CONF_ID]: {
|
||||
RESTRICTED_DIRS,
|
||||
CACHE_UPSTREAMS,
|
||||
SAFE_DIRS,
|
||||
BRIDGE_LIST,
|
||||
CEPH_HOST,
|
||||
@@ -110,6 +111,9 @@ const Steps = createSteps(
|
||||
const restrictedDirs =
|
||||
RESTRICTED_DIRS?.length > 0 ? RESTRICTED_DIRS.join(' ') : undefined
|
||||
|
||||
const cacheUpstreams =
|
||||
CACHE_UPSTREAMS?.length > 0 ? CACHE_UPSTREAMS.join(',') : undefined
|
||||
|
||||
const safeDirs = SAFE_DIRS?.length > 0 ? SAFE_DIRS.join(' ') : undefined
|
||||
|
||||
const bridgeList =
|
||||
@@ -129,6 +133,7 @@ const Steps = createSteps(
|
||||
DS_MAD: dsMadValue,
|
||||
TM_MAD: tmMad,
|
||||
RESTRICTED_DIRS: restrictedDirs,
|
||||
CACHE_UPSTREAMS: cacheUpstreams,
|
||||
SAFE_DIRS: safeDirs,
|
||||
BRIDGE_LIST: bridgeList,
|
||||
COMPATIBLE_SYS_DS: compatibleSysDs,
|
||||
|
||||
@@ -2101,6 +2101,13 @@ module.exports = {
|
||||
If set, it will overwrite the default device mapping`,
|
||||
BusAdapterController: 'Bus adapter controller',
|
||||
Cache: 'Cache',
|
||||
EnableDistributedCache: 'Enable the distributed cache',
|
||||
CachePath: 'Absolute directory where cached images will be stored.',
|
||||
CacheMaxSize:
|
||||
'Maximum percentage of disk (cache path), to be allocated for caching.',
|
||||
CacheUpstreams:
|
||||
"List of one or more central cache hostnames or IPs (e.g., 'hostname0,hostname1'). Leave empty to disable central caches.",
|
||||
CacheMinAge: 'Minimum age before a cached image can be evicted.',
|
||||
IoPolicy: 'IO Policy',
|
||||
Discard: 'Discard',
|
||||
IopsSize: 'Size of IOPS per second',
|
||||
|
||||
Reference in new issue
Block a user