mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 22:41:12 +02:00
Use black with -l 120 param.
This commit is contained in:
1 parent
f928738bd5
commit
c021e21309
194 files changed
+6034
-4564
No files matched your search
@@ -23,6 +23,7 @@ import asyncio
|
||||
from ..dynamips_error import DynamipsError
|
||||
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -130,9 +131,11 @@ class NIO:
|
||||
raise DynamipsError(f"Unknown direction {direction} to bind filter {filter_name}:")
|
||||
dynamips_direction = self._dynamips_direction[direction]
|
||||
|
||||
await self._hypervisor.send("nio bind_filter {name} {direction} {filter}".format(name=self._name,
|
||||
direction=dynamips_direction,
|
||||
filter=filter_name))
|
||||
await self._hypervisor.send(
|
||||
"nio bind_filter {name} {direction} {filter}".format(
|
||||
name=self._name, direction=dynamips_direction, filter=filter_name
|
||||
)
|
||||
)
|
||||
|
||||
if direction == "in":
|
||||
self._input_filter = filter_name
|
||||
@@ -153,8 +156,9 @@ class NIO:
|
||||
raise DynamipsError(f"Unknown direction {direction} to unbind filter:")
|
||||
dynamips_direction = self._dynamips_direction[direction]
|
||||
|
||||
await self._hypervisor.send("nio unbind_filter {name} {direction}".format(name=self._name,
|
||||
direction=dynamips_direction))
|
||||
await self._hypervisor.send(
|
||||
"nio unbind_filter {name} {direction}".format(name=self._name, direction=dynamips_direction)
|
||||
)
|
||||
|
||||
if direction == "in":
|
||||
self._input_filter = None
|
||||
@@ -187,9 +191,11 @@ class NIO:
|
||||
raise DynamipsError(f"Unknown direction {direction} to setup filter:")
|
||||
dynamips_direction = self._dynamips_direction[direction]
|
||||
|
||||
await self._hypervisor.send("nio setup_filter {name} {direction} {options}".format(name=self._name,
|
||||
direction=dynamips_direction,
|
||||
options=options))
|
||||
await self._hypervisor.send(
|
||||
"nio setup_filter {name} {direction} {options}".format(
|
||||
name=self._name, direction=dynamips_direction, options=options
|
||||
)
|
||||
)
|
||||
|
||||
if direction == "in":
|
||||
self._input_filter_options = options
|
||||
|
||||
@@ -23,6 +23,7 @@ import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -38,17 +39,21 @@ class NIOGenericEthernet(NIO):
|
||||
def __init__(self, hypervisor, ethernet_device):
|
||||
|
||||
# create an unique name
|
||||
name = f'generic_ethernet-{uuid.uuid4()}'
|
||||
name = f"generic_ethernet-{uuid.uuid4()}"
|
||||
self._ethernet_device = ethernet_device
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
async def create(self):
|
||||
|
||||
await self._hypervisor.send("nio create_gen_eth {name} {eth_device}".format(name=self._name,
|
||||
eth_device=self._ethernet_device))
|
||||
await self._hypervisor.send(
|
||||
"nio create_gen_eth {name} {eth_device}".format(name=self._name, eth_device=self._ethernet_device)
|
||||
)
|
||||
|
||||
log.info("NIO Generic Ethernet {name} created with device {device}".format(name=self._name,
|
||||
device=self._ethernet_device))
|
||||
log.info(
|
||||
"NIO Generic Ethernet {name} created with device {device}".format(
|
||||
name=self._name, device=self._ethernet_device
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def ethernet_device(self):
|
||||
@@ -62,5 +67,4 @@ class NIOGenericEthernet(NIO):
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_generic_ethernet",
|
||||
"ethernet_device": self._ethernet_device}
|
||||
return {"type": "nio_generic_ethernet", "ethernet_device": self._ethernet_device}
|
||||
@@ -23,6 +23,7 @@ import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -37,17 +38,21 @@ class NIOLinuxEthernet(NIO):
|
||||
|
||||
def __init__(self, hypervisor, ethernet_device):
|
||||
# create an unique name
|
||||
name = f'linux_ethernet-{uuid.uuid4()}'
|
||||
name = f"linux_ethernet-{uuid.uuid4()}"
|
||||
self._ethernet_device = ethernet_device
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
async def create(self):
|
||||
|
||||
await self._hypervisor.send("nio create_linux_eth {name} {eth_device}".format(name=self._name,
|
||||
eth_device=self._ethernet_device))
|
||||
await self._hypervisor.send(
|
||||
"nio create_linux_eth {name} {eth_device}".format(name=self._name, eth_device=self._ethernet_device)
|
||||
)
|
||||
|
||||
log.info("NIO Linux Ethernet {name} created with device {device}".format(name=self._name,
|
||||
device=self._ethernet_device))
|
||||
log.info(
|
||||
"NIO Linux Ethernet {name} created with device {device}".format(
|
||||
name=self._name, device=self._ethernet_device
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def ethernet_device(self):
|
||||
@@ -61,5 +66,4 @@ class NIOLinuxEthernet(NIO):
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_linux_ethernet",
|
||||
"ethernet_device": self._ethernet_device}
|
||||
return {"type": "nio_linux_ethernet", "ethernet_device": self._ethernet_device}
|
||||
@@ -23,6 +23,7 @@ import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -37,7 +38,7 @@ class NIONull(NIO):
|
||||
def __init__(self, hypervisor):
|
||||
|
||||
# create an unique name
|
||||
name = f'null-{uuid.uuid4()}'
|
||||
name = f"null-{uuid.uuid4()}"
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
async def create(self):
|
||||
|
||||
@@ -23,6 +23,7 @@ import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -38,7 +39,7 @@ class NIOTAP(NIO):
|
||||
def __init__(self, hypervisor, tap_device):
|
||||
|
||||
# create an unique name
|
||||
name = f'tap-{uuid.uuid4()}'
|
||||
name = f"tap-{uuid.uuid4()}"
|
||||
self._tap_device = tap_device
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
@@ -59,5 +60,4 @@ class NIOTAP(NIO):
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_tap",
|
||||
"tap_device": self._tap_device}
|
||||
return {"type": "nio_tap", "tap_device": self._tap_device}
|
||||
@@ -26,6 +26,7 @@ from .nio import NIO
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -43,7 +44,7 @@ class NIOUDP(NIO):
|
||||
def __init__(self, node, lport, rhost, rport):
|
||||
|
||||
# create an unique name
|
||||
name = f'udp-{uuid.uuid4()}'
|
||||
name = f"udp-{uuid.uuid4()}"
|
||||
self._lport = lport
|
||||
self._rhost = rhost
|
||||
self._rport = rport
|
||||
@@ -57,48 +58,40 @@ class NIOUDP(NIO):
|
||||
return
|
||||
# Ubridge is not supported
|
||||
if not hasattr(self._node, "add_ubridge_udp_connection"):
|
||||
await self._hypervisor.send("nio create_udp {name} {lport} {rhost} {rport}".format(name=self._name,
|
||||
lport=self._lport,
|
||||
rhost=self._rhost,
|
||||
rport=self._rport))
|
||||
await self._hypervisor.send(
|
||||
"nio create_udp {name} {lport} {rhost} {rport}".format(
|
||||
name=self._name, lport=self._lport, rhost=self._rhost, rport=self._rport
|
||||
)
|
||||
)
|
||||
return
|
||||
self._local_tunnel_lport = self._node.manager.port_manager.get_free_udp_port(self._node.project)
|
||||
self._local_tunnel_rport = self._node.manager.port_manager.get_free_udp_port(self._node.project)
|
||||
self._bridge_name = f'DYNAMIPS-{self._local_tunnel_lport}-{self._local_tunnel_rport}'
|
||||
await self._hypervisor.send("nio create_udp {name} {lport} {rhost} {rport}".format(name=self._name,
|
||||
lport=self._local_tunnel_lport,
|
||||
rhost='127.0.0.1',
|
||||
rport=self._local_tunnel_rport))
|
||||
|
||||
log.info("NIO UDP {name} created with lport={lport}, rhost={rhost}, rport={rport}".format(name=self._name,
|
||||
lport=self._lport,
|
||||
rhost=self._rhost,
|
||||
rport=self._rport))
|
||||
|
||||
self._source_nio = nio_udp.NIOUDP(self._local_tunnel_rport,
|
||||
'127.0.0.1',
|
||||
self._local_tunnel_lport)
|
||||
self._destination_nio = nio_udp.NIOUDP(self._lport,
|
||||
self._rhost,
|
||||
self._rport)
|
||||
self._destination_nio.filters = self._filters
|
||||
await self._node.add_ubridge_udp_connection(
|
||||
self._bridge_name,
|
||||
self._source_nio,
|
||||
self._destination_nio
|
||||
self._bridge_name = f"DYNAMIPS-{self._local_tunnel_lport}-{self._local_tunnel_rport}"
|
||||
await self._hypervisor.send(
|
||||
"nio create_udp {name} {lport} {rhost} {rport}".format(
|
||||
name=self._name, lport=self._local_tunnel_lport, rhost="127.0.0.1", rport=self._local_tunnel_rport
|
||||
)
|
||||
)
|
||||
|
||||
log.info(
|
||||
"NIO UDP {name} created with lport={lport}, rhost={rhost}, rport={rport}".format(
|
||||
name=self._name, lport=self._lport, rhost=self._rhost, rport=self._rport
|
||||
)
|
||||
)
|
||||
|
||||
self._source_nio = nio_udp.NIOUDP(self._local_tunnel_rport, "127.0.0.1", self._local_tunnel_lport)
|
||||
self._destination_nio = nio_udp.NIOUDP(self._lport, self._rhost, self._rport)
|
||||
self._destination_nio.filters = self._filters
|
||||
await self._node.add_ubridge_udp_connection(self._bridge_name, self._source_nio, self._destination_nio)
|
||||
|
||||
async def update(self):
|
||||
self._destination_nio.filters = self._filters
|
||||
await self._node.update_ubridge_udp_connection(
|
||||
self._bridge_name,
|
||||
self._source_nio,
|
||||
self._destination_nio)
|
||||
await self._node.update_ubridge_udp_connection(self._bridge_name, self._source_nio, self._destination_nio)
|
||||
|
||||
async def close(self):
|
||||
if self._local_tunnel_lport:
|
||||
await self._node.ubridge_delete_bridge(self._bridge_name)
|
||||
self._node.manager.port_manager.release_udp_port(self._local_tunnel_lport, self ._node.project)
|
||||
self._node.manager.port_manager.release_udp_port(self._local_tunnel_lport, self._node.project)
|
||||
if self._local_tunnel_rport:
|
||||
self._node.manager.port_manager.release_udp_port(self._local_tunnel_rport, self._node.project)
|
||||
self._node.manager.port_manager.release_udp_port(self._lport, self._node.project)
|
||||
@@ -135,7 +128,4 @@ class NIOUDP(NIO):
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_udp",
|
||||
"lport": self._lport,
|
||||
"rport": self._rport,
|
||||
"rhost": self._rhost}
|
||||
return {"type": "nio_udp", "lport": self._lport, "rport": self._rport, "rhost": self._rhost}
|
||||
@@ -23,6 +23,7 @@ import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -39,20 +40,24 @@ class NIOUNIX(NIO):
|
||||
def __init__(self, hypervisor, local_file, remote_file):
|
||||
|
||||
# create an unique name
|
||||
name = f'unix-{uuid.uuid4()}'
|
||||
name = f"unix-{uuid.uuid4()}"
|
||||
self._local_file = local_file
|
||||
self._remote_file = remote_file
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
async def create(self):
|
||||
|
||||
await self._hypervisor.send("nio create_unix {name} {local} {remote}".format(name=self._name,
|
||||
local=self._local_file,
|
||||
remote=self._remote_file))
|
||||
await self._hypervisor.send(
|
||||
"nio create_unix {name} {local} {remote}".format(
|
||||
name=self._name, local=self._local_file, remote=self._remote_file
|
||||
)
|
||||
)
|
||||
|
||||
log.info("NIO UNIX {name} created with local file {local} and remote file {remote}".format(name=self._name,
|
||||
local=self._local_file,
|
||||
remote=self._remote_file))
|
||||
log.info(
|
||||
"NIO UNIX {name} created with local file {local} and remote file {remote}".format(
|
||||
name=self._name, local=self._local_file, remote=self._remote_file
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def local_file(self):
|
||||
@@ -76,6 +81,4 @@ class NIOUNIX(NIO):
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_unix",
|
||||
"local_file": self._local_file,
|
||||
"remote_file": self._remote_file}
|
||||
return {"type": "nio_unix", "local_file": self._local_file, "remote_file": self._remote_file}
|
||||
@@ -23,6 +23,7 @@ import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -39,20 +40,24 @@ class NIOVDE(NIO):
|
||||
def __init__(self, hypervisor, control_file, local_file):
|
||||
|
||||
# create an unique name
|
||||
name = f'vde-{uuid.uuid4()}'
|
||||
name = f"vde-{uuid.uuid4()}"
|
||||
self._control_file = control_file
|
||||
self._local_file = local_file
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
async def create(self):
|
||||
|
||||
await self._hypervisor.send("nio create_vde {name} {control} {local}".format(name=self._name,
|
||||
control=self._control_file,
|
||||
local=self._local_file))
|
||||
await self._hypervisor.send(
|
||||
"nio create_vde {name} {control} {local}".format(
|
||||
name=self._name, control=self._control_file, local=self._local_file
|
||||
)
|
||||
)
|
||||
|
||||
log.info("NIO VDE {name} created with control={control}, local={local}".format(name=self._name,
|
||||
control=self._control_file,
|
||||
local=self._local_file))
|
||||
log.info(
|
||||
"NIO VDE {name} created with control={control}, local={local}".format(
|
||||
name=self._name, control=self._control_file, local=self._local_file
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def control_file(self):
|
||||
@@ -76,6 +81,4 @@ class NIOVDE(NIO):
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_vde",
|
||||
"local_file": self._local_file,
|
||||
"control_file": self._control_file}
|
||||
return {"type": "nio_vde", "local_file": self._local_file, "control_file": self._control_file}
|
||||
Reference in new issue
Block a user