File tree Expand file tree Collapse file tree 4 files changed +13
-8
lines changed
components/NetworkInterfaceModal/components/hooks Expand file tree Collapse file tree 4 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,10 @@ import { useMemo } from 'react';
22
33import { NetworkAttachmentDefinitionModelGroupVersionKind } from '@kubevirt-ui/kubevirt-api/console' ;
44import useNADListPermissions from '@kubevirt-utils/components/NetworkInterfaceModal/components/hooks/useNADListPermissions' ;
5- import { getExtraNADResources } from '@kubevirt-utils/components/NetworkInterfaceModal/components/hooks/utils' ;
6- import { getName } from '@kubevirt-utils/resources/shared' ;
7- import { PRIMARY_UDN_BINDING } from '@kubevirt-utils/resources/vm/utils/network/constants' ;
5+ import {
6+ filterUDNNads ,
7+ getExtraNADResources ,
8+ } from '@kubevirt-utils/components/NetworkInterfaceModal/components/hooks/utils' ;
89import { isEmpty } from '@kubevirt-utils/utils/utils' ;
910import { K8sResourceCommon , useK8sWatchResources } from '@openshift-console/dynamic-plugin-sdk' ;
1011
@@ -24,9 +25,8 @@ const useNADsData: UseNADsData = (namespace) => {
2425 const accumulatedData = useMemo ( ( ) => {
2526 return ( Object . values ( data ) || [ ] ) ?. reduce (
2627 ( acc , nads ) => {
27- const nadsWithNoPrimaryUDNBinding =
28- nads ?. data ?. filter ( ( nad ) => getName ( nad ) !== PRIMARY_UDN_BINDING ) || [ ] ;
29- acc . nads . push ( ...nadsWithNoPrimaryUDNBinding ) ;
28+ const availableNADs = filterUDNNads ( nads ?. data || [ ] ) ;
29+ acc . nads . push ( ...availableNADs ) ;
3030 acc . loaded = acc . loaded && ( ! isEmpty ( nads ?. loadError ) || nads ?. loaded ) ;
3131 acc . loadError = isEmpty ( nads ?. loadError ) ? acc . loadError : nads ?. loadError ;
3232 return acc ;
Original file line number Diff line number Diff line change @@ -5,7 +5,10 @@ import {
55 OPENSHIFT_MULTUS_NS ,
66 OPENSHIFT_SRIOV_NETWORK_OPERATOR_NS ,
77} from '@kubevirt-utils/constants/constants' ;
8+ import { getLabel } from '@kubevirt-utils/resources/shared' ;
9+ import { UDN_LABEL } from '@kubevirt-utils/resources/udn/constants' ;
810import { isEmpty } from '@kubevirt-utils/utils/utils' ;
11+ import { K8sResourceCommon } from '@openshift-console/dynamic-plugin-sdk' ;
912
1013const resources = {
1114 default : {
@@ -41,3 +44,6 @@ export const getExtraNADResources = (
4144 return newMap ;
4245 } , { } ) ;
4346} ;
47+
48+ export const filterUDNNads = ( nads : K8sResourceCommon [ ] ) =>
49+ nads ?. filter ( ( nad ) => getLabel ( nad , UDN_LABEL ) === undefined ) ;
Original file line number Diff line number Diff line change 11export const LAYER2_TOPOLOGY = 'layer2' ;
22export const LAYER3_TOPOLOGY = 'layer3' ;
33export const LOCALNET_TOPOLOGY = 'localnet' ;
4+ export const UDN_LABEL = 'k8s.ovn.org/user-defined-network' ;
45
56export const PrimaryTopologies = [ LAYER2_TOPOLOGY , LAYER3_TOPOLOGY ] ;
67export const SecondaryTopologies = [ LOCALNET_TOPOLOGY ] ;
Original file line number Diff line number Diff line change @@ -43,5 +43,3 @@ const labels2types: LabelMap = Object.fromEntries(
4343
4444export const interfaceTypesProxy = new Proxy < TypeMap > ( types2labels , typeHandler ) ;
4545export const interfaceLabelsProxy = new Proxy < LabelMap > ( labels2types , labelHandler ) ;
46-
47- export const PRIMARY_UDN_BINDING = 'primary-udn-kubevirt-binding' ;
You can’t perform that action at this time.
0 commit comments