diff --git a/gns3server/api/routes/compute/atm_switch_nodes.py b/gns3server/api/routes/compute/atm_switch_nodes.py index 65bc1157d..1282a162d 100644 --- a/gns3server/api/routes/compute/atm_switch_nodes.py +++ b/gns3server/api/routes/compute/atm_switch_nodes.py @@ -18,6 +18,7 @@ API routes for ATM switch nodes. """ +from typing import Any import os from fastapi import APIRouter, Depends, Body, Path, status, HTTPException @@ -29,7 +30,9 @@ from gns3server import schemas from gns3server.compute.dynamips import Dynamips from gns3server.compute.dynamips.nodes.atm_switch import ATMSwitch -responses = {404: {"model": schemas.ErrorMessage, "description": "Could not find project or ATM switch node"}} +responses: dict[int | str, dict[str, Any]] = { + 404: {"model": schemas.ErrorMessage, "description": "Could not find project or ATM switch node"} +} router = APIRouter(responses=responses) @@ -57,13 +60,13 @@ async def create_atm_switch(project_id: UUID, node_data: schemas.ATMSwitchCreate # Use the Dynamips ATM switch to simulate this node dynamips_manager = Dynamips.instance() - node_data = jsonable_encoder(node_data, exclude_unset=True) + data = jsonable_encoder(node_data, exclude_unset=True) node = await dynamips_manager.create_node( - node_data.get("name"), + data.get("name"), str(project_id), - node_data.get("node_id"), + data.get("node_id"), node_type="atm_switch", - mappings=node_data.get("mappings"), + mappings=data.get("mappings"), ) return node.asdict() @@ -97,11 +100,11 @@ async def update_atm_switch( Update an ATM switch node. """ - node_data = jsonable_encoder(node_data, exclude_unset=True) - if "name" in node_data and node.name != node_data["name"]: - await node.set_name(node_data["name"]) - if "mappings" in node_data: - node.mappings = node_data["mappings"] + data = jsonable_encoder(node_data, exclude_unset=True) + if "name" in data and node.name != data["name"]: + await node.set_name(data["name"]) + if "mappings" in data: + node.mappings = data["mappings"] node.updated() return node.asdict() diff --git a/pyproject.toml b/pyproject.toml index a9da73a8b..6f7bba3ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -316,7 +316,6 @@ module = [ "gns3server.agent.web_wireshark.manage_wireshark", # 1 "gns3server.agent.web_wireshark.manager", # 9 "gns3server.agent.web_wireshark.stats", # 4 - "gns3server.api.routes.compute.atm_switch_nodes", # 9 "gns3server.api.routes.compute.capabilities", # 1 "gns3server.api.routes.compute.cloud_nodes", # 14 "gns3server.api.routes.compute.compute", # 1