Use black with -l 120 param.

This commit is contained in:
grossmj committed 2021-04-13 18:46:50 +09:30
1 parent f928738bd5
commit c021e21309
194 files changed
+6034 -4564

No files matched your search

@@ -26,6 +26,7 @@ from ..nios.nio_udp import NIOUDP
from ..dynamips_error import DynamipsError
import logging
log = logging.getLogger(__name__)
@@ -56,12 +57,14 @@ class FrameRelaySwitch(Device):
for source, destination in self._mappings.items():
mappings[source] = destination
return {"name": self.name,
"usage": self.usage,
"node_id": self.id,
"project_id": self.project.id,
"mappings": mappings,
"status": "started"}
return {
"name": self.name,
"usage": self.usage,
"node_id": self.id,
"project_id": self.project.id,
"mappings": mappings,
"status": "started",
}
async def create(self):
@@ -81,9 +84,11 @@ 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(
'Frame Relay switch "{name}" [{id}]: renamed to "{new_name}"'.format(
name=self._name, id=self._id, new_name=new_name
)
)
self._name = new_name
@property
@@ -163,10 +168,11 @@ 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(
'Frame Relay switch "{name}" [{id}]: NIO {nio} bound to port {port}'.format(
name=self._name, id=self._id, nio=nio, port=port_number
)
)
self._nios[port_number] = nio
await self.set_mappings(self._mappings)
@@ -189,12 +195,16 @@ class FrameRelaySwitch(Device):
source_port, source_dlci = source
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))
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,
)
)
await self.unmap_vc(source_port, source_dlci, destination_port, destination_dlci)
await self.unmap_vc(destination_port, destination_dlci, source_port, source_dlci)
@@ -202,10 +212,11 @@ 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(
'Frame Relay switch "{name}" [{id}]: NIO {nio} removed from port {port}'.format(
name=self._name, id=self._id, nio=nio, port=port_number
)
)
del self._nios[port_number]
return nio
@@ -239,16 +250,23 @@ class FrameRelaySwitch(Device):
for source, destination in mappings.items():
if not isinstance(source, str) or not isinstance(destination, str):
raise DynamipsError("Invalid Frame-Relay mappings")
source_port, source_dlci = map(int, source.split(':'))
destination_port, destination_dlci = map(int, destination.split(':'))
source_port, source_dlci = map(int, source.split(":"))
destination_port, destination_dlci = map(int, destination.split(":"))
if self.has_port(destination_port):
if (source_port, source_dlci) not in self._active_mappings and (destination_port, 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))
if (source_port, source_dlci) not in self._active_mappings and (
destination_port,
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,
)
)
await self.map_vc(source_port, source_dlci, destination_port, destination_dlci)
await self.map_vc(destination_port, destination_dlci, source_port, source_dlci)
@@ -272,18 +290,17 @@ 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(
'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
)
)
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))
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
)
)
self._active_mappings[(port1, dlci1)] = (port2, dlci2)
@@ -306,18 +323,17 @@ 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(
'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
)
)
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))
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
)
)
del self._active_mappings[(port1, dlci1)]
async def start_capture(self, port_number, output_file, data_link_type="DLT_FRELAY"):
@@ -339,9 +355,11 @@ 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(
'Frame relay switch "{name}" [{id}]: starting packet capture on port {port}'.format(
name=self._name, id=self._id, port=port_number
)
)
async def stop_capture(self, port_number):
"""
@@ -354,6 +372,8 @@ 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(
'Frame relay switch "{name}" [{id}]: stopping packet capture on port {port}'.format(
name=self._name, id=self._id, port=port_number
)
)