Skip to content

Commit

Permalink
FR-317 mpls topology version (#464)
Browse files Browse the repository at this point in the history
* mpls topology version query added

* handle missing interfaces
  • Loading branch information
soson authored Aug 21, 2024
1 parent e5b14ea commit 6a1b0a6
Show file tree
Hide file tree
Showing 7 changed files with 442 additions and 7 deletions.
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

0 comments on commit 6a1b0a6

Please sign in to comment.