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.vpcs_nodes
This commit is contained in:
parent
e0c4cb8122
commit
a86cae541e
@ -23,7 +23,7 @@ import os
|
||||
from fastapi import APIRouter, WebSocket, Depends, Body, Path, status, HTTPException
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
from fastapi.responses import StreamingResponse
|
||||
from typing import Union
|
||||
from typing import Any, Union
|
||||
from uuid import UUID
|
||||
|
||||
from gns3server import schemas
|
||||
@ -31,7 +31,9 @@ from gns3server.compute.vpcs import VPCS
|
||||
from gns3server.compute.vpcs.vpcs_vm import VPCSVM
|
||||
from .dependencies.authentication import compute_authentication, ws_compute_authentication
|
||||
|
||||
responses = {404: {"model": schemas.ErrorMessage, "description": "Could not find project or VMware node"}}
|
||||
responses: dict[int | str, dict[str, Any]] = {
|
||||
404: {"model": schemas.ErrorMessage, "description": "Could not find project or VMware node"}
|
||||
}
|
||||
|
||||
router = APIRouter(responses=responses)
|
||||
|
||||
@ -59,14 +61,14 @@ async def create_vpcs_node(project_id: UUID, node_data: schemas.VPCSCreate) -> s
|
||||
"""
|
||||
|
||||
vpcs = VPCS.instance()
|
||||
node_data = jsonable_encoder(node_data, exclude_unset=True)
|
||||
data = jsonable_encoder(node_data, exclude_unset=True)
|
||||
vm = await vpcs.create_node(
|
||||
node_data["name"],
|
||||
data["name"],
|
||||
str(project_id),
|
||||
node_data.get("node_id"),
|
||||
console=node_data.get("console"),
|
||||
console_type=node_data.get("console_type", "telnet"),
|
||||
startup_script=node_data.get("startup_script"),
|
||||
data.get("node_id"),
|
||||
console=data.get("console"),
|
||||
console_type=data.get("console_type", "telnet"),
|
||||
startup_script=data.get("startup_script"),
|
||||
)
|
||||
|
||||
return vm.asdict()
|
||||
@ -87,14 +89,14 @@ async def update_vpcs_node(node_data: schemas.VPCSUpdate, node: VPCSVM = Depends
|
||||
Update a VPCS node.
|
||||
"""
|
||||
|
||||
node_data = jsonable_encoder(node_data, exclude_unset=True)
|
||||
name = node_data.get("name", node.name)
|
||||
data = jsonable_encoder(node_data, exclude_unset=True)
|
||||
name = data.get("name", node.name)
|
||||
if node.name != name:
|
||||
node.name = name
|
||||
console = node_data.get("console", node.console)
|
||||
console = data.get("console", node.console)
|
||||
if node.console != console:
|
||||
node.console = console
|
||||
console_type = node_data.get("console_type", node.console_type)
|
||||
console_type = data.get("console_type", node.console_type)
|
||||
if node.console_type != console_type:
|
||||
node.console_type = console_type
|
||||
node.updated()
|
||||
|
||||
@ -334,7 +334,6 @@ module = [
|
||||
"gns3server.api.routes.compute.notifications", # 4
|
||||
"gns3server.api.routes.compute.projects", # 7
|
||||
"gns3server.api.routes.compute.virtualbox_nodes", # 20
|
||||
"gns3server.api.routes.compute.vpcs_nodes", # 9
|
||||
"gns3server.api.routes.controller.acl", # 5
|
||||
"gns3server.api.routes.controller.api_keys", # 1
|
||||
"gns3server.api.routes.controller.chat", # 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user