refactor: use f-strings in dynamips NIO modules

This commit is contained in:
Mark Paronyan committed 2026-10-03 19:44:01 +03:00
1 parent fba3ecc5fc
commit c458459626
6 files changed
+13 -57

No files matched your search

+3 -13
View File
@@ -130,11 +130,7 @@ 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(f"nio bind_filter {self._name} {dynamips_direction} {filter_name}")
if direction == "in":
self._input_filter = filter_name
@@ -155,9 +151,7 @@ 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(f"nio unbind_filter {self._name} {dynamips_direction}")
if direction == "in":
self._input_filter = None
@@ -190,11 +184,7 @@ 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(f"nio setup_filter {self._name} {dynamips_direction} {options}")
if direction == "in":
self._input_filter_options = options
@@ -43,15 +43,9 @@ class NIOGenericEthernet(NIO):
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(f"nio create_gen_eth {self._name} {self._ethernet_device}")
log.info(
"NIO Generic Ethernet {name} created with device {device}".format(
name=self._name, device=self._ethernet_device
)
)
log.info(f"NIO Generic Ethernet {self._name} created with device {self._ethernet_device}")
@property
def ethernet_device(self):
@@ -42,15 +42,9 @@ class NIOLinuxEthernet(NIO):
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(f"nio create_linux_eth {self._name} {self._ethernet_device}")
log.info(
"NIO Linux Ethernet {name} created with device {device}".format(
name=self._name, device=self._ethernet_device
)
)
log.info(f"NIO Linux Ethernet {self._name} created with device {self._ethernet_device}")
@property
def ethernet_device(self):
+2 -10
View File
@@ -55,11 +55,7 @@ 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(f"nio create_udp {self._name} {self._lport} {self._rhost} {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)
@@ -70,11 +66,7 @@ class NIOUDP(NIO):
)
)
log.debug(
"NIO UDP {name} created with lport={lport}, rhost={rhost}, rport={rport}".format(
name=self._name, lport=self._lport, rhost=self._rhost, rport=self._rport
)
)
log.debug(f"NIO UDP {self._name} created with 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)
+2 -8
View File
@@ -45,16 +45,10 @@ class NIOUNIX(NIO):
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(f"nio create_unix {self._name} {self._local_file} {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
)
f"NIO UNIX {self._name} created with local file {self._local_file} and remote file {self._remote_file}"
)
@property
+2 -10
View File
@@ -45,17 +45,9 @@ class NIOVDE(NIO):
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(f"nio create_vde {self._name} {self._control_file} {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(f"NIO VDE {self._name} created with control={self._control_file}, local={self._local_file}")
@property
def control_file(self):