mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-13 21:21:44 +00:00
Update selected vGpus devices adding the provisioned devices
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
parent
fa545ad134
commit
8117e99b54
@ -51,5 +51,6 @@ export const HCI = {
|
|||||||
PARENT_SRIOV_GPU: 'harvesterhci.io/parentSRIOVGPUDevice',
|
PARENT_SRIOV_GPU: 'harvesterhci.io/parentSRIOVGPUDevice',
|
||||||
VM_MAINTENANCE_MODE_STRATEGY: 'harvesterhci.io/maintain-mode-strategy',
|
VM_MAINTENANCE_MODE_STRATEGY: 'harvesterhci.io/maintain-mode-strategy',
|
||||||
NODE_CPU_MANAGER_UPDATE_STATUS: 'harvesterhci.io/cpu-manager-update-status',
|
NODE_CPU_MANAGER_UPDATE_STATUS: 'harvesterhci.io/cpu-manager-update-status',
|
||||||
CPU_MANAGER: 'cpumanager'
|
CPU_MANAGER: 'cpumanager',
|
||||||
|
VM_DEVICE_ALLOCATION_DETAILS: 'harvesterhci.io/deviceAllocationDetails',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import remove from 'lodash/remove';
|
|||||||
import { set } from '@shell/utils/object';
|
import { set } from '@shell/utils/object';
|
||||||
import { HCI } from '../../../types';
|
import { HCI } from '../../../types';
|
||||||
import VGpuDeviceList from './VGpuDeviceList';
|
import VGpuDeviceList from './VGpuDeviceList';
|
||||||
|
import { uniq } from '@shell/utils/array';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'VirtualMachineVGpuDevices',
|
name: 'VirtualMachineVGpuDevices',
|
||||||
@ -45,7 +46,10 @@ export default {
|
|||||||
this[key] = res[key];
|
this[key] = res[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
(this.value?.domain?.devices?.gpus || []).forEach(({ name }) => {
|
uniq([
|
||||||
|
...(this.value?.domain?.devices?.gpus || []).map(({ name }) => name),
|
||||||
|
...Object.values(this.vm?.provisionedVGpus).reduce((acc, gpus) => [...acc, ...gpus], [])
|
||||||
|
]).forEach((name) => {
|
||||||
if (this.enabledDevices.find(device => device?.metadata?.name === name)) {
|
if (this.enabledDevices.find(device => device?.metadata?.name === name)) {
|
||||||
this.selectedDevices.push(name);
|
this.selectedDevices.push(name);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1098,6 +1098,16 @@ export default class VirtVm extends HarvesterResource {
|
|||||||
return this.spec?.template?.spec?.domain?.devices?.hostDevices || [];
|
return this.spec?.template?.spec?.domain?.devices?.hostDevices || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get provisionedVGpus() {
|
||||||
|
try {
|
||||||
|
const deviceAllocationDetails = JSON.parse(this.metadata?.annotations[HCI_ANNOTATIONS.VM_DEVICE_ALLOCATION_DETAILS] || '{}');
|
||||||
|
|
||||||
|
return deviceAllocationDetails?.gpus || {};
|
||||||
|
} catch (error) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setInstanceLabels(val) {
|
setInstanceLabels(val) {
|
||||||
if ( !this.spec?.template?.metadata?.labels ) {
|
if ( !this.spec?.template?.metadata?.labels ) {
|
||||||
set(this, 'spec.template.metadata.labels', {});
|
set(this, 'spec.template.metadata.labels', {});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user