fix(striker-ui): add IPMI IP to host inputs in manage manifest

main
Tsu-ba-me 2 years ago
parent 84f708f5d1
commit 594062e823
  1. 11
      striker-ui/components/ManageManifest/AnHostConfigInputGroup.tsx
  2. 65
      striker-ui/components/ManageManifest/AnHostInputGroup.tsx
  3. 3
      striker-ui/types/ManageManifest.d.ts

@ -47,13 +47,15 @@ const AnHostConfigInputGroup = <M extends MapToInputTestID>({
fences: previousFenceList = {},
hostNumber,
hostType,
ipmiIp,
networks: previousNetworkList = {},
upses: previousUpsList = {},
}: ManifestHost = previousHostArgs;
const fences = knownFenceListValues.reduce<ManifestHostFenceList>(
(fenceList, { fenceName }) => {
const { fencePort = '' } = previousFenceList[fenceName] ?? {};
const { [fenceName]: { fencePort = '' } = {} } =
previousFenceList;
fenceList[fenceName] = { fenceName, fencePort };
@ -63,7 +65,8 @@ const AnHostConfigInputGroup = <M extends MapToInputTestID>({
);
const networks = networkListEntries.reduce<ManifestHostNetworkList>(
(networkList, [networkId, { networkNumber, networkType }]) => {
const { networkIp = '' } = previousNetworkList[networkId] ?? {};
const { [networkId]: { networkIp = '' } = {} } =
previousNetworkList;
networkList[networkId] = {
networkIp,
@ -77,7 +80,7 @@ const AnHostConfigInputGroup = <M extends MapToInputTestID>({
);
const upses = knownUpsListValues.reduce<ManifestHostUpsList>(
(upsList, { upsName }) => {
const { isUsed = true } = previousUpsList[upsName] ?? {};
const { [upsName]: { isUsed = true } = {} } = previousUpsList;
upsList[upsName] = { isUsed, upsName };
@ -95,7 +98,7 @@ const AnHostConfigInputGroup = <M extends MapToInputTestID>({
hostId={hostId}
hostNumber={hostNumber}
hostType={hostType}
previous={{ fences, networks, upses }}
previous={{ fences, ipmiIp, networks, upses }}
/>
),
md: 3,

@ -1,7 +1,5 @@
import { ReactElement, useMemo } from 'react';
import NETWORK_TYPES from '../../lib/consts/NETWORK_TYPES';
import FlexBox from '../FlexBox';
import Grid from '../Grid';
import InputWithRef from '../InputWithRef';
@ -18,6 +16,8 @@ const INPUT_ID_PREFIX_AN_HOST = 'an-host-input';
const INPUT_CELL_ID_PREFIX_AH = `${INPUT_ID_PREFIX_AN_HOST}-cell`;
const INPUT_LABEL_AH_IPMI_IP = 'IPMI IP';
const MAP_TO_AH_INPUT_HANDLER: MapToManifestFormInputHandler = {
fence: (container, input) => {
const {
@ -48,6 +48,19 @@ const MAP_TO_AH_INPUT_HANDLER: MapToManifestFormInputHandler = {
hostType,
};
},
ipmi: (container, input) => {
const {
dataset: { hostId = '' },
value: ipmiIp,
} = input;
const {
hostConfig: {
hosts: { [hostId]: host },
},
} = container;
host.ipmiIp = ipmiIp;
},
network: (container, input) => {
const {
dataset: {
@ -99,6 +112,9 @@ const GRID_SPACING = '1em';
const buildInputIdAHFencePort = (hostId: string, fenceId: string): string =>
`${INPUT_ID_PREFIX_AN_HOST}-${hostId}-${fenceId}-port`;
const buildInputIdAHIpmiIp = (hostId: string): string =>
`${INPUT_ID_PREFIX_AN_HOST}-${hostId}-ipmi-ip`;
const buildInputIdAHNetworkIp = (hostId: string, networkId: string): string =>
`${INPUT_ID_PREFIX_AN_HOST}-${hostId}-${networkId}-ip`;
@ -117,6 +133,7 @@ const AnHostInputGroup = <M extends MapToInputTestID>({
hostType,
previous: {
fences: fenceList = {},
ipmiIp: previousIpmiIp,
networks: networkList = {},
upses: upsList = {},
} = {},
@ -142,6 +159,12 @@ const AnHostInputGroup = <M extends MapToInputTestID>({
() => `${INPUT_ID_PREFIX_AN_HOST}-${hostId}`,
[hostId],
);
const inputIdAHIpmiIp = useMemo(() => buildInputIdAHIpmiIp(hostId), [hostId]);
const inputCellIdAHIpmiIp = useMemo(
() => `${INPUT_CELL_ID_PREFIX_AH}-${hostId}-ipmi-ip`,
[hostId],
);
const fenceListGridLayout = useMemo(
() =>
@ -204,7 +227,7 @@ const AnHostInputGroup = <M extends MapToInputTestID>({
const cellId = `${INPUT_CELL_ID_PREFIX_AH}-${hostId}-${networkId}-ip`;
const inputId = buildInputIdAHNetworkIp(hostId, networkId);
const inputLabel = `${NETWORK_TYPES[networkType]} ${networkNumber}`;
const inputLabel = `${networkType.toUpperCase()} ${networkNumber} IP`;
previous[cellId] = {
children: (
@ -323,6 +346,41 @@ const AnHostInputGroup = <M extends MapToInputTestID>({
columns={GRID_COLUMNS}
layout={{
...networkListGridLayout,
[inputCellIdAHIpmiIp]: {
children: (
<InputWithRef
input={
<OutlinedInputWithLabel
baseInputProps={{
'data-handler': 'ipmi',
'data-host-id': hostId,
}}
id={inputIdAHIpmiIp}
label={INPUT_LABEL_AH_IPMI_IP}
value={previousIpmiIp}
/>
}
inputTestBatch={buildIPAddressTestBatch(
`${hostId} ${INPUT_LABEL_AH_IPMI_IP}`,
() => {
setMessage(inputIdAHIpmiIp);
},
{
onFinishBatch:
buildFinishInputTestBatchFunction(inputIdAHIpmiIp),
},
(message) => {
setMessage(inputIdAHIpmiIp, { children: message });
},
)}
onFirstRender={buildInputFirstRenderFunction(
inputIdAHIpmiIp,
)}
onUnmount={buildInputUnmountFunction(inputIdAHIpmiIp)}
required
/>
),
},
...fenceListGridLayout,
}}
spacing={GRID_SPACING}
@ -338,6 +396,7 @@ export {
INPUT_ID_PREFIX_AN_HOST,
MAP_TO_AH_INPUT_HANDLER,
buildInputIdAHFencePort,
buildInputIdAHIpmiIp,
buildInputIdAHNetworkIp,
buildInputIdAHUpsPowerHost,
};

@ -51,6 +51,7 @@ type ManifestHost = {
hostName?: string;
hostNumber: number;
hostType: string;
ipmiIp?: string;
networks?: ManifestHostNetworkList;
upses?: ManifestHostUpsList;
};
@ -122,7 +123,7 @@ type AnNetworkInputGroupProps<M extends MapToInputTestID> =
type AnHostInputGroupOptionalProps = {
hostLabel?: string;
previous?: Pick<ManifestHost, 'fences' | 'networks' | 'upses'>;
previous?: Pick<ManifestHost, 'fences' | 'ipmiIp' | 'networks' | 'upses'>;
};
type AnHostInputGroupProps<M extends MapToInputTestID> =

Loading…
Cancel
Save