mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-12 08:58:17 +03:00
B OpenNebula/one#6293: Add vGPU profile selector (#3326)
* Adds vGPU profiles to dummy driver * Adds back in missing vGPU selector to Sunstone Signed-off-by: Victor Hansson <vhansson@opennebula.io>
This commit is contained in:
parent
a68e0a73c3
commit
67c99abafc
@ -14,6 +14,7 @@
|
||||
* limitations under the License. *
|
||||
* ------------------------------------------------------------------------- */
|
||||
import { string, ObjectSchema, boolean } from 'yup'
|
||||
import { useFormContext } from 'react-hook-form'
|
||||
import { useGetHostsAdminQuery } from 'client/features/OneApi/host'
|
||||
import { getPciDevices } from 'client/models/Host'
|
||||
import {
|
||||
@ -86,7 +87,7 @@ const NAME_FIELD = {
|
||||
.trim()
|
||||
.notRequired()
|
||||
.afterSubmit(() => undefined),
|
||||
grid: { sm: 12, md: 3 },
|
||||
grid: { sm: 12, md: 4 },
|
||||
}
|
||||
|
||||
/** @type {Field} PCI device field */
|
||||
@ -113,7 +114,7 @@ const DEVICE_FIELD = {
|
||||
|
||||
return type ? schema.notRequired() : schema.required()
|
||||
}),
|
||||
grid: { xs: 12, sm: 3, md: 2 },
|
||||
grid: { xs: 12, md: 2 },
|
||||
}
|
||||
|
||||
/** @type {Field} PCI device field */
|
||||
@ -140,7 +141,7 @@ const VENDOR_FIELD = {
|
||||
|
||||
return type ? schema.notRequired() : schema.required()
|
||||
}),
|
||||
grid: { xs: 12, sm: 3, md: 2 },
|
||||
grid: { xs: 12, md: 2 },
|
||||
}
|
||||
|
||||
/** @type {Field} PCI device field */
|
||||
@ -167,7 +168,7 @@ const CLASS_FIELD = {
|
||||
|
||||
return type ? schema.notRequired() : schema.required()
|
||||
}),
|
||||
grid: { xs: 12, sm: 3, md: 2 },
|
||||
grid: { xs: 12, md: 2 },
|
||||
}
|
||||
|
||||
/** @type {Field} PCI device field */
|
||||
@ -201,6 +202,47 @@ const SHORT_ADDRESS = {
|
||||
}),
|
||||
}
|
||||
|
||||
/** @type {Field} Name PCI device field */
|
||||
const PROFILE_FIELD = {
|
||||
name: 'PROFILE',
|
||||
label: T.Profile,
|
||||
type: INPUT_TYPES.AUTOCOMPLETE,
|
||||
values: (dependencies = []) => {
|
||||
const [selectedPciDevice] = dependencies
|
||||
const { data = [] } = useGetHostsAdminQuery({
|
||||
skip: selectedPciDevice === undefined,
|
||||
})
|
||||
if (selectedPciDevice && data) {
|
||||
const pciDevices = data.map(getPciDevices).flat()
|
||||
const [DEVICE, VENDOR, CLASS] = selectedPciDevice?.split(';')
|
||||
const selectedDevice = pciDevices.find(
|
||||
(device) =>
|
||||
device?.DEVICE === DEVICE &&
|
||||
device?.VENDOR === VENDOR &&
|
||||
device?.CLASS === CLASS
|
||||
)
|
||||
|
||||
const profiles = selectedDevice?.PROFILES?.split(',') || []
|
||||
|
||||
if (!profiles?.length) {
|
||||
const { setValue } = useFormContext()
|
||||
setValue(PROFILE_FIELD.name, '')
|
||||
}
|
||||
|
||||
return arrayToOptions(profiles)
|
||||
}
|
||||
|
||||
return arrayToOptions([])
|
||||
},
|
||||
dependOf: [NAME_FIELD.name, SPECIFIC_DEVICE.name],
|
||||
htmlType: ([_, specificDevice] = []) => specificDevice && INPUT_TYPES.HIDDEN,
|
||||
validation: string()
|
||||
.trim()
|
||||
.notRequired()
|
||||
.default(() => ''),
|
||||
grid: { md: 6 },
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} oneConfig - Config of oned.conf
|
||||
* @param {boolean} adminGroup - User is admin or not
|
||||
@ -215,6 +257,7 @@ export const PCI_FIELDS = (oneConfig, adminGroup) =>
|
||||
VENDOR_FIELD,
|
||||
CLASS_FIELD,
|
||||
SHORT_ADDRESS,
|
||||
PROFILE_FIELD,
|
||||
],
|
||||
'PCI',
|
||||
oneConfig,
|
||||
@ -229,4 +272,5 @@ export const PCI_SCHEMA = getObjectSchemaFromFields([
|
||||
VENDOR_FIELD,
|
||||
CLASS_FIELD,
|
||||
SHORT_ADDRESS,
|
||||
PROFILE_FIELD,
|
||||
])
|
||||
|
@ -100,6 +100,9 @@ const PciDevices = ({ oneConfig, adminGroup }) => {
|
||||
CLASS: {
|
||||
__delete__: true,
|
||||
},
|
||||
PROFILE: {
|
||||
__delete__: true,
|
||||
},
|
||||
SHORT_ADDRESS: true,
|
||||
})
|
||||
} else {
|
||||
@ -107,6 +110,7 @@ const PciDevices = ({ oneConfig, adminGroup }) => {
|
||||
DEVICE: true,
|
||||
VENDOR: true,
|
||||
CLASS: true,
|
||||
PROFILE: true,
|
||||
SHORT_ADDRESS: {
|
||||
__delete__: true,
|
||||
},
|
||||
|
@ -405,6 +405,7 @@ export const {
|
||||
useLazyGetHostQuery,
|
||||
useGetHostsQuery,
|
||||
useGetHostsAdminQuery,
|
||||
useLazyGetHostsAdminQuery,
|
||||
useLazyGetHostsQuery,
|
||||
useGetHostMonitoringQuery,
|
||||
useLazyGetHostMonitoringQuery,
|
||||
|
@ -78,6 +78,7 @@ def pci
|
||||
TYPE = "10de:0863:0300",
|
||||
VENDOR = "10de",
|
||||
VENDOR_NAME = "NVIDIA Corporation",
|
||||
PROFILES = "nvidia-908,nvidia-909,nvidia-910,nvidia-911,nvidia-912,nvidia-913,nvidia-914,nvidia-915,nvidia-916,nvidia-917,nvidia-918,nvidia-919,nvidia-920,nvidia-921,nvidia-922,nvidia-923,nvidia-924,nvidia-925",
|
||||
NUMA_NODE="1"
|
||||
]
|
||||
PCI = [ ADDRESS = "0000:00:06:0",
|
||||
|
Loading…
x
Reference in New Issue
Block a user