Skip to content

Commit

Permalink
Merge pull request #855 from rszwajko/migrateBtnV7
Browse files Browse the repository at this point in the history
Add a fast Create Plan page - step 3
  • Loading branch information
yaacov authored Jan 29, 2024
2 parents fbc4200 + 840bb8f commit 3670aa5
Show file tree
Hide file tree
Showing 16 changed files with 1,416 additions and 191 deletions.
2 changes: 2 additions & 0 deletions packages/eslint-plugin/cspell.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ filesystems
bootloader
typeahead
immer
networkattachmentdefinitions
nicprofiles
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"A user password for connecting to the Red Hat Virtualization Manager (RHVM) API endpoint.": "A user password for connecting to the Red Hat Virtualization Manager (RHVM) API endpoint.",
"A user password for connecting to the vCenter API endpoint.": "A user password for connecting to the vCenter API endpoint.",
"Actions": "Actions",
"Add mapping": "Add mapping",
"Add source and target providers for the migration.": "Add source and target providers for the migration.",
"Application credential ID": "Application credential ID",
"Application credential name": "Application credential name",
Expand Down Expand Up @@ -85,6 +86,7 @@
"Defines the CPU limits allocated to the main container in the controller pod. The default value is 500 milliCPU.": "Defines the CPU limits allocated to the main container in the controller pod. The default value is 500 milliCPU.",
"Delete": "Delete",
"Delete {{model.label}}": "Delete {{model.label}}",
"Delete mapping": "Delete mapping",
"Delete Mapping": "Delete Mapping",
"Delete NetworkMap?": "Delete NetworkMap?",
"Delete Plan?": "Delete Plan?",
Expand Down Expand Up @@ -229,14 +231,17 @@
"Namespace is not defined": "Namespace is not defined",
"Network for data transfer": "Network for data transfer",
"Network interfaces": "Network interfaces",
"Network map:": "Network map:",
"NetworkAttachmentDefinitions": "NetworkAttachmentDefinitions",
"NetworkMaps": "NetworkMaps",
"NetworkMaps for virtualization": "NetworkMaps for virtualization",
"Networks": "Networks",
"Networks used by the selected VMs": "Networks used by the selected VMs",
"No credentials found.": "No credentials found.",
"No inventory data available.": "No inventory data available.",
"No NetworkMaps found in namespace <1>{namespace}</1>.": "No NetworkMaps found in namespace <1>{namespace}</1>.",
"No NetworkMaps found.": "No NetworkMaps found.",
"No networks in this category": "No networks in this category",
"No owner": "No owner",
"No Plans found in namespace <1>{namespace}</1>.": "No Plans found in namespace <1>{namespace}</1>.",
"No Plans found.": "No Plans found.",
Expand All @@ -249,6 +254,7 @@
"No secret.": "No secret.",
"No StorageMaps found in namespace <1>{namespace}</1>.": "No StorageMaps found in namespace <1>{namespace}</1>.",
"No StorageMaps found.": "No StorageMaps found.",
"No storages in this category": "No storages in this category",
"Not Ready": "Not Ready",
"Note: If 'Skip certificate validation' is selected, migrations from this provider will not be secure.<br><br> Insecure migration means that the transferred data is sent over an insecure connection and potentially sensitive data could be exposed.": "Note: If 'Skip certificate validation' is selected, migrations from this provider will not be secure.<br><br> Insecure migration means that the transferred data is sent over an insecure connection and potentially sensitive data could be exposed.",
"Note: It is strongly recommended to specify a VDDK init image to accelerate migrations.": "Note: It is strongly recommended to specify a VDDK init image to accelerate migrations.",
Expand Down Expand Up @@ -287,6 +293,8 @@
"OpenStack REST API user name.": "OpenStack REST API user name.",
"Operator": "Operator",
"Operator conditions define the current state of the controller": "Operator conditions define the current state of the controller",
"Other networks present on the source provider ": "Other networks present on the source provider ",
"Other storages present on the source provider ": "Other storages present on the source provider ",
"OvaPath": "OvaPath",
"Overview": "Overview",
"Owner": "Owner",
Expand Down Expand Up @@ -365,8 +373,10 @@
"Storage": "Storage",
"Storage classes": "Storage classes",
"Storage domains": "Storage domains",
"Storage map:": "Storage map:",
"StorageMaps": "StorageMaps",
"StorageMaps for virtualization": "StorageMaps for virtualization",
"Storages used by the selected VMs": "Storages used by the selected VMs",
"Succeeded": "Succeeded",
"Target and Source": "Target and Source",
"Target namespace": "Target namespace",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { useMemo } from 'react';

