Skip to content

Commit

Permalink
Add correct info in nmstate when user choose dual-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
ammont82 committed Jun 25, 2024
1 parent 322630e commit 96cc742
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,34 @@ import {
HostStaticNetworkConfig,
MacInterfaceMap,
} from '@openshift-assisted/types/assisted-installer-service';
import { ProtocolVersion, StaticIpInfo, StaticIpView } from './dataTypes';
import {
FormViewNetworkWideValues,
ProtocolVersion,
StaticIpInfo,
StaticIpView,
} from './dataTypes';
import { NmstateEthernetInterface, NmstateInterfaceType } from './nmstateTypes';
import { FORM_VIEW_PREFIX, getNmstateProtocolConfig, toYamlWithComments } from './nmstateYaml';
import { k8sCreate } from '@openshift-console/dynamic-plugin-sdk';
import { getShownProtocolVersions } from './protocolVersion';

const DUMMY_MAC = '01:23:45:67:89:AB';
const DUMMY_MAC_4 = '01:23:45:67:89:AB';
const DUMMY_MAC_6 = '01:23:45:67:89:AC';
const DUMMY_NIC_PREFIX = 'DUMMY';

export const getDummyNicName = (protocolVersion: ProtocolVersion) => {
const protocolNumber = protocolVersion === ProtocolVersion.ipv4 ? 4 : 6;
return `${DUMMY_NIC_PREFIX}${protocolNumber}`;
};

export const getDummyMacAddress = (protocolVersion: ProtocolVersion) => {
if (protocolVersion === ProtocolVersion.ipv4) {
return DUMMY_MAC_4;
} else {
return DUMMY_MAC_6;
}
};

export const DUMMY_NMSTATE_ADDRESSES = {
ipv4: {
prefixLength: 24,
Expand All @@ -39,8 +55,21 @@ export const getDummyInterfaces = (): NmstateEthernetInterface[] => {
];
};

export const getDummyMacInterfaceMap = (): MacInterfaceMap => {
return [{ macAddress: DUMMY_MAC, logicalNicName: getDummyNicName(ProtocolVersion.ipv4) }];
export const getDummyMacInterfaceMap = (
networkWideConfiguration?: FormViewNetworkWideValues,
): MacInterfaceMap => {
const macInterfaceMap = [];
if (networkWideConfiguration) {
for (const protocolVersion of getShownProtocolVersions(networkWideConfiguration.protocolType)) {
macInterfaceMap.push({
macAddress: getDummyMacAddress(protocolVersion),
logicalNicName: getDummyNicName(protocolVersion),
});
}
return macInterfaceMap;
} else {
return [{ macAddress: DUMMY_MAC_4, logicalNicName: getDummyNicName(ProtocolVersion.ipv4) }];
}
};

export const isDummyInterface = (nicName: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const formDataToInfraEnvField = (formData: StaticFormData): HostStaticNetworkCon
ret = [
{
networkYaml: toYaml(formData.networkWide),
macInterfaceMap: getDummyMacInterfaceMap(),
macInterfaceMap: getDummyMacInterfaceMap(formData.networkWide),
},
];
} else {
Expand Down

0 comments on commit 96cc742

Please sign in to comment.