fix(mcp): учитывать контекст экземпляра при настройке маршрутизации
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 10m42s
Docker images / frontend-image (push) Successful in 2m17s
Docker images / updater-image (push) Successful in 40s
Docker images / netflow-agent-image (push) Successful in 33s
Docker images / backend-image (push) Successful in 2m36s
Docker images / publish-release (push) Successful in 12s
Docker images / notify-webhook (push) Successful in 2s
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 10m42s
Docker images / frontend-image (push) Successful in 2m17s
Docker images / updater-image (push) Successful in 40s
Docker images / netflow-agent-image (push) Successful in 33s
Docker images / backend-image (push) Successful in 2m36s
Docker images / publish-release (push) Successful in 12s
Docker images / notify-webhook (push) Successful in 2s
This commit is contained in:
1 parent
3c06a72349
commit
fc39b0da3c
5 files changed
+71
-19
No files matched your search
@@ -1,8 +1,24 @@
|
||||
import type { MikrotikClient } from "./mikrotik.js"
|
||||
import { nativeBgpRows, type NativeBgpRow } from "./bgp-export-model.js"
|
||||
import { bgpFilterName } from "./bgp-filter-binding-model.js"
|
||||
import { readOspfEffectiveDisabled } from "./ospf-effective-disabled.js"
|
||||
import { McpError } from "../modules/mcp/security.js"
|
||||
|
||||
export async function readBgpInstanceContext(client: Pick<MikrotikClient, "post">, row: NativeBgpRow) {
|
||||
const read = async (key: "vrf" | "routing-table") => {
|
||||
const value = row[key]
|
||||
return value === undefined || value === ""
|
||||
? bgpFilterName(await client.post("/routing/bgp/instance/get", { ".id": row[".id"], "value-name": key }))
|
||||
: bgpFilterName({ ret: value })
|
||||
}
|
||||
const [observedVrf, observedTable] = await Promise.all([read("vrf"), read("routing-table")])
|
||||
const vrf = observedVrf || "main"
|
||||
// Only infer the routing table when the instance uses the built-in VRF.
|
||||
const table = observedTable || (vrf === "main" ? "main" : null)
|
||||
if (!table) throw new McpError("STATE_UNAVAILABLE", "Не подтверждена таблица BGP instance", 409)
|
||||
return { vrf, table }
|
||||
}
|
||||
|
||||
/** Prove a configured peer, including RouterOS releases that omit the D flag. */
|
||||
export async function readStaticBgpConnection(client: Pick<MikrotikClient, "get" | "post">, id: string) {
|
||||
const connections = nativeBgpRows(await client.get("/routing/bgp/connection")), target = connections.find(row => row[".id"] === id)
|
||||
|
||||
Reference in new issue
Block a user