import {
OpenShiftNetworkAttachmentDefinition,
OpenstackNetwork,
OVirtNetwork,
ProviderType,
V1beta1Provider,
VSphereNetwork,
} from '@kubev2v/types';

import useProviderInventory from './useProviderInventory';

export type InventoryNetwork =
| OpenShiftNetworkAttachmentDefinition
| OpenstackNetwork
| OVirtNetwork
| VSphereNetwork;

export const useSourceNetworks = (
provider: V1beta1Provider,
): [InventoryNetwork[], boolean, Error] => {
const providerType: ProviderType = provider?.spec?.type as ProviderType;
const {
inventory: networks,
loading,
error,
} = useProviderInventory<InventoryNetwork[]>({
provider,
subPath: providerType === 'openshift' ? '/networkattachmentdefinitions' : '/networks',
});

const typedNetworks = useMemo(
() =>
Array.isArray(networks)
? networks.map((net) => ({ ...net, providerType } as InventoryNetwork))
: [],
[networks],
);

return [typedNetworks, loading, error];
};

export const useOpenShiftNetworks = (
provider: V1beta1Provider,
): [OpenShiftNetworkAttachmentDefinition[], boolean, Error] => {
const isOpenShift = provider?.spec?.type === 'openshift';
const {
inventory: networks,
loading,
error,
} = useProviderInventory<OpenShiftNetworkAttachmentDefinition[]>({
provider,
subPath: isOpenShift ? '/networkattachmentdefinitions' : '',
});

const typedNetworks: OpenShiftNetworkAttachmentDefinition[] = useMemo(
() =>
Array.isArray(networks) ? networks.map((net) => ({ ...net, providerType: 'openshift' })) : [],
[networks],
);

return [typedNetworks, loading, error];
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useMemo } from 'react';

import { OVirtNicProfile, V1beta1Provider } from '@kubev2v/types';

import useProviderInventory from './useProviderInventory';

/**
* Works only for oVirt
*/
export const useNicProfiles = (provider: V1beta1Provider): [OVirtNicProfile[], boolean, Error] => {
const isOVirt = provider?.spec?.type === 'ovirt';
const {
inventory: nicProfiles,
loading,
error,
} = useProviderInventory<OVirtNicProfile[]>({
provider,
subPath: isOVirt ? '/nicprofiles?detail=1' : '',
});

const stable = useMemo(() => {
if (!isOVirt) {
return [];
}
return Array.isArray(nicProfiles) ? nicProfiles : [];
}, [isOVirt, nicProfiles]);

return [stable, loading, error];
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @index(['./*', /style/g], f => `export * from '${f.path}';`)
export * from './networkMapTemplate';
export * from './planTemplate';
export * from './providerTemplate';
export * from './secretTemplate';
export * from './storageMapTemplate';
// @endindex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { V1beta1NetworkMap } from '@kubev2v/types';

export const networkMapTemplate: V1beta1NetworkMap = {
apiVersion: 'forklift.konveyor.io/v1beta1',
kind: 'NetworkMap',
metadata: {
name: undefined,
namespace: undefined,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { V1beta1StorageMap } from '@kubev2v/types';

export const storageMapTemplate: V1beta1StorageMap = {
apiVersion: 'forklift.konveyor.io/v1beta1',
kind: 'StorageMap',
metadata: {
name: undefined,
namespace: undefined,
},
};
Loading

0 comments on commit 3670aa5

Please sign in to comment.