fix(striker-ui): build fence and ups list from manifest template
This commit is contained in:
parent
c35b2d7969
commit
89c7f6b980
@ -10,29 +10,19 @@ const INPUT_GROUP_CELL_ID_PREFIX_ANVIL_HOST_CONFIG = `${INPUT_GROUP_ID_PREFIX_AN
|
|||||||
|
|
||||||
const DEFAULT_HOST_LIST: ManifestHostList = {
|
const DEFAULT_HOST_LIST: ManifestHostList = {
|
||||||
node1: {
|
node1: {
|
||||||
fences: {
|
|
||||||
fence1: { fenceName: 'ex_pdu01', fencePort: 0 },
|
|
||||||
fence2: { fenceName: 'ex_pdu02', fencePort: 0 },
|
|
||||||
},
|
|
||||||
hostNumber: 1,
|
hostNumber: 1,
|
||||||
hostType: 'node',
|
hostType: 'node',
|
||||||
upses: {
|
|
||||||
ups1: { isPowerHost: true, upsName: 'ex_ups01' },
|
|
||||||
ups2: { isPowerHost: false, upsName: 'ex_ups02' },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
node2: {
|
node2: {
|
||||||
hostNumber: 2,
|
hostNumber: 2,
|
||||||
hostType: 'node',
|
hostType: 'node',
|
||||||
},
|
},
|
||||||
dr1: {
|
|
||||||
hostNumber: 1,
|
|
||||||
hostType: 'dr',
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const AnvilHostConfigInputGroup = <M extends MapToInputTestID>({
|
const AnvilHostConfigInputGroup = <M extends MapToInputTestID>({
|
||||||
formUtils,
|
formUtils,
|
||||||
|
knownFences = {},
|
||||||
|
knownUpses = {},
|
||||||
networkListEntries,
|
networkListEntries,
|
||||||
previous: { hosts: previousHostList = DEFAULT_HOST_LIST } = {},
|
previous: { hosts: previousHostList = DEFAULT_HOST_LIST } = {},
|
||||||
}: AnvilHostConfigInputGroupProps<M>): ReactElement => {
|
}: AnvilHostConfigInputGroupProps<M>): ReactElement => {
|
||||||
@ -40,6 +30,14 @@ const AnvilHostConfigInputGroup = <M extends MapToInputTestID>({
|
|||||||
() => Object.entries(previousHostList),
|
() => Object.entries(previousHostList),
|
||||||
[previousHostList],
|
[previousHostList],
|
||||||
);
|
);
|
||||||
|
const knownFenceListValues = useMemo(
|
||||||
|
() => Object.values(knownFences),
|
||||||
|
[knownFences],
|
||||||
|
);
|
||||||
|
const knownUpsListValues = useMemo(
|
||||||
|
() => Object.values(knownUpses),
|
||||||
|
[knownUpses],
|
||||||
|
);
|
||||||
|
|
||||||
const hostNetworkList = useMemo(
|
const hostNetworkList = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@ -63,13 +61,41 @@ const AnvilHostConfigInputGroup = <M extends MapToInputTestID>({
|
|||||||
hostListEntries.reduce<GridLayout>(
|
hostListEntries.reduce<GridLayout>(
|
||||||
(previous, [hostId, previousHostArgs]) => {
|
(previous, [hostId, previousHostArgs]) => {
|
||||||
const {
|
const {
|
||||||
|
fences: previousFenceList = {},
|
||||||
hostNumber,
|
hostNumber,
|
||||||
hostType,
|
hostType,
|
||||||
networks = hostNetworkList,
|
networks = hostNetworkList,
|
||||||
|
upses: previousUpsList = {},
|
||||||
}: ManifestHost = previousHostArgs;
|
}: ManifestHost = previousHostArgs;
|
||||||
|
|
||||||
const cellId = `${INPUT_GROUP_CELL_ID_PREFIX_ANVIL_HOST_CONFIG}-${hostId}`;
|
const fences = knownFenceListValues.reduce<ManifestHostFenceList>(
|
||||||
|
(fenceList, { fenceName }) => {
|
||||||
|
const { fencePort = '' } = previousFenceList[fenceName] ?? {};
|
||||||
|
|
||||||
|
fenceList[fenceName] = {
|
||||||
|
fenceName,
|
||||||
|
fencePort,
|
||||||
|
};
|
||||||
|
|
||||||
|
return fenceList;
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
const upses = knownUpsListValues.reduce<ManifestHostUpsList>(
|
||||||
|
(upsList, { upsName }) => {
|
||||||
|
const { isUsed = true } = previousUpsList[upsName] ?? {};
|
||||||
|
|
||||||
|
upsList[upsName] = {
|
||||||
|
isUsed,
|
||||||
|
upsName,
|
||||||
|
};
|
||||||
|
|
||||||
|
return upsList;
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
|
||||||
|
const cellId = `${INPUT_GROUP_CELL_ID_PREFIX_ANVIL_HOST_CONFIG}-${hostId}`;
|
||||||
const hostLabel = `${hostType} ${hostNumber}`;
|
const hostLabel = `${hostType} ${hostNumber}`;
|
||||||
|
|
||||||
previous[cellId] = {
|
previous[cellId] = {
|
||||||
@ -77,7 +103,7 @@ const AnvilHostConfigInputGroup = <M extends MapToInputTestID>({
|
|||||||
<AnvilHostInputGroup
|
<AnvilHostInputGroup
|
||||||
formUtils={formUtils}
|
formUtils={formUtils}
|
||||||
hostLabel={hostLabel}
|
hostLabel={hostLabel}
|
||||||
previous={{ ...previousHostArgs, networks }}
|
previous={{ fences, networks, upses }}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
md: 3,
|
md: 3,
|
||||||
@ -88,7 +114,13 @@ const AnvilHostConfigInputGroup = <M extends MapToInputTestID>({
|
|||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
),
|
),
|
||||||
[formUtils, hostListEntries, hostNetworkList],
|
[
|
||||||
|
formUtils,
|
||||||
|
hostListEntries,
|
||||||
|
hostNetworkList,
|
||||||
|
knownFenceListValues,
|
||||||
|
knownUpsListValues,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user