mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-01 00:02:34 +03:00
Merge pull request #2908 from markparonyan/mypy-agent-copilot-tools-nornir
fix(typing): resolve mypy errors in agent.gns3_copilot.tools_v2 (nornir + packet filter)
This commit is contained in:
commit
4337f8ccf6
@ -78,7 +78,7 @@ try:
|
|||||||
# so we use importlib to get the actual module
|
# so we use importlib to get the actual module
|
||||||
import importlib
|
import importlib
|
||||||
|
|
||||||
sd = importlib.import_module("netmiko.ssh_dispatcher")
|
sd: Any = importlib.import_module("netmiko.ssh_dispatcher")
|
||||||
|
|
||||||
# Recalculate platforms lists to include custom device types
|
# Recalculate platforms lists to include custom device types
|
||||||
sd.platforms = list(sd.CLASS_MAPPER.keys())
|
sd.platforms = list(sd.CLASS_MAPPER.keys())
|
||||||
@ -196,7 +196,7 @@ class ExecuteMultipleDeviceConfigCommands(BaseTool):
|
|||||||
|
|
||||||
# Validate input
|
# Validate input
|
||||||
device_configs_list, project_id = self._validate_tool_input(tool_input)
|
device_configs_list, project_id = self._validate_tool_input(tool_input)
|
||||||
if isinstance(device_configs_list, list) and len(device_configs_list) > 0 and "error" in device_configs_list[0]:
|
if len(device_configs_list) > 0 and "error" in device_configs_list[0]:
|
||||||
return device_configs_list
|
return device_configs_list
|
||||||
|
|
||||||
# Filter forbidden commands and store blocked commands info
|
# Filter forbidden commands and store blocked commands info
|
||||||
|
|||||||
@ -78,7 +78,7 @@ try:
|
|||||||
# so we use importlib to get the actual module
|
# so we use importlib to get the actual module
|
||||||
import importlib
|
import importlib
|
||||||
|
|
||||||
sd = importlib.import_module("netmiko.ssh_dispatcher")
|
sd: Any = importlib.import_module("netmiko.ssh_dispatcher")
|
||||||
|
|
||||||
# Recalculate platforms lists to include custom device types
|
# Recalculate platforms lists to include custom device types
|
||||||
sd.platforms = list(sd.CLASS_MAPPER.keys())
|
sd.platforms = list(sd.CLASS_MAPPER.keys())
|
||||||
@ -199,7 +199,7 @@ class ExecuteMultipleDeviceCommands(BaseTool):
|
|||||||
|
|
||||||
# Validate input
|
# Validate input
|
||||||
device_configs_list, project_id = self._validate_tool_input(tool_input)
|
device_configs_list, project_id = self._validate_tool_input(tool_input)
|
||||||
if isinstance(device_configs_list, list) and len(device_configs_list) > 0 and "error" in device_configs_list[0]:
|
if len(device_configs_list) > 0 and "error" in device_configs_list[0]:
|
||||||
return device_configs_list
|
return device_configs_list
|
||||||
|
|
||||||
# Filter forbidden commands and store blocked commands info
|
# Filter forbidden commands and store blocked commands info
|
||||||
|
|||||||
@ -286,7 +286,7 @@ class GNS3PacketFilterTool(BaseTool):
|
|||||||
|
|
||||||
# Check if output contains "Invalid" indicating syntax error
|
# Check if output contains "Invalid" indicating syntax error
|
||||||
if "Invalid" in result.stdout or "Invalid" in result.stderr:
|
if "Invalid" in result.stdout or "Invalid" in result.stderr:
|
||||||
error_lines = []
|
error_lines: list[str] = []
|
||||||
if "Invalid" in result.stderr:
|
if "Invalid" in result.stderr:
|
||||||
error_lines.extend(line for line in result.stderr.split("\n") if "Invalid" in line)
|
error_lines.extend(line for line in result.stderr.split("\n") if "Invalid" in line)
|
||||||
if "Invalid" in result.stdout:
|
if "Invalid" in result.stdout:
|
||||||
|
|||||||
@ -297,9 +297,6 @@ module = [
|
|||||||
"gns3server.agent", # 2
|
"gns3server.agent", # 2
|
||||||
"gns3server.agent.gns3_copilot.chat_sessions_repository", # 8
|
"gns3server.agent.gns3_copilot.chat_sessions_repository", # 8
|
||||||
"gns3server.agent.gns3_copilot.gns3_client.api_handlers", # 10
|
"gns3server.agent.gns3_copilot.gns3_client.api_handlers", # 10
|
||||||
"gns3server.agent.gns3_copilot.tools_v2.config_tools_nornir", # 6
|
|
||||||
"gns3server.agent.gns3_copilot.tools_v2.display_tools_nornir", # 6
|
|
||||||
"gns3server.agent.gns3_copilot.tools_v2.gns3_packet_filter", # 1
|
|
||||||
"gns3server.agent.gns3_copilot.tools_v2.gns3_start_node", # 3
|
"gns3server.agent.gns3_copilot.tools_v2.gns3_start_node", # 3
|
||||||
"gns3server.agent.gns3_copilot.tools_v2.gns3_stop_node", # 3
|
"gns3server.agent.gns3_copilot.tools_v2.gns3_stop_node", # 3
|
||||||
"gns3server.agent.gns3_copilot.tools_v2.gns3_suspend_node", # 3
|
"gns3server.agent.gns3_copilot.tools_v2.gns3_suspend_node", # 3
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user