refactor: use f-strings in dynamips nodes

This commit is contained in:
Mark Paronyan committed 2026-10-03 19:44:00 +03:00
1 parent a5d2bca921
commit fba3ecc5fc
12 files changed
+58 -296

No files matched your search

@@ -81,11 +81,7 @@ class FrameRelaySwitch(Device):
"""
await self._hypervisor.send(f'frsw rename "{self._name}" "{new_name}"')
log.info(
'Frame Relay switch "{name}" [{id}]: renamed to "{new_name}"'.format(
name=self._name, id=self._id, new_name=new_name
)
)
log.info(f'Frame Relay switch "{self._name}" [{self._id}]: renamed to "{new_name}"')
self._name = new_name
@property
@@ -165,11 +161,7 @@ class FrameRelaySwitch(Device):
if port_number in self._nios:
raise DynamipsError(f"Port {port_number} isn't free")
log.info(
'Frame Relay switch "{name}" [{id}]: NIO {nio} bound to port {port}'.format(
name=self._name, id=self._id, nio=nio, port=port_number
)
)
log.info(f'Frame Relay switch "{self._name}" [{self._id}]: NIO {nio} bound to port {port_number}')
self._nios[port_number] = nio
await self.set_mappings(self._mappings)
@@ -193,14 +185,7 @@ class FrameRelaySwitch(Device):
destination_port, destination_dlci = destination
if port_number == source_port:
log.info(
'Frame Relay switch "{name}" [{id}]: unmapping VC between port {source_port} DLCI {source_dlci} and port {destination_port} DLCI {destination_dlci}'.format(
name=self._name,
id=self._id,
source_port=source_port,
source_dlci=source_dlci,
destination_port=destination_port,
destination_dlci=destination_dlci,
)
f'Frame Relay switch "{self._name}" [{self._id}]: unmapping VC between port {source_port} DLCI {source_dlci} and port {destination_port} DLCI {destination_dlci}'
)
await self.unmap_vc(source_port, source_dlci, destination_port, destination_dlci)
await self.unmap_vc(destination_port, destination_dlci, source_port, source_dlci)
@@ -209,11 +194,7 @@ class FrameRelaySwitch(Device):
if isinstance(nio, NIOUDP):
self.manager.port_manager.release_udp_port(nio.lport, self._project)
log.info(
'Frame Relay switch "{name}" [{id}]: NIO {nio} removed from port {port}'.format(
name=self._name, id=self._id, nio=nio, port=port_number
)
)
log.info(f'Frame Relay switch "{self._name}" [{self._id}]: NIO {nio} removed from port {port_number}')
del self._nios[port_number]
return nio
@@ -255,14 +236,7 @@ class FrameRelaySwitch(Device):
destination_dlci,
) not in self._active_mappings:
log.info(
'Frame Relay switch "{name}" [{id}]: mapping VC between port {source_port} DLCI {source_dlci} and port {destination_port} DLCI {destination_dlci}'.format(
name=self._name,
id=self._id,
source_port=source_port,
source_dlci=source_dlci,
destination_port=destination_port,
destination_dlci=destination_dlci,
)
f'Frame Relay switch "{self._name}" [{self._id}]: mapping VC between port {source_port} DLCI {source_dlci} and port {destination_port} DLCI {destination_dlci}'
)
await self.map_vc(source_port, source_dlci, destination_port, destination_dlci)
@@ -287,16 +261,10 @@ class FrameRelaySwitch(Device):
nio1 = self._nios[port1]
nio2 = self._nios[port2]
await self._hypervisor.send(
'frsw create_vc "{name}" {input_nio} {input_dlci} {output_nio} {output_dlci}'.format(
name=self._name, input_nio=nio1, input_dlci=dlci1, output_nio=nio2, output_dlci=dlci2
)
)
await self._hypervisor.send(f'frsw create_vc "{self._name}" {nio1} {dlci1} {nio2} {dlci2}')
log.info(
'Frame Relay switch "{name}" [{id}]: VC from port {port1} DLCI {dlci1} to port {port2} DLCI {dlci2} created'.format(
name=self._name, id=self._id, port1=port1, dlci1=dlci1, port2=port2, dlci2=dlci2
)
f'Frame Relay switch "{self._name}" [{self._id}]: VC from port {port1} DLCI {dlci1} to port {port2} DLCI {dlci2} created'
)
self._active_mappings[(port1, dlci1)] = (port2, dlci2)
@@ -320,16 +288,10 @@ class FrameRelaySwitch(Device):
nio1 = self._nios[port1]
nio2 = self._nios[port2]
await self._hypervisor.send(
'frsw delete_vc "{name}" {input_nio} {input_dlci} {output_nio} {output_dlci}'.format(
name=self._name, input_nio=nio1, input_dlci=dlci1, output_nio=nio2, output_dlci=dlci2
)
)
await self._hypervisor.send(f'frsw delete_vc "{self._name}" {nio1} {dlci1} {nio2} {dlci2}')
log.info(
'Frame Relay switch "{name}" [{id}]: VC from port {port1} DLCI {dlci1} to port {port2} DLCI {dlci2} deleted'.format(
name=self._name, id=self._id, port1=port1, dlci1=dlci1, port2=port2, dlci2=dlci2
)
f'Frame Relay switch "{self._name}" [{self._id}]: VC from port {port1} DLCI {dlci1} to port {port2} DLCI {dlci2} deleted'
)
del self._active_mappings[(port1, dlci1)]
@@ -352,11 +314,7 @@ class FrameRelaySwitch(Device):
raise DynamipsError(f"Port {port_number} has already a filter applied")
await nio.start_packet_capture(output_file, data_link_type)
log.info(
'Frame relay switch "{name}" [{id}]: starting packet capture on port {port}'.format(
name=self._name, id=self._id, port=port_number
)
)
log.info(f'Frame relay switch "{self._name}" [{self._id}]: starting packet capture on port {port_number}')
async def stop_capture(self, port_number):
"""
@@ -369,8 +327,4 @@ class FrameRelaySwitch(Device):
if not nio.capturing:
return
await nio.stop_packet_capture()
log.info(
'Frame relay switch "{name}" [{id}]: stopping packet capture on port {port}'.format(
name=self._name, id=self._id, port=port_number
)
)
log.info(f'Frame relay switch "{self._name}" [{self._id}]: stopping packet capture on port {port_number}')