mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-09-30 07:40:12 +03:00
fix(typing): resolve mypy errors in api.routes.compute.frame_relay_switch_nodes
This commit is contained in:
parent
5ed85340af
commit
04ca7ffd9b
@ -18,6 +18,7 @@
|
|||||||
API routes for Frame Relay switch nodes.
|
API routes for Frame Relay 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.frame_relay_switch import FrameRelaySwitch
|
from gns3server.compute.dynamips.nodes.frame_relay_switch import FrameRelaySwitch
|
||||||
|
|
||||||
responses = {404: {"model": schemas.ErrorMessage, "description": "Could not find project or Frame Relay switch node"}}
|
responses: dict[int | str, dict[str, Any]] = {
|
||||||
|
404: {"model": schemas.ErrorMessage, "description": "Could not find project or Frame Relay switch node"}
|
||||||
|
}
|
||||||
|
|
||||||
router = APIRouter(responses=responses)
|
router = APIRouter(responses=responses)
|
||||||
|
|
||||||
@ -59,13 +62,13 @@ async def create_frame_relay_switch(
|
|||||||
|
|
||||||
# Use the Dynamips Frame Relay switch to simulate this node
|
# Use the Dynamips Frame Relay 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.pop("name"),
|
data.pop("name"),
|
||||||
str(project_id),
|
str(project_id),
|
||||||
node_data.get("node_id"),
|
data.get("node_id"),
|
||||||
node_type="frame_relay_switch",
|
node_type="frame_relay_switch",
|
||||||
mappings=node_data.get("mappings"),
|
mappings=data.get("mappings"),
|
||||||
)
|
)
|
||||||
return node.asdict()
|
return node.asdict()
|
||||||
|
|
||||||
@ -99,11 +102,11 @@ async def update_frame_relay_switch(
|
|||||||
Update an Frame Relay switch node.
|
Update an Frame Relay 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()
|
||||||
|
|
||||||
|
|||||||
@ -327,7 +327,6 @@ module = [
|
|||||||
"gns3server.api.routes.compute.docker_nodes", # 26
|
"gns3server.api.routes.compute.docker_nodes", # 26
|
||||||
"gns3server.api.routes.compute.dynamips_nodes", # 9
|
"gns3server.api.routes.compute.dynamips_nodes", # 9
|
||||||
"gns3server.api.routes.compute.ethernet_hub_nodes", # 9
|
"gns3server.api.routes.compute.ethernet_hub_nodes", # 9
|
||||||
"gns3server.api.routes.compute.frame_relay_switch_nodes", # 9
|
|
||||||
"gns3server.api.routes.compute.iou_nodes", # 15
|
"gns3server.api.routes.compute.iou_nodes", # 15
|
||||||
"gns3server.api.routes.compute.nat_nodes", # 10
|
"gns3server.api.routes.compute.nat_nodes", # 10
|
||||||
"gns3server.api.routes.compute.notifications", # 4
|
"gns3server.api.routes.compute.notifications", # 4
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user