mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-26 18:22:23 +02:00
refactor: use f-strings in dynamips NIO modules
This commit is contained in:
parent
fba3ecc5fc
commit
c458459626
@ -130,11 +130,7 @@ class NIO:
|
|||||||
raise DynamipsError(f"Unknown direction {direction} to bind filter {filter_name}:")
|
raise DynamipsError(f"Unknown direction {direction} to bind filter {filter_name}:")
|
||||||
dynamips_direction = self._dynamips_direction[direction]
|
dynamips_direction = self._dynamips_direction[direction]
|
||||||
|
|
||||||
await self._hypervisor.send(
|
await self._hypervisor.send(f"nio bind_filter {self._name} {dynamips_direction} {filter_name}")
|
||||||
"nio bind_filter {name} {direction} {filter}".format(
|
|
||||||
name=self._name, direction=dynamips_direction, filter=filter_name
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if direction == "in":
|
if direction == "in":
|
||||||
self._input_filter = filter_name
|
self._input_filter = filter_name
|
||||||
@ -155,9 +151,7 @@ class NIO:
|
|||||||
raise DynamipsError(f"Unknown direction {direction} to unbind filter:")
|
raise DynamipsError(f"Unknown direction {direction} to unbind filter:")
|
||||||
dynamips_direction = self._dynamips_direction[direction]
|
dynamips_direction = self._dynamips_direction[direction]
|
||||||
|
|
||||||
await self._hypervisor.send(
|
await self._hypervisor.send(f"nio unbind_filter {self._name} {dynamips_direction}")
|
||||||
"nio unbind_filter {name} {direction}".format(name=self._name, direction=dynamips_direction)
|
|
||||||
)
|
|
||||||
|
|
||||||
if direction == "in":
|
if direction == "in":
|
||||||
self._input_filter = None
|
self._input_filter = None
|
||||||
@ -190,11 +184,7 @@ class NIO:
|
|||||||
raise DynamipsError(f"Unknown direction {direction} to setup filter:")
|
raise DynamipsError(f"Unknown direction {direction} to setup filter:")
|
||||||
dynamips_direction = self._dynamips_direction[direction]
|
dynamips_direction = self._dynamips_direction[direction]
|
||||||
|
|
||||||
await self._hypervisor.send(
|
await self._hypervisor.send(f"nio setup_filter {self._name} {dynamips_direction} {options}")
|
||||||
"nio setup_filter {name} {direction} {options}".format(
|
|
||||||
name=self._name, direction=dynamips_direction, options=options
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if direction == "in":
|
if direction == "in":
|
||||||
self._input_filter_options = options
|
self._input_filter_options = options
|
||||||
|
|||||||
@ -43,15 +43,9 @@ class NIOGenericEthernet(NIO):
|
|||||||
|
|
||||||
async def create(self):
|
async def create(self):
|
||||||
|
|
||||||
await self._hypervisor.send(
|
await self._hypervisor.send(f"nio create_gen_eth {self._name} {self._ethernet_device}")
|
||||||
"nio create_gen_eth {name} {eth_device}".format(name=self._name, eth_device=self._ethernet_device)
|
|
||||||
)
|
|
||||||
|
|
||||||
log.info(
|
log.info(f"NIO Generic Ethernet {self._name} created with device {self._ethernet_device}")
|
||||||
"NIO Generic Ethernet {name} created with device {device}".format(
|
|
||||||
name=self._name, device=self._ethernet_device
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ethernet_device(self):
|
def ethernet_device(self):
|
||||||
|
|||||||
@ -42,15 +42,9 @@ class NIOLinuxEthernet(NIO):
|
|||||||
|
|
||||||
async def create(self):
|
async def create(self):
|
||||||
|
|
||||||
await self._hypervisor.send(
|
await self._hypervisor.send(f"nio create_linux_eth {self._name} {self._ethernet_device}")
|
||||||
"nio create_linux_eth {name} {eth_device}".format(name=self._name, eth_device=self._ethernet_device)
|
|
||||||
)
|
|
||||||
|
|
||||||
log.info(
|
log.info(f"NIO Linux Ethernet {self._name} created with device {self._ethernet_device}")
|
||||||
"NIO Linux Ethernet {name} created with device {device}".format(
|
|
||||||
name=self._name, device=self._ethernet_device
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ethernet_device(self):
|
def ethernet_device(self):
|
||||||
|
|||||||
@ -55,11 +55,7 @@ class NIOUDP(NIO):
|
|||||||
return
|
return
|
||||||
# Ubridge is not supported
|
# Ubridge is not supported
|
||||||
if not hasattr(self._node, "add_ubridge_udp_connection"):
|
if not hasattr(self._node, "add_ubridge_udp_connection"):
|
||||||
await self._hypervisor.send(
|
await self._hypervisor.send(f"nio create_udp {self._name} {self._lport} {self._rhost} {self._rport}")
|
||||||
"nio create_udp {name} {lport} {rhost} {rport}".format(
|
|
||||||
name=self._name, lport=self._lport, rhost=self._rhost, rport=self._rport
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
self._local_tunnel_lport = self._node.manager.port_manager.get_free_udp_port(self._node.project)
|
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._local_tunnel_rport = self._node.manager.port_manager.get_free_udp_port(self._node.project)
|
||||||
@ -70,11 +66,7 @@ class NIOUDP(NIO):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
log.debug(
|
log.debug(f"NIO UDP {self._name} created with lport={self._lport}, rhost={self._rhost}, rport={self._rport}")
|
||||||
"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._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 = nio_udp.NIOUDP(self._lport, self._rhost, self._rport)
|
||||||
|
|||||||
@ -45,16 +45,10 @@ class NIOUNIX(NIO):
|
|||||||
|
|
||||||
async def create(self):
|
async def create(self):
|
||||||
|
|
||||||
await self._hypervisor.send(
|
await self._hypervisor.send(f"nio create_unix {self._name} {self._local_file} {self._remote_file}")
|
||||||
"nio create_unix {name} {local} {remote}".format(
|
|
||||||
name=self._name, local=self._local_file, remote=self._remote_file
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
log.info(
|
log.info(
|
||||||
"NIO UNIX {name} created with local file {local} and remote file {remote}".format(
|
f"NIO UNIX {self._name} created with local file {self._local_file} and remote file {self._remote_file}"
|
||||||
name=self._name, local=self._local_file, remote=self._remote_file
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@ -45,17 +45,9 @@ class NIOVDE(NIO):
|
|||||||
|
|
||||||
async def create(self):
|
async def create(self):
|
||||||
|
|
||||||
await self._hypervisor.send(
|
await self._hypervisor.send(f"nio create_vde {self._name} {self._control_file} {self._local_file}")
|
||||||
"nio create_vde {name} {control} {local}".format(
|
|
||||||
name=self._name, control=self._control_file, local=self._local_file
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
log.info(
|
log.info(f"NIO VDE {self._name} created with control={self._control_file}, local={self._local_file}")
|
||||||
"NIO VDE {name} created with control={control}, local={local}".format(
|
|
||||||
name=self._name, control=self._control_file, local=self._local_file
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def control_file(self):
|
def control_file(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user