mirror of
https://github.com/hansjone/netx.git
synced 2026-10-13 09:40:48 +08:00
Add concurrent multi-NE CLI exec batch for field sweeps.
execManagedNe can take ne_ids/ume_ne_ids/targets and POST /v1/managed-ne/exec-batch so many show commands run in parallel instead of serial one-NE MCP loops. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
8a07baa018
commit
9ba4d051dc
8 changed files with 355 additions and 14 deletions
|
|
@ -156,6 +156,41 @@ def test_call_exec_managed_ne_posts_body() -> None:
|
|||
assert payload["ok"] is True
|
||||
|
||||
|
||||
def test_call_exec_managed_ne_batch_ne_ids() -> None:
|
||||
with patch("netx_mcp.http_tools.http_post_json") as mock_post:
|
||||
mock_post.return_value = {
|
||||
"ok": True,
|
||||
"data": {
|
||||
"ok": True,
|
||||
"summary": {"total": 2, "ok": 2, "failed": 0},
|
||||
"results": [{"ok": True}, {"ok": True}],
|
||||
},
|
||||
}
|
||||
out = call_http_tool(
|
||||
"execManagedNe",
|
||||
{"ne_ids": ["a", "b"], "commands": ["show version"], "concurrency": 2},
|
||||
)
|
||||
mock_post.assert_called_once()
|
||||
assert mock_post.call_args[0][0] == "/v1/managed-ne/exec-batch"
|
||||
body = mock_post.call_args[0][1]
|
||||
assert body["ne_ids"] == ["a", "b"]
|
||||
assert body["commands"] == ["show version"]
|
||||
assert body["concurrency"] == 2
|
||||
payload = json.loads(out["content"][0]["text"])
|
||||
assert payload["ok"] is True
|
||||
assert payload["data"]["summary"]["total"] == 2
|
||||
|
||||
|
||||
def test_exec_managed_ne_schema_documents_batch() -> None:
|
||||
tool = next(t for t in HTTP_MCP_TOOLS if t.get("name") == "execManagedNe")
|
||||
props = tool["inputSchema"]["properties"]
|
||||
assert "ne_ids" in props
|
||||
assert "ume_ne_ids" in props
|
||||
assert "targets" in props
|
||||
assert "concurrency" in props
|
||||
assert "Many NEs" in tool["description"] or "ne_ids" in tool["description"]
|
||||
|
||||
|
||||
def test_call_exec_managed_ne_respects_max_commands_env(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setenv("NETX_NE_EXEC_MAX_COMMANDS", "10")
|
||||
cmds = [f"show version {i}" for i in range(6)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue