mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-07 03:00:30 +03:00
refactor: use f-strings in dynamips nodes
This commit is contained in:
parent
a5d2bca921
commit
fba3ecc5fc
@ -82,11 +82,7 @@ class ATMSwitch(Device):
|
||||
"""
|
||||
|
||||
await self._hypervisor.send(f'atmsw rename "{self._name}" "{new_name}"')
|
||||
log.info(
|
||||
'ATM switch "{name}" [{id}]: renamed to "{new_name}"'.format(
|
||||
name=self._name, id=self._id, new_name=new_name
|
||||
)
|
||||
)
|
||||
log.info(f'ATM switch "{self._name}" [{self._id}]: renamed to "{new_name}"')
|
||||
self._name = new_name
|
||||
|
||||
@property
|
||||
@ -165,11 +161,7 @@ class ATMSwitch(Device):
|
||||
if port_number in self._nios:
|
||||
raise DynamipsError(f"Port {port_number} isn't free")
|
||||
|
||||
log.info(
|
||||
'ATM switch "{name}" [id={id}]: NIO {nio} bound to port {port}'.format(
|
||||
name=self._name, id=self._id, nio=nio, port=port_number
|
||||
)
|
||||
)
|
||||
log.info(f'ATM switch "{self._name}" [id={self._id}]: NIO {nio} bound to port {port_number}')
|
||||
|
||||
self._nios[port_number] = nio
|
||||
await self.set_mappings(self._mappings)
|
||||
@ -193,16 +185,7 @@ class ATMSwitch(Device):
|
||||
destination_port, destination_vpi, destination_vci = destination
|
||||
if port_number == source_port:
|
||||
log.info(
|
||||
'ATM switch "{name}" [{id}]: unmapping VCC between port {source_port} VPI {source_vpi} VCI {source_vci} and port {destination_port} VPI {destination_vpi} VCI {destination_vci}'.format(
|
||||
name=self._name,
|
||||
id=self._id,
|
||||
source_port=source_port,
|
||||
source_vpi=source_vpi,
|
||||
source_vci=source_vci,
|
||||
destination_port=destination_port,
|
||||
destination_vpi=destination_vpi,
|
||||
destination_vci=destination_vci,
|
||||
)
|
||||
f'ATM switch "{self._name}" [{self._id}]: unmapping VCC between port {source_port} VPI {source_vpi} VCI {source_vci} and port {destination_port} VPI {destination_vpi} VCI {destination_vci}'
|
||||
)
|
||||
await self.unmap_pvc(
|
||||
source_port, source_vpi, source_vci, destination_port, destination_vpi, destination_vci
|
||||
@ -216,14 +199,7 @@ class ATMSwitch(Device):
|
||||
destination_port, destination_vpi = destination
|
||||
if port_number == source_port:
|
||||
log.info(
|
||||
'ATM switch "{name}" [{id}]: unmapping VPC between port {source_port} VPI {source_vpi} and port {destination_port} VPI {destination_vpi}'.format(
|
||||
name=self._name,
|
||||
id=self._id,
|
||||
source_port=source_port,
|
||||
source_vpi=source_vpi,
|
||||
destination_port=destination_port,
|
||||
destination_vpi=destination_vpi,
|
||||
)
|
||||
f'ATM switch "{self._name}" [{self._id}]: unmapping VPC between port {source_port} VPI {source_vpi} and port {destination_port} VPI {destination_vpi}'
|
||||
)
|
||||
await self.unmap_vp(source_port, source_vpi, destination_port, destination_vpi)
|
||||
await self.unmap_vp(destination_port, destination_vpi, source_port, source_vpi)
|
||||
@ -231,11 +207,7 @@ class ATMSwitch(Device):
|
||||
nio = self._nios[port_number]
|
||||
if isinstance(nio, NIOUDP):
|
||||
self.manager.port_manager.release_udp_port(nio.lport, self._project)
|
||||
log.info(
|
||||
'ATM switch "{name}" [{id}]: NIO {nio} removed from port {port}'.format(
|
||||
name=self._name, id=self._id, nio=nio, port=port_number
|
||||
)
|
||||
)
|
||||
log.info(f'ATM switch "{self._name}" [{self._id}]: NIO {nio} removed from port {port_number}')
|
||||
|
||||
del self._nios[port_number]
|
||||
return nio
|
||||
@ -283,16 +255,7 @@ class ATMSwitch(Device):
|
||||
destination_vci,
|
||||
) not in self._active_mappings:
|
||||
log.info(
|
||||
'ATM switch "{name}" [{id}]: mapping VCC between port {source_port} VPI {source_vpi} VCI {source_vci} and port {destination_port} VPI {destination_vpi} VCI {destination_vci}'.format(
|
||||
name=self._name,
|
||||
id=self._id,
|
||||
source_port=source_port,
|
||||
source_vpi=source_vpi,
|
||||
source_vci=source_vci,
|
||||
destination_port=destination_port,
|
||||
destination_vpi=destination_vpi,
|
||||
destination_vci=destination_vci,
|
||||
)
|
||||
f'ATM switch "{self._name}" [{self._id}]: mapping VCC between port {source_port} VPI {source_vpi} VCI {source_vci} and port {destination_port} VPI {destination_vpi} VCI {destination_vci}'
|
||||
)
|
||||
await self.map_pvc(
|
||||
source_port, source_vpi, source_vci, destination_port, destination_vpi, destination_vci
|
||||
@ -310,14 +273,7 @@ class ATMSwitch(Device):
|
||||
destination_vpi,
|
||||
) not in self._active_mappings:
|
||||
log.info(
|
||||
'ATM switch "{name}" [{id}]: mapping VPC between port {source_port} VPI {source_vpi} and port {destination_port} VPI {destination_vpi}'.format(
|
||||
name=self._name,
|
||||
id=self._id,
|
||||
source_port=source_port,
|
||||
source_vpi=source_vpi,
|
||||
destination_port=destination_port,
|
||||
destination_vpi=destination_vpi,
|
||||
)
|
||||
f'ATM switch "{self._name}" [{self._id}]: mapping VPC between port {source_port} VPI {source_vpi} and port {destination_port} VPI {destination_vpi}'
|
||||
)
|
||||
await self.map_vp(source_port, source_vpi, destination_port, destination_vpi)
|
||||
await self.map_vp(destination_port, destination_vpi, source_port, source_vpi)
|
||||
@ -341,16 +297,10 @@ class ATMSwitch(Device):
|
||||
nio1 = self._nios[port1]
|
||||
nio2 = self._nios[port2]
|
||||
|
||||
await self._hypervisor.send(
|
||||
'atmsw create_vpc "{name}" {input_nio} {input_vpi} {output_nio} {output_vpi}'.format(
|
||||
name=self._name, input_nio=nio1, input_vpi=vpi1, output_nio=nio2, output_vpi=vpi2
|
||||
)
|
||||
)
|
||||
await self._hypervisor.send(f'atmsw create_vpc "{self._name}" {nio1} {vpi1} {nio2} {vpi2}')
|
||||
|
||||
log.info(
|
||||
'ATM switch "{name}" [{id}]: VPC from port {port1} VPI {vpi1} to port {port2} VPI {vpi2} created'.format(
|
||||
name=self._name, id=self._id, port1=port1, vpi1=vpi1, port2=port2, vpi2=vpi2
|
||||
)
|
||||
f'ATM switch "{self._name}" [{self._id}]: VPC from port {port1} VPI {vpi1} to port {port2} VPI {vpi2} created'
|
||||
)
|
||||
|
||||
self._active_mappings[(port1, vpi1)] = (port2, vpi2)
|
||||
@ -374,16 +324,10 @@ class ATMSwitch(Device):
|
||||
nio1 = self._nios[port1]
|
||||
nio2 = self._nios[port2]
|
||||
|
||||
await self._hypervisor.send(
|
||||
'atmsw delete_vpc "{name}" {input_nio} {input_vpi} {output_nio} {output_vpi}'.format(
|
||||
name=self._name, input_nio=nio1, input_vpi=vpi1, output_nio=nio2, output_vpi=vpi2
|
||||
)
|
||||
)
|
||||
await self._hypervisor.send(f'atmsw delete_vpc "{self._name}" {nio1} {vpi1} {nio2} {vpi2}')
|
||||
|
||||
log.info(
|
||||
'ATM switch "{name}" [{id}]: VPC from port {port1} VPI {vpi1} to port {port2} VPI {vpi2} deleted'.format(
|
||||
name=self._name, id=self._id, port1=port1, vpi1=vpi1, port2=port2, vpi2=vpi2
|
||||
)
|
||||
f'ATM switch "{self._name}" [{self._id}]: VPC from port {port1} VPI {vpi1} to port {port2} VPI {vpi2} deleted'
|
||||
)
|
||||
|
||||
del self._active_mappings[(port1, vpi1)]
|
||||
@ -409,22 +353,10 @@ class ATMSwitch(Device):
|
||||
nio1 = self._nios[port1]
|
||||
nio2 = self._nios[port2]
|
||||
|
||||
await self._hypervisor.send(
|
||||
'atmsw create_vcc "{name}" {input_nio} {input_vpi} {input_vci} {output_nio} {output_vpi} {output_vci}'.format(
|
||||
name=self._name,
|
||||
input_nio=nio1,
|
||||
input_vpi=vpi1,
|
||||
input_vci=vci1,
|
||||
output_nio=nio2,
|
||||
output_vpi=vpi2,
|
||||
output_vci=vci2,
|
||||
)
|
||||
)
|
||||
await self._hypervisor.send(f'atmsw create_vcc "{self._name}" {nio1} {vpi1} {vci1} {nio2} {vpi2} {vci2}')
|
||||
|
||||
log.info(
|
||||
'ATM switch "{name}" [{id}]: VCC from port {port1} VPI {vpi1} VCI {vci1} to port {port2} VPI {vpi2} VCI {vci2} created'.format(
|
||||
name=self._name, id=self._id, port1=port1, vpi1=vpi1, vci1=vci1, port2=port2, vpi2=vpi2, vci2=vci2
|
||||
)
|
||||
f'ATM switch "{self._name}" [{self._id}]: VCC from port {port1} VPI {vpi1} VCI {vci1} to port {port2} VPI {vpi2} VCI {vci2} created'
|
||||
)
|
||||
|
||||
self._active_mappings[(port1, vpi1, vci1)] = (port2, vpi2, vci2)
|
||||
@ -450,22 +382,10 @@ class ATMSwitch(Device):
|
||||
nio1 = self._nios[port1]
|
||||
nio2 = self._nios[port2]
|
||||
|
||||
await self._hypervisor.send(
|
||||
'atmsw delete_vcc "{name}" {input_nio} {input_vpi} {input_vci} {output_nio} {output_vpi} {output_vci}'.format(
|
||||
name=self._name,
|
||||
input_nio=nio1,
|
||||
input_vpi=vpi1,
|
||||
input_vci=vci1,
|
||||
output_nio=nio2,
|
||||
output_vpi=vpi2,
|
||||
output_vci=vci2,
|
||||
)
|
||||
)
|
||||
await self._hypervisor.send(f'atmsw delete_vcc "{self._name}" {nio1} {vpi1} {vci1} {nio2} {vpi2} {vci2}')
|
||||
|
||||
log.info(
|
||||
'ATM switch "{name}" [{id}]: VCC from port {port1} VPI {vpi1} VCI {vci1} to port {port2} VPI {vpi2} VCI {vci2} deleted'.format(
|
||||
name=self._name, id=self._id, port1=port1, vpi1=vpi1, vci1=vci1, port2=port2, vpi2=vpi2, vci2=vci2
|
||||
)
|
||||
f'ATM switch "{self._name}" [{self._id}]: VCC from port {port1} VPI {vpi1} VCI {vci1} to port {port2} VPI {vpi2} VCI {vci2} deleted'
|
||||
)
|
||||
del self._active_mappings[(port1, vpi1, vci1)]
|
||||
|
||||
@ -487,11 +407,7 @@ class ATMSwitch(Device):
|
||||
raise DynamipsError(f"Port {port_number} has already a filter applied")
|
||||
|
||||
await nio.start_packet_capture(output_file, data_link_type)
|
||||
log.info(
|
||||
'ATM switch "{name}" [{id}]: starting packet capture on port {port}'.format(
|
||||
name=self._name, id=self._id, port=port_number
|
||||
)
|
||||
)
|
||||
log.info(f'ATM switch "{self._name}" [{self._id}]: starting packet capture on port {port_number}')
|
||||
|
||||
async def stop_capture(self, port_number):
|
||||
"""
|
||||
@ -504,8 +420,4 @@ class ATMSwitch(Device):
|
||||
if not nio.capturing:
|
||||
return
|
||||
await nio.stop_packet_capture()
|
||||
log.info(
|
||||
'ATM switch "{name}" [{id}]: stopping packet capture on port {port}'.format(
|
||||
name=self._name, id=self._id, port=port_number
|
||||
)
|
||||
)
|
||||
log.info(f'ATM switch "{self._name}" [{self._id}]: stopping packet capture on port {port_number}')
|
||||
|
||||
@ -54,9 +54,7 @@ class Bridge(Device):
|
||||
:param new_name: New name for this bridge
|
||||
"""
|
||||
|
||||
await self._hypervisor.send(
|
||||
'nio_bridge rename "{name}" "{new_name}"'.format(name=self._name, new_name=new_name)
|
||||
)
|
||||
await self._hypervisor.send(f'nio_bridge rename "{self._name}" "{new_name}"')
|
||||
|
||||
self._name = new_name
|
||||
|
||||
|
||||
@ -124,9 +124,7 @@ class C1700(Router):
|
||||
|
||||
await self._hypervisor.send(f'c1700 set_chassis "{self._name}" {chassis}')
|
||||
|
||||
log.info(
|
||||
'Router "{name}" [{id}]: chassis set to {chassis}'.format(name=self._name, id=self._id, chassis=chassis)
|
||||
)
|
||||
log.info(f'Router "{self._name}" [{self._id}]: chassis set to {chassis}')
|
||||
|
||||
self._chassis = chassis
|
||||
self._setup_chassis()
|
||||
@ -150,9 +148,5 @@ class C1700(Router):
|
||||
|
||||
await self._hypervisor.send(f'c1700 set_iomem "{self._name}" {iomem}')
|
||||
|
||||
log.info(
|
||||
'Router "{name}" [{id}]: I/O memory updated from {old_iomem}% to {new_iomem}%'.format(
|
||||
name=self._name, id=self._id, old_iomem=self._iomem, new_iomem=iomem
|
||||
)
|
||||
)
|
||||
log.info(f'Router "{self._name}" [{self._id}]: I/O memory updated from {self._iomem}% to {iomem}%')
|
||||
self._iomem = iomem
|
||||
|
||||
@ -136,9 +136,7 @@ class C2600(Router):
|
||||
|
||||
await self._hypervisor.send(f'c2600 set_chassis "{self._name}" {chassis}')
|
||||
|
||||
log.info(
|
||||
'Router "{name}" [{id}]: chassis set to {chassis}'.format(name=self._name, id=self._id, chassis=chassis)
|
||||
)
|
||||
log.info(f'Router "{self._name}" [{self._id}]: chassis set to {chassis}')
|
||||
self._chassis = chassis
|
||||
self._setup_chassis()
|
||||
|
||||
@ -161,9 +159,5 @@ class C2600(Router):
|
||||
|
||||
await self._hypervisor.send(f'c2600 set_iomem "{self._name}" {iomem}')
|
||||
|
||||
log.info(
|
||||
'Router "{name}" [{id}]: I/O memory updated from {old_iomem}% to {new_iomem}%'.format(
|
||||
name=self._name, id=self._id, old_iomem=self._iomem, new_iomem=iomem
|
||||
)
|
||||
)
|
||||
log.info(f'Router "{self._name}" [{self._id}]: I/O memory updated from {self._iomem}% to {iomem}%')
|
||||
self._iomem = iomem
|
||||
|
||||
@ -102,9 +102,5 @@ class C2691(Router):
|
||||
|
||||
await self._hypervisor.send(f'c2691 set_iomem "{self._name}" {iomem}')
|
||||
|
||||
log.info(
|
||||
'Router "{name}" [{id}]: I/O memory updated from {old_iomem}% to {new_iomem}%'.format(
|
||||
name=self._name, id=self._id, old_iomem=self._iomem, new_iomem=iomem
|
||||
)
|
||||
)
|
||||
log.info(f'Router "{self._name}" [{self._id}]: I/O memory updated from {self._iomem}% to {iomem}%')
|
||||
self._iomem = iomem
|
||||
|
||||
@ -119,9 +119,7 @@ class C3600(Router):
|
||||
|
||||
await self._hypervisor.send(f'c3600 set_chassis "{self._name}" {chassis}')
|
||||
|
||||
log.info(
|
||||
'Router "{name}" [{id}]: chassis set to {chassis}'.format(name=self._name, id=self._id, chassis=chassis)
|
||||
)
|
||||
log.info(f'Router "{self._name}" [{self._id}]: chassis set to {chassis}')
|
||||
|
||||
self._chassis = chassis
|
||||
self._setup_chassis()
|
||||
@ -145,9 +143,5 @@ class C3600(Router):
|
||||
|
||||
await self._hypervisor.send(f'c3600 set_iomem "{self._name}" {iomem}')
|
||||
|
||||
log.info(
|
||||
'Router "{name}" [{id}]: I/O memory updated from {old_iomem}% to {new_iomem}%'.format(
|
||||
name=self._name, id=self._id, old_iomem=self._iomem, new_iomem=iomem
|
||||
)
|
||||
)
|
||||
log.info(f'Router "{self._name}" [{self._id}]: I/O memory updated from {self._iomem}% to {iomem}%')
|
||||
self._iomem = iomem
|
||||
|
||||
@ -102,9 +102,5 @@ class C3725(Router):
|
||||
|
||||
await self._hypervisor.send(f'c3725 set_iomem "{self._name}" {iomem}')
|
||||
|
||||
log.info(
|
||||
'Router "{name}" [{id}]: I/O memory updated from {old_iomem}% to {new_iomem}%'.format(
|
||||
name=self._name, id=self._id, old_iomem=self._iomem, new_iomem=iomem
|
||||
)
|
||||
)
|
||||
log.info(f'Router "{self._name}" [{self._id}]: I/O memory updated from {self._iomem}% to {iomem}%')
|
||||
self._iomem = iomem
|
||||
|
||||
@ -102,9 +102,5 @@ class C3745(Router):
|
||||
|
||||
await self._hypervisor.send(f'c3745 set_iomem "{self._name}" {iomem}')
|
||||
|
||||
log.info(
|
||||
'Router "{name}" [{id}]: I/O memory updated from {old_iomem}% to {new_iomem}%'.format(
|
||||
name=self._name, id=self._id, old_iomem=self._iomem, new_iomem=iomem
|
||||
)
|
||||
)
|
||||
log.info(f'Router "{self._name}" [{self._id}]: I/O memory updated from {self._iomem}% to {iomem}%')
|
||||
self._iomem = iomem
|
||||
|
||||
@ -139,11 +139,7 @@ class C7200(Router):
|
||||
|
||||
await self._hypervisor.send(f'c7200 set_npe "{self._name}" {npe}')
|
||||
|
||||
log.info(
|
||||
'Router "{name}" [{id}]: NPE updated from {old_npe} to {new_npe}'.format(
|
||||
name=self._name, id=self._id, old_npe=self._npe, new_npe=npe
|
||||
)
|
||||
)
|
||||
log.info(f'Router "{self._name}" [{self._id}]: NPE updated from {self._npe} to {npe}')
|
||||
self._npe = npe
|
||||
|
||||
@property
|
||||
@ -165,11 +161,7 @@ class C7200(Router):
|
||||
|
||||
await self._hypervisor.send(f'c7200 set_midplane "{self._name}" {midplane}')
|
||||
|
||||
log.info(
|
||||
'Router "{name}" [{id}]: midplane updated from {old_midplane} to {new_midplane}'.format(
|
||||
name=self._name, id=self._id, old_midplane=self._midplane, new_midplane=midplane
|
||||
)
|
||||
)
|
||||
log.info(f'Router "{self._name}" [{self._id}]: midplane updated from {self._midplane} to {midplane}')
|
||||
self._midplane = midplane
|
||||
|
||||
@property
|
||||
@ -196,20 +188,10 @@ class C7200(Router):
|
||||
|
||||
sensor_id = 0
|
||||
for sensor in sensors:
|
||||
await self._hypervisor.send(
|
||||
'c7200 set_temp_sensor "{name}" {sensor_id} {temp}'.format(
|
||||
name=self._name, sensor_id=sensor_id, temp=sensor
|
||||
)
|
||||
)
|
||||
await self._hypervisor.send(f'c7200 set_temp_sensor "{self._name}" {sensor_id} {sensor}')
|
||||
|
||||
log.info(
|
||||
'Router "{name}" [{id}]: sensor {sensor_id} temperature updated from {old_temp}C to {new_temp}C'.format(
|
||||
name=self._name,
|
||||
id=self._id,
|
||||
sensor_id=sensor_id,
|
||||
old_temp=self._sensors[sensor_id],
|
||||
new_temp=sensors[sensor_id],
|
||||
)
|
||||
f'Router "{self._name}" [{self._id}]: sensor {sensor_id} temperature updated from {self._sensors[sensor_id]}C to {sensors[sensor_id]}C'
|
||||
)
|
||||
|
||||
sensor_id += 1
|
||||
@ -235,16 +217,10 @@ class C7200(Router):
|
||||
|
||||
power_supply_id = 0
|
||||
for power_supply in power_supplies:
|
||||
await self._hypervisor.send(
|
||||
'c7200 set_power_supply "{name}" {power_supply_id} {powered_on}'.format(
|
||||
name=self._name, power_supply_id=power_supply_id, powered_on=power_supply
|
||||
)
|
||||
)
|
||||
await self._hypervisor.send(f'c7200 set_power_supply "{self._name}" {power_supply_id} {power_supply}')
|
||||
|
||||
log.info(
|
||||
'Router "{name}" [{id}]: power supply {power_supply_id} state updated to {powered_on}'.format(
|
||||
name=self._name, id=self._id, power_supply_id=power_supply_id, powered_on=power_supply
|
||||
)
|
||||
f'Router "{self._name}" [{self._id}]: power supply {power_supply_id} state updated to {power_supply}'
|
||||
)
|
||||
power_supply_id += 1
|
||||
|
||||
|
||||
@ -145,11 +145,7 @@ class EthernetHub(Bridge):
|
||||
|
||||
await Bridge.add_nio(self, nio)
|
||||
|
||||
log.info(
|
||||
'Ethernet hub "{name}" [{id}]: NIO {nio} bound to port {port}'.format(
|
||||
name=self._name, id=self._id, nio=nio, port=port_number
|
||||
)
|
||||
)
|
||||
log.info(f'Ethernet hub "{self._name}" [{self._id}]: NIO {nio} bound to port {port_number}')
|
||||
self._mappings[port_number] = nio
|
||||
|
||||
async def remove_nio(self, port_number):
|
||||
@ -170,11 +166,7 @@ class EthernetHub(Bridge):
|
||||
self.manager.port_manager.release_udp_port(nio.lport, self._project)
|
||||
await Bridge.remove_nio(self, nio)
|
||||
|
||||
log.info(
|
||||
'Ethernet hub "{name}" [{id}]: NIO {nio} removed from port {port}'.format(
|
||||
name=self._name, id=self._id, nio=nio, port=port_number
|
||||
)
|
||||
)
|
||||
log.info(f'Ethernet hub "{self._name}" [{self._id}]: NIO {nio} removed from port {port_number}')
|
||||
|
||||
del self._mappings[port_number]
|
||||
return nio
|
||||
@ -216,11 +208,7 @@ class EthernetHub(Bridge):
|
||||
raise DynamipsError(f"Port {port_number} has already a filter applied")
|
||||
|
||||
await nio.start_packet_capture(output_file, data_link_type)
|
||||
log.info(
|
||||
'Ethernet hub "{name}" [{id}]: starting packet capture on port {port}'.format(
|
||||
name=self._name, id=self._id, port=port_number
|
||||
)
|
||||
)
|
||||
log.info(f'Ethernet hub "{self._name}" [{self._id}]: starting packet capture on port {port_number}')
|
||||
|
||||
async def stop_capture(self, port_number):
|
||||
"""
|
||||
@ -233,8 +221,4 @@ class EthernetHub(Bridge):
|
||||
if not nio.capturing:
|
||||
return
|
||||
await nio.stop_packet_capture()
|
||||
log.info(
|
||||
'Ethernet hub "{name}" [{id}]: stopping packet capture on port {port}'.format(
|
||||
name=self._name, id=self._id, port=port_number
|
||||
)
|
||||
)
|
||||
log.info(f'Ethernet hub "{self._name}" [{self._id}]: stopping packet capture on port {port_number}')
|
||||
|
||||
@ -210,11 +210,7 @@ class EthernetSwitch(Device):
|
||||
"""
|
||||
|
||||
await self._hypervisor.send(f'ethsw rename "{self._name}" "{new_name}"')
|
||||
log.info(
|
||||
'Ethernet switch "{name}" [{id}]: renamed to "{new_name}"'.format(
|
||||
name=self._name, id=self._id, new_name=new_name
|
||||
)
|
||||
)
|
||||
log.info(f'Ethernet switch "{self._name}" [{self._id}]: renamed to "{new_name}"')
|
||||
self._name = new_name
|
||||
|
||||
@property
|
||||
@ -279,11 +275,7 @@ class EthernetSwitch(Device):
|
||||
|
||||
await self._hypervisor.send(f'ethsw add_nio "{self._name}" {nio}')
|
||||
|
||||
log.info(
|
||||
'Ethernet switch "{name}" [{id}]: NIO {nio} bound to port {port}'.format(
|
||||
name=self._name, id=self._id, nio=nio, port=port_number
|
||||
)
|
||||
)
|
||||
log.info(f'Ethernet switch "{self._name}" [{self._id}]: NIO {nio} bound to port {port_number}')
|
||||
self._nios[port_number] = nio
|
||||
for port_settings in self._ports:
|
||||
if port_settings["port_number"] == port_number:
|
||||
@ -309,11 +301,7 @@ class EthernetSwitch(Device):
|
||||
if self._hypervisor:
|
||||
await self._hypervisor.send(f'ethsw remove_nio "{self._name}" {nio}')
|
||||
|
||||
log.info(
|
||||
'Ethernet switch "{name}" [{id}]: NIO {nio} removed from port {port}'.format(
|
||||
name=self._name, id=self._id, nio=nio, port=port_number
|
||||
)
|
||||
)
|
||||
log.info(f'Ethernet switch "{self._name}" [{self._id}]: NIO {nio} removed from port {port_number}')
|
||||
|
||||
del self._nios[port_number]
|
||||
if port_number in self._mappings:
|
||||
@ -367,14 +355,10 @@ class EthernetSwitch(Device):
|
||||
raise DynamipsError(f"Port {port_number} is not allocated")
|
||||
|
||||
nio = self._nios[port_number]
|
||||
await self._hypervisor.send(
|
||||
'ethsw set_access_port "{name}" {nio} {vlan_id}'.format(name=self._name, nio=nio, vlan_id=vlan_id)
|
||||
)
|
||||
await self._hypervisor.send(f'ethsw set_access_port "{self._name}" {nio} {vlan_id}')
|
||||
|
||||
log.info(
|
||||
'Ethernet switch "{name}" [{id}]: port {port} set as an access port in VLAN {vlan_id}'.format(
|
||||
name=self._name, id=self._id, port=port_number, vlan_id=vlan_id
|
||||
)
|
||||
f'Ethernet switch "{self._name}" [{self._id}]: port {port_number} set as an access port in VLAN {vlan_id}'
|
||||
)
|
||||
self._mappings[port_number] = ("access", vlan_id)
|
||||
|
||||
@ -390,16 +374,10 @@ class EthernetSwitch(Device):
|
||||
raise DynamipsError(f"Port {port_number} is not allocated")
|
||||
|
||||
nio = self._nios[port_number]
|
||||
await self._hypervisor.send(
|
||||
'ethsw set_dot1q_port "{name}" {nio} {native_vlan}'.format(
|
||||
name=self._name, nio=nio, native_vlan=native_vlan
|
||||
)
|
||||
)
|
||||
await self._hypervisor.send(f'ethsw set_dot1q_port "{self._name}" {nio} {native_vlan}')
|
||||
|
||||
log.info(
|
||||
'Ethernet switch "{name}" [{id}]: port {port} set as a 802.1Q port with native VLAN {vlan_id}'.format(
|
||||
name=self._name, id=self._id, port=port_number, vlan_id=native_vlan
|
||||
)
|
||||
f'Ethernet switch "{self._name}" [{self._id}]: port {port_number} set as a 802.1Q port with native VLAN {native_vlan}'
|
||||
)
|
||||
|
||||
self._mappings[port_number] = ("dot1q", native_vlan)
|
||||
@ -428,9 +406,7 @@ class EthernetSwitch(Device):
|
||||
)
|
||||
|
||||
log.info(
|
||||
'Ethernet switch "{name}" [{id}]: port {port} set as a QinQ ({ethertype}) port with outer VLAN {vlan_id}'.format(
|
||||
name=self._name, id=self._id, port=port_number, vlan_id=outer_vlan, ethertype=ethertype
|
||||
)
|
||||
f'Ethernet switch "{self._name}" [{self._id}]: port {port_number} set as a QinQ ({ethertype}) port with outer VLAN {outer_vlan}'
|
||||
)
|
||||
self._mappings[port_number] = ("qinq", outer_vlan, ethertype)
|
||||
|
||||
@ -469,11 +445,7 @@ class EthernetSwitch(Device):
|
||||
raise DynamipsError(f"Port {port_number} has already a filter applied")
|
||||
|
||||
await nio.start_packet_capture(output_file, data_link_type)
|
||||
log.info(
|
||||
'Ethernet switch "{name}" [{id}]: starting packet capture on port {port}'.format(
|
||||
name=self._name, id=self._id, port=port_number
|
||||
)
|
||||
)
|
||||
log.info(f'Ethernet switch "{self._name}" [{self._id}]: starting packet capture on port {port_number}')
|
||||
|
||||
async def stop_capture(self, port_number):
|
||||
"""
|
||||
@ -486,8 +458,4 @@ class EthernetSwitch(Device):
|
||||
if not nio.capturing:
|
||||
return
|
||||
await nio.stop_packet_capture()
|
||||
log.info(
|
||||
'Ethernet switch "{name}" [{id}]: stopping packet capture on port {port}'.format(
|
||||
name=self._name, id=self._id, port=port_number
|
||||
)
|
||||
)
|
||||
log.info(f'Ethernet switch "{self._name}" [{self._id}]: stopping packet capture on port {port_number}')
|
||||
|
||||
@ -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}')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user