Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR-317 mpls topology version #464

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions src/__generated__/topology-discovery.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/external-api/topology-discovery-graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ const MPLS_TOPOLOGY = gql`
}
}
details {
router_id
mpls_data {
lsp_id
in_label
Expand Down
53 changes: 51 additions & 2 deletions src/external-api/topology-network-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const Interface = t.type({
});
const PtpInterface = t.intersection([Interface, t.type({ details: PtpInterfaceDetails })]);
const SynceInterface = t.intersection([Interface, t.type({ details: SynceInterfaceDetails })]);
const MplsInterface = t.intersection([Interface, t.type({})]);
const NetInterface = t.type({
_id: t.string,
_key: t.string,
Expand Down Expand Up @@ -81,6 +82,13 @@ const SynceInterfaceWithStatusValidator = t.intersection([
}),
]);

const MplsInterfaceWithStatusValidator = t.intersection([
MplsInterface,
t.type({
status: StatusValidator,
}),
]);

const CoordinatesValidator = t.type({
x: t.number,
y: t.number,
Expand Down Expand Up @@ -126,6 +134,17 @@ const SynceDeviceValidator = t.intersection([
}),
]);

const MplsDeviceValidator = t.intersection([
InterfaceWithStatusValidator,
t.type({
labels: t.array(t.string),
details: t.type({
// selected_for_use: t.string,
}),
coordinates: CoordinatesValidator,
}),
]);

const NetworkValidator = t.type({
_id: t.string,
_key: t.string,
Expand Down Expand Up @@ -195,6 +214,11 @@ const ChangedSynceDevice = t.type({
old: SynceDeviceValidator,
});

const ChangedMplsDevice = t.type({
new: MplsDeviceValidator,
old: MplsDeviceValidator,
});

const ChangedNetDevice = t.type({
new: NetDeviceValidator,
old: NetDeviceValidator,
Expand All @@ -221,6 +245,10 @@ const ChangedSynceInterface = t.type({
new: SynceInterfaceWithStatusValidator,
old: SynceInterfaceWithStatusValidator,
});
const ChangedMplsInterface = t.type({
new: MplsInterfaceWithStatusValidator,
old: MplsInterfaceWithStatusValidator,
});
const ChangedNetInterface = t.type({
new: NetInterfaceValidator,
old: NetInterfaceValidator,
Expand Down Expand Up @@ -276,6 +304,20 @@ const ChangeNetDiff = t.type({
NetNetwork: t.array(ChangedNetNetwork),
});

const MplsDiff = t.type({
MplsDevice: t.array(MplsDeviceValidator),
MplsHas: t.array(EdgeWithStatusValidator),
MplsInterface: t.array(MplsInterfaceWithStatusValidator),
MplsLink: t.array(Edge),
});

const ChangeMplsDiff = t.type({
MplsDevice: t.array(ChangedMplsDevice),
MplsHas: t.array(ChangedEdgeWithStatusValidator),
MplsInterface: t.array(ChangedMplsInterface),
MplsLink: t.array(ChangedEdge),
});

const NetDiff = t.type({
NetDevice: t.array(NetDeviceValidator),
NetHas: t.array(Edge),
Expand All @@ -284,8 +326,8 @@ const NetDiff = t.type({
NetNetwork: t.array(NetworkValidator),
});

const TopologyDiff = t.union([PhyDiff, PtpDiff, SynceDiff, NetDiff]);
const ChangeTopologyDiff = t.union([ChangePhyDiff, ChangePtpDiff, ChangeSynceDiff, ChangeNetDiff]);
const TopologyDiff = t.union([PhyDiff, PtpDiff, SynceDiff, NetDiff, MplsDiff]);
const ChangeTopologyDiff = t.union([ChangePhyDiff, ChangePtpDiff, ChangeSynceDiff, ChangeNetDiff, ChangeMplsDiff]);

export type PhyTopologyDiffType = {
added: t.TypeOf<typeof PhyDiff>;
Expand All @@ -305,6 +347,12 @@ export type SynceTopologyDiffType = {
deleted: t.TypeOf<typeof SynceDiff>;
};

export type MplsTopologyDiffType = {
added: t.TypeOf<typeof MplsDiff>;
changed: t.TypeOf<typeof ChangeMplsDiff>;
deleted: t.TypeOf<typeof MplsDiff>;
};

export type NetTopologyDiffType = {
added: t.TypeOf<typeof NetDiff>;
changed: t.TypeOf<typeof ChangeNetDiff>;
Expand Down Expand Up @@ -348,6 +396,7 @@ export function decodeLinksAndDevicesOutput(value: unknown): LinksAndDevicesOutp
export type InterfaceWithStatus = t.TypeOf<typeof InterfaceWithStatusValidator>;
export type PtpInterfaceWithStatus = t.TypeOf<typeof PtpInterfaceWithStatusValidator>;
export type SynceInterfaceWithStatus = t.TypeOf<typeof SynceInterfaceWithStatusValidator>;
export type MplsInterfaceWithStatus = t.TypeOf<typeof MplsInterfaceWithStatusValidator>;

const HasAndInterfacesOutputValidator = t.type({
has: t.array(EdgeWithStatusValidator),
Expand Down
Loading