mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-06-18 15:28:11 +00:00
Migration to FastAPI
This commit is contained in:
@ -19,7 +19,8 @@ import os
|
||||
import re
|
||||
import uuid
|
||||
import html
|
||||
import aiohttp
|
||||
|
||||
from .controller_error import ControllerError, ControllerNotFoundError
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
@ -225,26 +226,26 @@ class Link:
|
||||
|
||||
port = node.get_port(adapter_number, port_number)
|
||||
if port is None:
|
||||
raise aiohttp.web.HTTPNotFound(text="Port {}/{} for {} not found".format(adapter_number, port_number, node.name))
|
||||
raise ControllerNotFoundError("Port {}/{} for {} not found".format(adapter_number, port_number, node.name))
|
||||
if port.link is not None:
|
||||
raise aiohttp.web.HTTPConflict(text="Port is already used")
|
||||
raise ControllerError("Port is already used")
|
||||
|
||||
self._link_type = port.link_type
|
||||
|
||||
for other_node in self._nodes:
|
||||
if other_node["node"] == node:
|
||||
raise aiohttp.web.HTTPConflict(text="Cannot connect to itself")
|
||||
raise ControllerError("Cannot connect to itself")
|
||||
|
||||
if node.node_type in ["nat", "cloud"]:
|
||||
if other_node["node"].node_type in ["nat", "cloud"]:
|
||||
raise aiohttp.web.HTTPConflict(text="Connecting a {} to a {} is not allowed".format(other_node["node"].node_type, node.node_type))
|
||||
raise ControllerError("Connecting a {} to a {} is not allowed".format(other_node["node"].node_type, node.node_type))
|
||||
|
||||
# Check if user is not connecting serial => ethernet
|
||||
other_port = other_node["node"].get_port(other_node["adapter_number"], other_node["port_number"])
|
||||
if other_port is None:
|
||||
raise aiohttp.web.HTTPNotFound(text="Port {}/{} for {} not found".format(other_node["adapter_number"], other_node["port_number"], other_node["node"].name))
|
||||
raise ControllerNotFoundError("Port {}/{} for {} not found".format(other_node["adapter_number"], other_node["port_number"], other_node["node"].name))
|
||||
if port.link_type != other_port.link_type:
|
||||
raise aiohttp.web.HTTPConflict(text="Connecting a {} interface to a {} interface is not allowed".format(other_port.link_type, port.link_type))
|
||||
raise ControllerError("Connecting a {} interface to a {} interface is not allowed".format(other_port.link_type, port.link_type))
|
||||
|
||||
if label is None:
|
||||
label = {
|
||||
|
Reference in New Issue
Block a user