lab_verify
Validates eNSP lab configurations by running device commands and applying rule-based checks to deliver PASS/FAIL verdicts.
Instructions
按规则验证实验是否真的做对了,给出 PASS / FAIL 判定。
检查项 = 某台设备上跑一条命令 + 对回显的判定规则。两种给法:
suite:内置套件名,见下。
checks:自定义检查项列表,每项: {"name": "VRRP 主备", "target": "FW1", "command": "display vrrp", "expect": {"minCount": {"pattern": "State\s*:\s*(Master|Backup)", "atLeast": 1}}}
target 可以是设备名、设备类别(AR / LSW / FW / WLAN / CLIENT)或 all, 用类别时会自动展开到这类所有设备。
expect 可组合的规则:contains / notContains(字符串或列表)、regex、 notRegex、minCount{"pattern","atLeast"}、reachable(布尔,ping 是否通)、 maxLoss(丢包率上限)。留空表示“命令跑通就算过”。
内置套件:
reachable:逐台登录,只验证 console 可连(最简单的连通性体检)
fw_ha:防火墙双机热备(HRP 角色 + 心跳口 + VRRP 主备)
bfd:BFD 会话 Up
ospf:OSPF 邻居 Full
vrrp:VRRP 主备
vlan:交换机上存在业务 VLAN
devices 可限定范围。检查项并发执行,concurrency 默认 4、最大 16。 返回 verdict(PASS / FAIL)、passed / failed / skipped 计数和每条检查的 状态、未满足的条件、回显片段。save_report 可把结果另存为 JSON。
验收跑过的命令同样自动留痕,tool 记为 lab_verify。
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"topo_path": "<topo_path>"
},
"name": "lab_verify"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | No | 127.0.0.1 | |
| suite | No | ||
| checks | No | ||
| devices | No | ||
| password | No | ||
| username | No | ||
| topo_path | Yes | ||
| concurrency | No | ||
| save_report | No | ||
| new_password | No | ||
| include_output | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |