mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-22 10:52:21 +03:00
fix(typing): resolve mypy errors in api.routes.compute.atm_switch_nodes
This commit is contained in:
parent
c154d1c41e
commit
8aa07a8c25
@ -18,6 +18,7 @@
|
|||||||
API routes for ATM switch nodes.
|
API routes for ATM switch nodes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, Body, Path, status, HTTPException
|
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 import Dynamips
|
||||||
from gns3server.compute.dynamips.nodes.atm_switch import ATMSwitch
|
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)
|
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
|
# Use the Dynamips ATM switch to simulate this node
|
||||||
dynamips_manager = Dynamips.instance()
|
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 = await dynamips_manager.create_node(
|
||||||
node_data.get("name"),
|
data.get("name"),
|
||||||
str(project_id),
|
str(project_id),
|
||||||
node_data.get("node_id"),
|
data.get("node_id"),
|
||||||
node_type="atm_switch",
|
node_type="atm_switch",
|
||||||
mappings=node_data.get("mappings"),
|
mappings=data.get("mappings"),
|
||||||
)
|
)
|
||||||
return node.asdict()
|
return node.asdict()
|
||||||
|
|
||||||
@ -97,11 +100,11 @@ async def update_atm_switch(
|
|||||||
Update an ATM switch node.
|
Update an ATM switch node.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
node_data = jsonable_encoder(node_data, exclude_unset=True)
|
data = jsonable_encoder(node_data, exclude_unset=True)
|
||||||
if "name" in node_data and node.name != node_data["name"]:
|
if "name" in data and node.name != data["name"]:
|
||||||
await node.set_name(node_data["name"])
|
await node.set_name(data["name"])
|
||||||
if "mappings" in node_data:
|
if "mappings" in data:
|
||||||
node.mappings = node_data["mappings"]
|
node.mappings = data["mappings"]
|
||||||
node.updated()
|
node.updated()
|
||||||
return node.asdict()
|
return node.asdict()
|
||||||
|
|
||||||
|
|||||||
@ -316,7 +316,6 @@ module = [
|
|||||||
"gns3server.agent.web_wireshark.manage_wireshark", # 1
|
"gns3server.agent.web_wireshark.manage_wireshark", # 1
|
||||||
"gns3server.agent.web_wireshark.manager", # 9
|
"gns3server.agent.web_wireshark.manager", # 9
|
||||||
"gns3server.agent.web_wireshark.stats", # 4
|
"gns3server.agent.web_wireshark.stats", # 4
|
||||||
"gns3server.api.routes.compute.atm_switch_nodes", # 9
|
|
||||||
"gns3server.api.routes.compute.capabilities", # 1
|
"gns3server.api.routes.compute.capabilities", # 1
|
||||||
"gns3server.api.routes.compute.cloud_nodes", # 14
|
"gns3server.api.routes.compute.cloud_nodes", # 14
|
||||||
"gns3server.api.routes.compute.compute", # 1
|
"gns3server.api.routes.compute.compute", # 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user