diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesList.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesList.tsx index a3fb05daa..f2467065f 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesList.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/OpenShiftVirtualMachinesList.tsx @@ -5,7 +5,7 @@ import { EnumToTuple, ResourceFieldFactory } from '@kubev2v/common'; import { ProviderVirtualMachinesList, VmData } from './components'; import { OpenShiftVirtualMachinesRow } from './OpenShiftVirtualMachinesRow'; import { ProviderVirtualMachinesProps } from './ProviderVirtualMachines'; -import { getVmPowerState } from './utils'; +import { getOpenShiftFeatureMap, getVmPowerState } from './utils'; const openShiftVmFieldsMetadataFactory: ResourceFieldFactory = (t) => [ { @@ -33,6 +33,26 @@ const openShiftVmFieldsMetadataFactory: ResourceFieldFactory = (t) => [ }, sortable: true, }, + { + resourceFieldId: 'features', + jsonPath: (data: VmData) => getOpenShiftFeatureMap(data?.vm), + label: t('Features'), + isVisible: true, + isIdentity: false, + filter: { + type: 'enum', + placeholderLabel: t('Filter by features'), + values: EnumToTuple({ + numa: 'NUMA', + gpus: 'GPUs', + hostDevices: 'Host Devices', + persistentTpm: 'Persistent TPM', + persistentEfi: 'Persistent EFI', + dedicatedCpu: 'Dedicated CPU', + }), + }, + sortable: true, + }, { resourceFieldId: 'template', jsonPath: "$.vm.object.metadata.labels['vm.kubevirt.io/template']", diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/components/ProviderVirtualMachinesList.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/components/ProviderVirtualMachinesList.tsx index 964041aac..0193991f7 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/components/ProviderVirtualMachinesList.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/components/ProviderVirtualMachinesList.tsx @@ -53,8 +53,9 @@ export const ProviderVirtualMachinesList: React.FC ); }; @@ -64,3 +65,8 @@ const concernsMatcher: ValueMatcher = { matchValue: (concerns: Concern[]) => (filter: string) => Array.isArray(concerns) && concerns.some(({ category }) => category === filter), }; + +const featuresMatcher: ValueMatcher = { + filterType: 'features', + matchValue: (features: { [key: string]: boolean }) => (filter: string) => !!features?.[filter], +}; diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/utils/helpers/getOpenShiftFeatureMap.ts b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/utils/helpers/getOpenShiftFeatureMap.ts new file mode 100644 index 000000000..9a6a59446 --- /dev/null +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/utils/helpers/getOpenShiftFeatureMap.ts @@ -0,0 +1,20 @@ +import { ProviderVirtualMachine, V1DomainSpec } from '@kubev2v/types'; + +export const getOpenShiftFeatureMap = (vm: ProviderVirtualMachine) => { + if (vm.providerType !== 'openshift') { + return {}; + } + const domain: V1DomainSpec = vm.object?.spec?.template?.spec?.domain; + if (!domain) { + return {}; + } + + return { + numa: !!domain.cpu?.numa, + gpus: !!domain.devices?.gpus?.length, + hostDevices: !!domain?.devices?.hostDevices?.length, + persistentTpm: domain?.devices?.tpm?.persistent, + persistentEfi: domain?.firmware?.bootloader?.efi?.persistent, + dedicatedCpu: domain?.cpu?.dedicatedCpuPlacement, + }; +}; diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/utils/helpers/index.ts b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/utils/helpers/index.ts index aa2d06682..c97ba37f1 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/utils/helpers/index.ts +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/VirtualMachines/utils/helpers/index.ts @@ -1,4 +1,5 @@ // @index(['./*', /style/g], f => `export * from '${f.path}';`) +export * from './getOpenShiftFeatureMap'; export * from './getVmPowerState'; export * from './vmProps'; // @endindex diff --git a/packages/types/src/types/k8s/V1VirtualMachine.ts b/packages/types/src/types/k8s/V1VirtualMachine.ts index da0544bad..4234a6942 100644 --- a/packages/types/src/types/k8s/V1VirtualMachine.ts +++ b/packages/types/src/types/k8s/V1VirtualMachine.ts @@ -114,7 +114,7 @@ interface V1VirtualMachineInstanceSpec { // Specification of the desired behavior of the VirtualMachineInstance on the host. // Domain DomainSpec `json:"domain"` - domain: DomainSpec; + domain: V1DomainSpec; // NodeSelector is a selector which must be true for the vmi to fit on a node. // Selector which must match a node's labels for the vmi to be scheduled on that node. @@ -235,7 +235,7 @@ interface V1VirtualMachineInstanceSpec { //AccessCredentials []AccessCredential `json:"accessCredentials,omitempty"` } -interface DomainSpec { +export interface V1DomainSpec { // Resources describes the Compute Resources required by this vmi. // Resources ResourceRequirements `json:"resources,omitempty"` resources?: { @@ -251,6 +251,8 @@ interface DomainSpec { cores: number; sockets: number; threads: number; + dedicatedCpuPlacement?: boolean; + numa?: unknown; }; // Memory allow specifying the VMI memory features. @@ -264,6 +266,13 @@ interface DomainSpec { // Firmware. // +optional // Firmware *Firmware `json:"firmware,omitempty"` + firmware?: { + bootloader?: { + efi?: { + persistent?: boolean; + }; + }; + }; // Clock sets the clock and timers of the vmi. // +optional @@ -355,6 +364,7 @@ interface Devices { // +optional // +listType=atomic // GPUs []GPU `json:"gpus,omitempty"` + gpus?: unknown[]; // Filesystems describes filesystem which is connected to the vmi. // +optional @@ -365,4 +375,9 @@ interface Devices { // +optional // +listType=atomic // HostDevices []HostDevice `json:"hostDevices,omitempty"` + hostDevices?: unknown[]; + + tpm?: { + persistent?: boolean; + }; } diff --git a/packages/types/src/types/k8s/index.ts b/packages/types/src/types/k8s/index.ts index 5ccaae0b0..d7939b817 100644 --- a/packages/types/src/types/k8s/index.ts +++ b/packages/types/src/types/k8s/index.ts @@ -5,4 +5,5 @@ export * from './K8sResourceCondition'; export * from './V1Namespace'; export * from './V1NetworkAttachmentDefinition'; export * from './V1Secret'; +export * from './V1VirtualMachine'; // @endindex