diff --git a/striker-ui/components/ManageManifest/AnHostConfigInputGroup.tsx b/striker-ui/components/ManageManifest/AnHostConfigInputGroup.tsx index 46e35075..6f27710c 100644 --- a/striker-ui/components/ManageManifest/AnHostConfigInputGroup.tsx +++ b/striker-ui/components/ManageManifest/AnHostConfigInputGroup.tsx @@ -47,13 +47,15 @@ const AnHostConfigInputGroup = ({ fences: previousFenceList = {}, hostNumber, hostType, + ipmiIp, networks: previousNetworkList = {}, upses: previousUpsList = {}, }: ManifestHost = previousHostArgs; const fences = knownFenceListValues.reduce( (fenceList, { fenceName }) => { - const { fencePort = '' } = previousFenceList[fenceName] ?? {}; + const { [fenceName]: { fencePort = '' } = {} } = + previousFenceList; fenceList[fenceName] = { fenceName, fencePort }; @@ -63,7 +65,8 @@ const AnHostConfigInputGroup = ({ ); const networks = networkListEntries.reduce( (networkList, [networkId, { networkNumber, networkType }]) => { - const { networkIp = '' } = previousNetworkList[networkId] ?? {}; + const { [networkId]: { networkIp = '' } = {} } = + previousNetworkList; networkList[networkId] = { networkIp, @@ -77,7 +80,7 @@ const AnHostConfigInputGroup = ({ ); const upses = knownUpsListValues.reduce( (upsList, { upsName }) => { - const { isUsed = true } = previousUpsList[upsName] ?? {}; + const { [upsName]: { isUsed = true } = {} } = previousUpsList; upsList[upsName] = { isUsed, upsName }; @@ -95,7 +98,7 @@ const AnHostConfigInputGroup = ({ hostId={hostId} hostNumber={hostNumber} hostType={hostType} - previous={{ fences, networks, upses }} + previous={{ fences, ipmiIp, networks, upses }} /> ), md: 3, diff --git a/striker-ui/components/ManageManifest/AnHostInputGroup.tsx b/striker-ui/components/ManageManifest/AnHostInputGroup.tsx index a1ee9aff..e0153b35 100644 --- a/striker-ui/components/ManageManifest/AnHostInputGroup.tsx +++ b/striker-ui/components/ManageManifest/AnHostInputGroup.tsx @@ -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 = ({ hostType, previous: { fences: fenceList = {}, + ipmiIp: previousIpmiIp, networks: networkList = {}, upses: upsList = {}, } = {}, @@ -142,6 +159,12 @@ const AnHostInputGroup = ({ () => `${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 = ({ 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 = ({ columns={GRID_COLUMNS} layout={{ ...networkListGridLayout, + [inputCellIdAHIpmiIp]: { + children: ( + + } + 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, }; diff --git a/striker-ui/types/ManageManifest.d.ts b/striker-ui/types/ManageManifest.d.ts index 30e03cc6..bc2aa6c3 100644 --- a/striker-ui/types/ManageManifest.d.ts +++ b/striker-ui/types/ManageManifest.d.ts @@ -51,6 +51,7 @@ type ManifestHost = { hostName?: string; hostNumber: number; hostType: string; + ipmiIp?: string; networks?: ManifestHostNetworkList; upses?: ManifestHostUpsList; }; @@ -122,7 +123,7 @@ type AnNetworkInputGroupProps = type AnHostInputGroupOptionalProps = { hostLabel?: string; - previous?: Pick; + previous?: Pick; }; type AnHostInputGroupProps =