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

+46 -37
View File
@@ -74,36 +74,38 @@ from .adapters.wic_1t import WIC_1T
from .adapters.wic_2t import WIC_2T
ADAPTER_MATRIX = {"C7200-IO-2FE": C7200_IO_2FE,
"C7200-IO-FE": C7200_IO_FE,
"C7200-IO-GE-E": C7200_IO_GE_E,
"NM-16ESW": NM_16ESW,
"NM-1E": NM_1E,
"NM-1FE-TX": NM_1FE_TX,
"NM-4E": NM_4E,
"NM-4T": NM_4T,
"PA-2FE-TX": PA_2FE_TX,
"PA-4E": PA_4E,
"PA-4T+": PA_4T,
"PA-8E": PA_8E,
"PA-8T": PA_8T,
"PA-A1": PA_A1,
"PA-FE-TX": PA_FE_TX,
"PA-GE": PA_GE,
"PA-POS-OC3": PA_POS_OC3}
ADAPTER_MATRIX = {
"C7200-IO-2FE": C7200_IO_2FE,
"C7200-IO-FE": C7200_IO_FE,
"C7200-IO-GE-E": C7200_IO_GE_E,
"NM-16ESW": NM_16ESW,
"NM-1E": NM_1E,
"NM-1FE-TX": NM_1FE_TX,
"NM-4E": NM_4E,
"NM-4T": NM_4T,
"PA-2FE-TX": PA_2FE_TX,
"PA-4E": PA_4E,
"PA-4T+": PA_4T,
"PA-8E": PA_8E,
"PA-8T": PA_8T,
"PA-A1": PA_A1,
"PA-FE-TX": PA_FE_TX,
"PA-GE": PA_GE,
"PA-POS-OC3": PA_POS_OC3,
}
WIC_MATRIX = {"WIC-1ENET": WIC_1ENET,
"WIC-1T": WIC_1T,
"WIC-2T": WIC_2T}
WIC_MATRIX = {"WIC-1ENET": WIC_1ENET, "WIC-1T": WIC_1T, "WIC-2T": WIC_2T}
PLATFORMS_DEFAULT_RAM = {"c1700": 160,
"c2600": 160,
"c2691": 192,
"c3600": 192,
"c3725": 128,
"c3745": 256,
"c7200": 512}
PLATFORMS_DEFAULT_RAM = {
"c1700": 160,
"c2600": 160,
"c2691": 192,
"c3600": 192,
"c3725": 128,
"c3745": 256,
"c7200": 512,
}
class Dynamips(BaseManager):
@@ -126,7 +128,7 @@ class Dynamips(BaseManager):
"""
:returns: List of node type supported by this class and computer
"""
return ['dynamips', 'frame_relay_switch', 'atm_switch']
return ["dynamips", "frame_relay_switch", "atm_switch"]
def get_dynamips_id(self, project_id):
"""
@@ -301,7 +303,7 @@ class Dynamips(BaseManager):
await hypervisor.start()
log.info(f"Hypervisor {hypervisor.host}:{hypervisor.port} has successfully started")
await hypervisor.connect()
if parse_version(hypervisor.version) < parse_version('0.2.11'):
if parse_version(hypervisor.version) < parse_version("0.2.11"):
raise DynamipsError(f"Dynamips version must be >= 0.2.11, detected version is {hypervisor.version}")
return hypervisor
@@ -408,7 +410,15 @@ class Dynamips(BaseManager):
if ghost_file_path not in self._ghost_files:
# create a new ghost IOS instance
ghost_id = str(uuid4())
ghost = Router("ghost-" + ghost_file, ghost_id, vm.project, vm.manager, platform=vm.platform, hypervisor=vm.hypervisor, ghost_flag=True)
ghost = Router(
"ghost-" + ghost_file,
ghost_id,
vm.project,
vm.manager,
platform=vm.platform,
hypervisor=vm.hypervisor,
ghost_flag=True,
)
try:
await ghost.create()
await ghost.set_image(vm.image)
@@ -538,7 +548,7 @@ class Dynamips(BaseManager):
with open(path, "wb") as f:
if content:
content = "!\n" + content.replace("\r", "")
content = content.replace('%h', vm.name)
content = content.replace("%h", vm.name)
f.write(content.encode("utf-8"))
except OSError as e:
raise DynamipsError(f"Could not create config file '{path}': {e}")
@@ -571,7 +581,7 @@ class Dynamips(BaseManager):
for idlepc in idlepcs:
match = re.search(r"^0x[0-9a-f]{8}$", idlepc.split()[0])
if not match:
continue
continue
await vm.set_idlepc(idlepc.split()[0])
log.debug(f"Auto Idle-PC: trying idle-PC value {vm.idlepc}")
start_time = time.time()
@@ -615,7 +625,7 @@ class Dynamips(BaseManager):
# Not a Dynamips router
if not hasattr(source_node, "startup_config_path"):
return (await super().duplicate_node(source_node_id, destination_node_id))
return await super().duplicate_node(source_node_id, destination_node_id)
try:
with open(source_node.startup_config_path) as f:
@@ -627,10 +637,9 @@ class Dynamips(BaseManager):
private_config = f.read()
except OSError:
private_config = None
await self.set_vm_configs(destination_node, {
"startup_config_content": startup_config,
"private_config_content": private_config
})
await self.set_vm_configs(
destination_node, {"startup_config_content": startup_config, "private_config_content": private_config}
)
# Force refresh of the name in configuration files
new_name = destination_node.name
@@ -18,7 +18,6 @@ from .adapter import Adapter
class GT96100_FE(Adapter):
def __init__(self):
super().__init__(interfaces=2, wics=3)
+16 -11
View File
@@ -29,21 +29,26 @@ from .nodes.ethernet_hub import EthernetHub
from .nodes.frame_relay_switch import FrameRelaySwitch
import logging
log = logging.getLogger(__name__)
PLATFORMS = {'c1700': C1700,
'c2600': C2600,
'c2691': C2691,
'c3725': C3725,
'c3745': C3745,
'c3600': C3600,
'c7200': C7200}
PLATFORMS = {
"c1700": C1700,
"c2600": C2600,
"c2691": C2691,
"c3725": C3725,
"c3745": C3745,
"c3600": C3600,
"c7200": C7200,
}
DEVICES = {'atm_switch': ATMSwitch,
'frame_relay_switch': FrameRelaySwitch,
'ethernet_switch': EthernetSwitch,
'ethernet_hub': EthernetHub}
DEVICES = {
"atm_switch": ATMSwitch,
"frame_relay_switch": FrameRelaySwitch,
"ethernet_switch": EthernetSwitch,
"ethernet_hub": EthernetHub,
}
class DynamipsFactory:
@@ -78,7 +78,9 @@ class DynamipsHypervisor:
while time.time() - begin < timeout:
await asyncio.sleep(0.01)
try:
self._reader, self._writer = await asyncio.wait_for(asyncio.open_connection(host, self._port), timeout=1)
self._reader, self._writer = await asyncio.wait_for(
asyncio.open_connection(host, self._port), timeout=1
)
except (asyncio.TimeoutError, OSError) as e:
last_exception = e
continue
@@ -242,17 +244,20 @@ class DynamipsHypervisor:
raise DynamipsError("Not connected")
try:
command = command.strip() + '\n'
command = command.strip() + "\n"
log.debug(f"sending {command}")
self._writer.write(command.encode())
await self._writer.drain()
except OSError as e:
raise DynamipsError("Could not send Dynamips command '{command}' to {host}:{port}: {error}, process running: {run}"
.format(command=command.strip(), host=self._host, port=self._port, error=e, run=self.is_running()))
raise DynamipsError(
"Could not send Dynamips command '{command}' to {host}:{port}: {error}, process running: {run}".format(
command=command.strip(), host=self._host, port=self._port, error=e, run=self.is_running()
)
)
# Now retrieve the result
data = []
buf = ''
buf = ""
retries = 0
max_retries = 10
while True:
@@ -272,8 +277,11 @@ class DynamipsHypervisor:
continue
if not chunk:
if retries > max_retries:
raise DynamipsError("No data returned from {host}:{port}, Dynamips process running: {run}"
.format(host=self._host, port=self._port, run=self.is_running()))
raise DynamipsError(
"No data returned from {host}:{port}, Dynamips process running: {run}".format(
host=self._host, port=self._port, run=self.is_running()
)
)
else:
retries += 1
await asyncio.sleep(0.1)
@@ -281,30 +289,36 @@ class DynamipsHypervisor:
retries = 0
buf += chunk.decode("utf-8", errors="ignore")
except OSError as e:
raise DynamipsError("Could not read response for '{command}' from {host}:{port}: {error}, process running: {run}"
.format(command=command.strip(), host=self._host, port=self._port, error=e, run=self.is_running()))
raise DynamipsError(
"Could not read response for '{command}' from {host}:{port}: {error}, process running: {run}".format(
command=command.strip(), host=self._host, port=self._port, error=e, run=self.is_running()
)
)
# If the buffer doesn't end in '\n' then we can't be done
try:
if buf[-1] != '\n':
if buf[-1] != "\n":
continue
except IndexError:
raise DynamipsError("Could not communicate with {host}:{port}, Dynamips process running: {run}"
.format(host=self._host, port=self._port, run=self.is_running()))
raise DynamipsError(
"Could not communicate with {host}:{port}, Dynamips process running: {run}".format(
host=self._host, port=self._port, run=self.is_running()
)
)
data += buf.split('\r\n')
if data[-1] == '':
data += buf.split("\r\n")
if data[-1] == "":
data.pop()
buf = ''
buf = ""
# Does it contain an error code?
if self.error_re.search(data[-1]):
raise DynamipsError(f"Dynamips error when running command '{command}': {data[-1][4:]}")
# Or does the last line begin with '100-'? Then we are done!
if data[-1][:4] == '100-':
if data[-1][:4] == "100-":
data[-1] = data[-1][4:]
if data[-1] == 'OK':
if data[-1] == "OK":
data.pop()
break
+6 -7
View File
@@ -28,6 +28,7 @@ from .dynamips_hypervisor import DynamipsHypervisor
from .dynamips_error import DynamipsError
import logging
log = logging.getLogger(__name__)
@@ -121,17 +122,15 @@ class Hypervisor(DynamipsHypervisor):
# add the Npcap directory to $PATH to force Dynamips to use npcap DLL instead of Winpcap (if installed)
system_root = os.path.join(os.path.expandvars("%SystemRoot%"), "System32", "Npcap")
if os.path.isdir(system_root):
env["PATH"] = system_root + ';' + env["PATH"]
env["PATH"] = system_root + ";" + env["PATH"]
try:
log.info(f"Starting Dynamips: {self._command}")
self._stdout_file = os.path.join(self.working_dir, f"dynamips_i{self._id}_stdout.txt")
log.info(f"Dynamips process logging to {self._stdout_file}")
with open(self._stdout_file, "w", encoding="utf-8") as fd:
self._process = await asyncio.create_subprocess_exec(*self._command,
stdout=fd,
stderr=subprocess.STDOUT,
cwd=self._working_dir,
env=env)
self._process = await asyncio.create_subprocess_exec(
*self._command, stdout=fd, stderr=subprocess.STDOUT, cwd=self._working_dir, env=env
)
log.info(f"Dynamips process started PID={self._process.pid}")
self._started = True
except (OSError, subprocess.SubprocessError) as e:
@@ -159,7 +158,7 @@ class Hypervisor(DynamipsHypervisor):
except OSError as e:
log.error(f"Cannot stop the Dynamips process: {e}")
if self._process.returncode is None:
log.warning(f'Dynamips hypervisor with PID={self._process.pid} is still running')
log.warning(f"Dynamips hypervisor with PID={self._process.pid} is still running")
if self._stdout_file and os.access(self._stdout_file, os.W_OK):
try:
+14 -8
View File
@@ -23,6 +23,7 @@ import asyncio
from ..dynamips_error import DynamipsError
import logging
log = logging.getLogger(__name__)
@@ -130,9 +131,11 @@ 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(
"nio bind_filter {name} {direction} {filter}".format(
name=self._name, direction=dynamips_direction, filter=filter_name
)
)
if direction == "in":
self._input_filter = filter_name
@@ -153,8 +156,9 @@ 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(
"nio unbind_filter {name} {direction}".format(name=self._name, direction=dynamips_direction)
)
if direction == "in":
self._input_filter = None
@@ -187,9 +191,11 @@ 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(
"nio setup_filter {name} {direction} {options}".format(
name=self._name, direction=dynamips_direction, options=options
)
)
if direction == "in":
self._input_filter_options = options
@@ -23,6 +23,7 @@ import uuid
from .nio import NIO
import logging
log = logging.getLogger(__name__)
@@ -38,17 +39,21 @@ class NIOGenericEthernet(NIO):
def __init__(self, hypervisor, ethernet_device):
# create an unique name
name = f'generic_ethernet-{uuid.uuid4()}'
name = f"generic_ethernet-{uuid.uuid4()}"
self._ethernet_device = ethernet_device
super().__init__(name, hypervisor)
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(
"nio create_gen_eth {name} {eth_device}".format(name=self._name, eth_device=self._ethernet_device)
)
log.info("NIO Generic Ethernet {name} created with device {device}".format(name=self._name,
device=self._ethernet_device))
log.info(
"NIO Generic Ethernet {name} created with device {device}".format(
name=self._name, device=self._ethernet_device
)
)
@property
def ethernet_device(self):
@@ -62,5 +67,4 @@ class NIOGenericEthernet(NIO):
def __json__(self):
return {"type": "nio_generic_ethernet",
"ethernet_device": self._ethernet_device}
return {"type": "nio_generic_ethernet", "ethernet_device": self._ethernet_device}
@@ -23,6 +23,7 @@ import uuid
from .nio import NIO
import logging
log = logging.getLogger(__name__)
@@ -37,17 +38,21 @@ class NIOLinuxEthernet(NIO):
def __init__(self, hypervisor, ethernet_device):
# create an unique name
name = f'linux_ethernet-{uuid.uuid4()}'
name = f"linux_ethernet-{uuid.uuid4()}"
self._ethernet_device = ethernet_device
super().__init__(name, hypervisor)
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(
"nio create_linux_eth {name} {eth_device}".format(name=self._name, eth_device=self._ethernet_device)
)
log.info("NIO Linux Ethernet {name} created with device {device}".format(name=self._name,
device=self._ethernet_device))
log.info(
"NIO Linux Ethernet {name} created with device {device}".format(
name=self._name, device=self._ethernet_device
)
)
@property
def ethernet_device(self):
@@ -61,5 +66,4 @@ class NIOLinuxEthernet(NIO):
def __json__(self):
return {"type": "nio_linux_ethernet",
"ethernet_device": self._ethernet_device}
return {"type": "nio_linux_ethernet", "ethernet_device": self._ethernet_device}
+2 -1
View File
@@ -23,6 +23,7 @@ import uuid
from .nio import NIO
import logging
log = logging.getLogger(__name__)
@@ -37,7 +38,7 @@ class NIONull(NIO):
def __init__(self, hypervisor):
# create an unique name
name = f'null-{uuid.uuid4()}'
name = f"null-{uuid.uuid4()}"
super().__init__(name, hypervisor)
async def create(self):
+3 -3
View File
@@ -23,6 +23,7 @@ import uuid
from .nio import NIO
import logging
log = logging.getLogger(__name__)
@@ -38,7 +39,7 @@ class NIOTAP(NIO):
def __init__(self, hypervisor, tap_device):
# create an unique name
name = f'tap-{uuid.uuid4()}'
name = f"tap-{uuid.uuid4()}"
self._tap_device = tap_device
super().__init__(name, hypervisor)
@@ -59,5 +60,4 @@ class NIOTAP(NIO):
def __json__(self):
return {"type": "nio_tap",
"tap_device": self._tap_device}
return {"type": "nio_tap", "tap_device": self._tap_device}
+26 -36
View File
@@ -26,6 +26,7 @@ from .nio import NIO
import logging
log = logging.getLogger(__name__)
@@ -43,7 +44,7 @@ class NIOUDP(NIO):
def __init__(self, node, lport, rhost, rport):
# create an unique name
name = f'udp-{uuid.uuid4()}'
name = f"udp-{uuid.uuid4()}"
self._lport = lport
self._rhost = rhost
self._rport = rport
@@ -57,48 +58,40 @@ 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(
"nio create_udp {name} {lport} {rhost} {rport}".format(
name=self._name, lport=self._lport, rhost=self._rhost, rport=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)
self._bridge_name = f'DYNAMIPS-{self._local_tunnel_lport}-{self._local_tunnel_rport}'
await self._hypervisor.send("nio create_udp {name} {lport} {rhost} {rport}".format(name=self._name,
lport=self._local_tunnel_lport,
rhost='127.0.0.1',
rport=self._local_tunnel_rport))
log.info("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._destination_nio = nio_udp.NIOUDP(self._lport,
self._rhost,
self._rport)
self._destination_nio.filters = self._filters
await self._node.add_ubridge_udp_connection(
self._bridge_name,
self._source_nio,
self._destination_nio
self._bridge_name = f"DYNAMIPS-{self._local_tunnel_lport}-{self._local_tunnel_rport}"
await self._hypervisor.send(
"nio create_udp {name} {lport} {rhost} {rport}".format(
name=self._name, lport=self._local_tunnel_lport, rhost="127.0.0.1", rport=self._local_tunnel_rport
)
)
log.info(
"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._destination_nio = nio_udp.NIOUDP(self._lport, self._rhost, self._rport)
self._destination_nio.filters = self._filters
await self._node.add_ubridge_udp_connection(self._bridge_name, self._source_nio, self._destination_nio)
async def update(self):
self._destination_nio.filters = self._filters
await self._node.update_ubridge_udp_connection(
self._bridge_name,
self._source_nio,
self._destination_nio)
await self._node.update_ubridge_udp_connection(self._bridge_name, self._source_nio, self._destination_nio)
async def close(self):
if self._local_tunnel_lport:
await self._node.ubridge_delete_bridge(self._bridge_name)
self._node.manager.port_manager.release_udp_port(self._local_tunnel_lport, self ._node.project)
self._node.manager.port_manager.release_udp_port(self._local_tunnel_lport, self._node.project)
if self._local_tunnel_rport:
self._node.manager.port_manager.release_udp_port(self._local_tunnel_rport, self._node.project)
self._node.manager.port_manager.release_udp_port(self._lport, self._node.project)
@@ -135,7 +128,4 @@ class NIOUDP(NIO):
def __json__(self):
return {"type": "nio_udp",
"lport": self._lport,
"rport": self._rport,
"rhost": self._rhost}
return {"type": "nio_udp", "lport": self._lport, "rport": self._rport, "rhost": self._rhost}
+13 -10
View File
@@ -23,6 +23,7 @@ import uuid
from .nio import NIO
import logging
log = logging.getLogger(__name__)
@@ -39,20 +40,24 @@ class NIOUNIX(NIO):
def __init__(self, hypervisor, local_file, remote_file):
# create an unique name
name = f'unix-{uuid.uuid4()}'
name = f"unix-{uuid.uuid4()}"
self._local_file = local_file
self._remote_file = remote_file
super().__init__(name, hypervisor)
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(
"nio create_unix {name} {local} {remote}".format(
name=self._name, local=self._local_file, remote=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))
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
)
)
@property
def local_file(self):
@@ -76,6 +81,4 @@ class NIOUNIX(NIO):
def __json__(self):
return {"type": "nio_unix",
"local_file": self._local_file,
"remote_file": self._remote_file}
return {"type": "nio_unix", "local_file": self._local_file, "remote_file": self._remote_file}
+13 -10
View File
@@ -23,6 +23,7 @@ import uuid
from .nio import NIO
import logging
log = logging.getLogger(__name__)
@@ -39,20 +40,24 @@ class NIOVDE(NIO):
def __init__(self, hypervisor, control_file, local_file):
# create an unique name
name = f'vde-{uuid.uuid4()}'
name = f"vde-{uuid.uuid4()}"
self._control_file = control_file
self._local_file = local_file
super().__init__(name, hypervisor)
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(
"nio create_vde {name} {control} {local}".format(
name=self._name, control=self._control_file, local=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(
"NIO VDE {name} created with control={control}, local={local}".format(
name=self._name, control=self._control_file, local=self._local_file
)
)
@property
def control_file(self):
@@ -76,6 +81,4 @@ class NIOVDE(NIO):
def __json__(self):
return {"type": "nio_vde",
"local_file": self._local_file,
"control_file": self._control_file}
return {"type": "nio_vde", "local_file": self._local_file, "control_file": self._control_file}
+153 -112
View File
@@ -27,6 +27,7 @@ from ..nios.nio_udp import NIOUDP
from ..dynamips_error import DynamipsError
import logging
log = logging.getLogger(__name__)
@@ -57,12 +58,14 @@ class ATMSwitch(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):
@@ -82,9 +85,11 @@ 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(
'ATM 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 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(
'ATM switch "{name}" [id={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,37 +195,50 @@ class ATMSwitch(Device):
source_port, source_vpi, source_vci = source
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))
await self.unmap_pvc(source_port, source_vpi, source_vci, destination_port, destination_vpi, destination_vci)
await self.unmap_pvc(destination_port, destination_vpi, destination_vci, source_port, source_vpi, source_vci)
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,
)
)
await self.unmap_pvc(
source_port, source_vpi, source_vci, destination_port, destination_vpi, destination_vci
)
await self.unmap_pvc(
destination_port, destination_vpi, destination_vci, source_port, source_vpi, source_vci
)
else:
# remove the virtual paths mapped with this port/nio
source_port, source_vpi = source
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))
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,
)
)
await self.unmap_vp(source_port, source_vpi, destination_port, destination_vpi)
await self.unmap_vp(destination_port, destination_vpi, source_port, source_vpi)
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(
'ATM 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
@@ -261,30 +280,48 @@ class ATMSwitch(Device):
source_port, source_vpi, source_vci = map(int, match_source_pvc.group(1, 2, 3))
destination_port, destination_vpi, destination_vci = map(int, match_destination_pvc.group(1, 2, 3))
if self.has_port(destination_port):
if (source_port, source_vpi, source_vci) not in self._active_mappings and \
(destination_port, destination_vpi, 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))
await self.map_pvc(source_port, source_vpi, source_vci, destination_port, destination_vpi, destination_vci)
await self.map_pvc(destination_port, destination_vpi, destination_vci, source_port, source_vpi, source_vci)
if (source_port, source_vpi, source_vci) not in self._active_mappings and (
destination_port,
destination_vpi,
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,
)
)
await self.map_pvc(
source_port, source_vpi, source_vci, destination_port, destination_vpi, destination_vci
)
await self.map_pvc(
destination_port, destination_vpi, destination_vci, source_port, source_vpi, source_vci
)
else:
# add the virtual paths
source_port, source_vpi = map(int, source.split(':'))
destination_port, destination_vpi = map(int, destination.split(':'))
source_port, source_vpi = map(int, source.split(":"))
destination_port, destination_vpi = map(int, destination.split(":"))
if self.has_port(destination_port):
if (source_port, source_vpi) not in self._active_mappings and (destination_port, 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))
if (source_port, source_vpi) not in self._active_mappings and (
destination_port,
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,
)
)
await self.map_vp(source_port, source_vpi, destination_port, destination_vpi)
await self.map_vp(destination_port, destination_vpi, source_port, source_vpi)
@@ -307,18 +344,17 @@ 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(
'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
)
)
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))
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
)
)
self._active_mappings[(port1, vpi1)] = (port2, vpi2)
@@ -341,18 +377,17 @@ 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(
'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
)
)
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))
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
)
)
del self._active_mappings[(port1, vpi1)]
@@ -377,22 +412,23 @@ 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(
'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,
)
)
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))
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
)
)
self._active_mappings[(port1, vpi1, vci1)] = (port2, vpi2, vci2)
@@ -417,22 +453,23 @@ 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(
'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,
)
)
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))
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
)
)
del self._active_mappings[(port1, vpi1, vci1)]
async def start_capture(self, port_number, output_file, data_link_type="DLT_ATM_RFC1483"):
@@ -453,9 +490,11 @@ 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(
'ATM 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):
"""
@@ -468,6 +507,8 @@ 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(
'ATM switch "{name}" [{id}]: stopping packet capture on port {port}'.format(
name=self._name, id=self._id, port=port_number
)
)
+3 -2
View File
@@ -56,8 +56,9 @@ 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(
'nio_bridge rename "{name}" "{new_name}"'.format(name=self._name, new_name=new_name)
)
self._name = new_name
+27 -13
View File
@@ -25,6 +25,7 @@ from ..adapters.c1700_mb_1fe import C1700_MB_1FE
from ..adapters.c1700_mb_wic1 import C1700_MB_WIC1
import logging
log = logging.getLogger(__name__)
@@ -47,9 +48,23 @@ class C1700(Router):
1710 is not supported.
"""
def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, aux_type="none", chassis="1720"):
def __init__(
self,
name,
node_id,
project,
manager,
dynamips_id,
console=None,
console_type="telnet",
aux=None,
aux_type="none",
chassis="1720",
):
super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c1700")
super().__init__(
name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c1700"
)
# Set default values for this platform (must be the same as Dynamips)
self._ram = 64
@@ -63,9 +78,7 @@ class C1700(Router):
def __json__(self):
c1700_router_info = {"iomem": self._iomem,
"chassis": self._chassis,
"sparsemem": self._sparsemem}
c1700_router_info = {"iomem": self._iomem, "chassis": self._chassis, "sparsemem": self._sparsemem}
router_info = Router.__json__(self)
router_info.update(c1700_router_info)
@@ -86,7 +99,7 @@ class C1700(Router):
# With 1751 and 1760, WICs in WIC slot 1 show up as in slot 1, not 0
# e.g. s1/0 not s0/2
if self._chassis in ['1751', '1760']:
if self._chassis in ["1751", "1760"]:
self._create_slots(2)
self._slots[1] = C1700_MB_WIC1()
else:
@@ -113,9 +126,9 @@ 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(
'Router "{name}" [{id}]: chassis set to {chassis}'.format(name=self._name, id=self._id, chassis=chassis)
)
self._chassis = chassis
self._setup_chassis()
@@ -139,8 +152,9 @@ 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(
'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
)
)
self._iomem = iomem
+38 -22
View File
@@ -27,6 +27,7 @@ from ..adapters.c2600_mb_1fe import C2600_MB_1FE
from ..adapters.c2600_mb_2fe import C2600_MB_2FE
import logging
log = logging.getLogger(__name__)
@@ -51,20 +52,36 @@ class C2600(Router):
# adapters to insert by default corresponding the
# chosen chassis.
integrated_adapters = {"2610": C2600_MB_1E,
"2611": C2600_MB_2E,
"2620": C2600_MB_1FE,
"2621": C2600_MB_2FE,
"2610XM": C2600_MB_1FE,
"2611XM": C2600_MB_2FE,
"2620XM": C2600_MB_1FE,
"2621XM": C2600_MB_2FE,
"2650XM": C2600_MB_1FE,
"2651XM": C2600_MB_2FE}
integrated_adapters = {
"2610": C2600_MB_1E,
"2611": C2600_MB_2E,
"2620": C2600_MB_1FE,
"2621": C2600_MB_2FE,
"2610XM": C2600_MB_1FE,
"2611XM": C2600_MB_2FE,
"2620XM": C2600_MB_1FE,
"2621XM": C2600_MB_2FE,
"2650XM": C2600_MB_1FE,
"2651XM": C2600_MB_2FE,
}
def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, aux_type="none", chassis="2610"):
def __init__(
self,
name,
node_id,
project,
manager,
dynamips_id,
console=None,
console_type="telnet",
aux=None,
aux_type="none",
chassis="2610",
):
super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c2600")
super().__init__(
name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c2600"
)
# Set default values for this platform (must be the same as Dynamips)
self._ram = 64
@@ -78,9 +95,7 @@ class C2600(Router):
def __json__(self):
c2600_router_info = {"iomem": self._iomem,
"chassis": self._chassis,
"sparsemem": self._sparsemem}
c2600_router_info = {"iomem": self._iomem, "chassis": self._chassis, "sparsemem": self._sparsemem}
router_info = Router.__json__(self)
router_info.update(c2600_router_info)
@@ -123,9 +138,9 @@ 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(
'Router "{name}" [{id}]: chassis set to {chassis}'.format(name=self._name, id=self._id, chassis=chassis)
)
self._chassis = chassis
self._setup_chassis()
@@ -148,8 +163,9 @@ 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(
'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
)
)
self._iomem = iomem
+22 -6
View File
@@ -25,6 +25,7 @@ from ..adapters.gt96100_fe import GT96100_FE
from ..dynamips_error import DynamipsError
import logging
log = logging.getLogger(__name__)
@@ -44,9 +45,23 @@ class C2691(Router):
:param aux_type: auxiliary console type
"""
def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, aux_type="none", chassis=None):
def __init__(
self,
name,
node_id,
project,
manager,
dynamips_id,
console=None,
console_type="telnet",
aux=None,
aux_type="none",
chassis=None,
):
super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c2691")
super().__init__(
name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c2691"
)
# Set default values for this platform (must be the same as Dynamips)
self._ram = 128
@@ -89,8 +104,9 @@ 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(
'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
)
)
self._iomem = iomem
+26 -11
View File
@@ -24,6 +24,7 @@ from .router import Router
from ..adapters.leopard_2fe import Leopard_2FE
import logging
log = logging.getLogger(__name__)
@@ -45,9 +46,23 @@ class C3600(Router):
3620, 3640 or 3660 (default = 3640).
"""
def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, aux_type="none", chassis="3640"):
def __init__(
self,
name,
node_id,
project,
manager,
dynamips_id,
console=None,
console_type="telnet",
aux=None,
aux_type="none",
chassis="3640",
):
super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c3600")
super().__init__(
name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c3600"
)
# Set default values for this platform (must be the same as Dynamips)
self._ram = 128
@@ -60,8 +75,7 @@ class C3600(Router):
def __json__(self):
c3600_router_info = {"iomem": self._iomem,
"chassis": self._chassis}
c3600_router_info = {"iomem": self._iomem, "chassis": self._chassis}
router_info = Router.__json__(self)
router_info.update(c3600_router_info)
@@ -107,9 +121,9 @@ 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(
'Router "{name}" [{id}]: chassis set to {chassis}'.format(name=self._name, id=self._id, chassis=chassis)
)
self._chassis = chassis
self._setup_chassis()
@@ -133,8 +147,9 @@ 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(
'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
)
)
self._iomem = iomem
+22 -6
View File
@@ -25,6 +25,7 @@ from ..adapters.gt96100_fe import GT96100_FE
from ..dynamips_error import DynamipsError
import logging
log = logging.getLogger(__name__)
@@ -44,9 +45,23 @@ class C3725(Router):
:param aux_type: auxiliary console type
"""
def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, aux_type="none", chassis=None):
def __init__(
self,
name,
node_id,
project,
manager,
dynamips_id,
console=None,
console_type="telnet",
aux=None,
aux_type="none",
chassis=None,
):
super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c3725")
super().__init__(
name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c3725"
)
# Set default values for this platform (must be the same as Dynamips)
self._ram = 128
@@ -89,8 +104,9 @@ 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(
'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
)
)
self._iomem = iomem
+22 -6
View File
@@ -25,6 +25,7 @@ from ..adapters.gt96100_fe import GT96100_FE
from ..dynamips_error import DynamipsError
import logging
log = logging.getLogger(__name__)
@@ -44,9 +45,23 @@ class C3745(Router):
:param aux_type: auxiliary console type
"""
def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, aux_type="none", chassis=None):
def __init__(
self,
name,
node_id,
project,
manager,
dynamips_id,
console=None,
console_type="telnet",
aux=None,
aux_type="none",
chassis=None,
):
super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c3745")
super().__init__(
name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c3745"
)
# Set default values for this platform (must be the same as Dynamips)
self._ram = 128
@@ -89,8 +104,9 @@ 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(
'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
)
)
self._iomem = iomem
+59 -30
View File
@@ -27,6 +27,7 @@ from ..adapters.c7200_io_ge_e import C7200_IO_GE_E
from ..dynamips_error import DynamipsError
import logging
log = logging.getLogger(__name__)
@@ -47,9 +48,24 @@ class C7200(Router):
:param npe: Default NPE
"""
def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, aux_type="none", npe="npe-400", chassis=None):
def __init__(
self,
name,
node_id,
project,
manager,
dynamips_id,
console=None,
console_type="telnet",
aux=None,
aux_type="none",
npe="npe-400",
chassis=None,
):
super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c7200")
super().__init__(
name, node_id, project, manager, dynamips_id, console, console_type, aux, aux_type, platform="c7200"
)
# Set default values for this platform (must be the same as Dynamips)
self._ram = 256
@@ -78,10 +94,12 @@ class C7200(Router):
def __json__(self):
c7200_router_info = {"npe": self._npe,
"midplane": self._midplane,
"sensors": self._sensors,
"power_supplies": self._power_supplies}
c7200_router_info = {
"npe": self._npe,
"midplane": self._midplane,
"sensors": self._sensors,
"power_supplies": self._power_supplies,
}
router_info = Router.__json__(self)
router_info.update(c7200_router_info)
@@ -119,15 +137,16 @@ class C7200(Router):
npe-225, npe-300, npe-400 and npe-g2 (PowerPC c7200 only)
"""
if (await self.is_running()):
if await self.is_running():
raise DynamipsError("Cannot change NPE on running 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(
'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
)
)
self._npe = npe
@property
@@ -149,10 +168,11 @@ 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(
'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
)
)
self._midplane = midplane
@property
@@ -179,15 +199,21 @@ 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(
'c7200 set_temp_sensor "{name}" {sensor_id} {temp}'.format(
name=self._name, sensor_id=sensor_id, temp=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]))
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],
)
)
sensor_id += 1
self._sensors = sensors
@@ -212,14 +238,17 @@ 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(
'c7200 set_power_supply "{name}" {power_supply_id} {powered_on}'.format(
name=self._name, power_supply_id=power_supply_id, powered_on=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))
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
)
)
power_supply_id += 1
self._power_supplies = power_supplies
@@ -24,6 +24,7 @@ from ..dynamips_error import DynamipsError
from ...error import NodeError
import logging
log = logging.getLogger(__name__)
@@ -48,19 +49,20 @@ class EthernetHub(Bridge):
# create 8 ports by default
self._ports = []
for port_number in range(0, 8):
self._ports.append({"port_number": port_number,
"name": f"Ethernet{port_number}"})
self._ports.append({"port_number": port_number, "name": f"Ethernet{port_number}"})
else:
self._ports = ports
def __json__(self):
return {"name": self.name,
"usage": self.usage,
"node_id": self.id,
"project_id": self.project.id,
"ports_mapping": self._ports,
"status": "started"}
return {
"name": self.name,
"usage": self.usage,
"node_id": self.id,
"project_id": self.project.id,
"ports_mapping": self._ports,
"status": "started",
}
@property
def ports_mapping(self):
@@ -107,7 +109,7 @@ class EthernetHub(Bridge):
return self._mappings
async def delete(self):
return (await self.close())
return await self.close()
async def close(self):
"""
@@ -144,10 +146,11 @@ 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(
'Ethernet hub "{name}" [{id}]: NIO {nio} bound to port {port}'.format(
name=self._name, id=self._id, nio=nio, port=port_number
)
)
self._mappings[port_number] = nio
async def remove_nio(self, port_number):
@@ -168,10 +171,11 @@ 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(
'Ethernet hub "{name}" [{id}]: NIO {nio} removed from port {port}'.format(
name=self._name, id=self._id, nio=nio, port=port_number
)
)
del self._mappings[port_number]
return nio
@@ -213,9 +217,11 @@ 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(
'Ethernet hub "{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):
"""
@@ -228,6 +234,8 @@ 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(
'Ethernet hub "{name}" [{id}]: stopping packet capture on port {port}'.format(
name=self._name, id=self._id, port=port_number
)
)
@@ -21,7 +21,8 @@ http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L558
import asyncio
from gns3server.utils import parse_version
#from gns3server.utils.asyncio.embed_shell import EmbedShell, create_telnet_shell
# from gns3server.utils.asyncio.embed_shell import EmbedShell, create_telnet_shell
from .device import Device
@@ -30,6 +31,7 @@ from ..dynamips_error import DynamipsError
from ...error import NodeError
import logging
log = logging.getLogger(__name__)
@@ -84,8 +86,8 @@ class EthernetSwitch(Device):
self._nios = {}
self._mappings = {}
self._telnet_console = None
#self._telnet_shell = None
#self._telnet_server = None
# self._telnet_shell = None
# self._telnet_server = None
self._console = console
self._console_type = console_type
@@ -101,23 +103,24 @@ class EthernetSwitch(Device):
# create 8 ports by default
self._ports = []
for port_number in range(0, 8):
self._ports.append({"port_number": port_number,
"name": f"Ethernet{port_number}",
"type": "access",
"vlan": 1})
self._ports.append(
{"port_number": port_number, "name": f"Ethernet{port_number}", "type": "access", "vlan": 1}
)
else:
self._ports = ports
def __json__(self):
ethernet_switch_info = {"name": self.name,
"usage": self.usage,
"console": self.console,
"console_type": self.console_type,
"node_id": self.id,
"project_id": self.project.id,
"ports_mapping": self._ports,
"status": "started"}
ethernet_switch_info = {
"name": self.name,
"usage": self.usage,
"console": self.console,
"console_type": self.console_type,
"node_id": self.id,
"project_id": self.project.id,
"ports_mapping": self._ports,
"status": "started",
}
return ethernet_switch_info
@@ -138,8 +141,10 @@ class EthernetSwitch(Device):
if self._console_type != console_type:
if console_type == "telnet":
self.project.emit("log.warning", {
"message": f'"{self._name}": Telnet access for switches is not available in this version of GNS3'})
self.project.emit(
"log.warning",
{"message": f'"{self._name}": Telnet access for switches is not available in this version of GNS3'},
)
self._console_type = console_type
@property
@@ -186,15 +191,18 @@ class EthernetSwitch(Device):
await self._hypervisor.send(f'ethsw create "{self._name}"')
log.info(f'Ethernet switch "{self._name}" [{self._id}] has been created')
#self._telnet_shell = EthernetSwitchConsole(self)
#self._telnet_shell.prompt = self._name + '> '
#self._telnet = create_telnet_shell(self._telnet_shell)
#try:
# self._telnet_shell = EthernetSwitchConsole(self)
# self._telnet_shell.prompt = self._name + '> '
# self._telnet = create_telnet_shell(self._telnet_shell)
# try:
# self._telnet_server = (await asyncio.start_server(self._telnet.run, self._manager.port_manager.console_host, self.console))
#except OSError as e:
# except OSError as e:
# self.project.emit("log.warning", {"message": "Could not start Telnet server on socket {}:{}: {}".format(self._manager.port_manager.console_host, self.console, e)})
if self._console_type == "telnet":
self.project.emit("log.warning", {"message": f'"{self._name}": Telnet access for switches is not available in this version of GNS3'})
self.project.emit(
"log.warning",
{"message": f'"{self._name}": Telnet access for switches is not available in this version of GNS3'},
)
self._hypervisor.devices.append(self)
async def set_name(self, new_name):
@@ -205,9 +213,11 @@ 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(
'Ethernet switch "{name}" [{id}]: renamed to "{new_name}"'.format(
name=self._name, id=self._id, new_name=new_name
)
)
self._name = new_name
@property
@@ -231,15 +241,15 @@ class EthernetSwitch(Device):
return self._mappings
async def delete(self):
return (await self.close())
return await self.close()
async def close(self):
"""
Deletes this Ethernet switch.
"""
#await self._telnet.close()
#if self._telnet_server:
# await self._telnet.close()
# if self._telnet_server:
# self._telnet_server.close()
for nio in self._nios.values():
@@ -272,10 +282,11 @@ 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(
'Ethernet 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
for port_settings in self._ports:
if port_settings["port_number"] == port_number:
@@ -301,10 +312,11 @@ 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(
'Ethernet 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]
if port_number in self._mappings:
@@ -358,14 +370,15 @@ 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(
'ethsw set_access_port "{name}" {nio} {vlan_id}'.format(name=self._name, nio=nio, vlan_id=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))
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
)
)
self._mappings[port_number] = ("access", vlan_id)
async def set_dot1q_port(self, port_number, native_vlan):
@@ -380,14 +393,17 @@ 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(
'ethsw set_dot1q_port "{name}" {nio} {native_vlan}'.format(
name=self._name, nio=nio, native_vlan=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))
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
)
)
self._mappings[port_number] = ("dot1q", native_vlan)
@@ -403,19 +419,22 @@ class EthernetSwitch(Device):
raise DynamipsError(f"Port {port_number} is not allocated")
nio = self._nios[port_number]
if ethertype != "0x8100" and parse_version(self.hypervisor.version) < parse_version('0.2.16'):
raise DynamipsError(f"Dynamips version required is >= 0.2.16 to change the default QinQ Ethernet type, detected version is {self.hypervisor.version}")
if ethertype != "0x8100" and parse_version(self.hypervisor.version) < parse_version("0.2.16"):
raise DynamipsError(
f"Dynamips version required is >= 0.2.16 to change the default QinQ Ethernet type, detected version is {self.hypervisor.version}"
)
await self._hypervisor.send('ethsw set_qinq_port "{name}" {nio} {outer_vlan} {ethertype}'.format(name=self._name,
nio=nio,
outer_vlan=outer_vlan,
ethertype=ethertype if ethertype != "0x8100" else ""))
await self._hypervisor.send(
'ethsw set_qinq_port "{name}" {nio} {outer_vlan} {ethertype}'.format(
name=self._name, nio=nio, outer_vlan=outer_vlan, ethertype=ethertype if ethertype != "0x8100" else ""
)
)
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))
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
)
)
self._mappings[port_number] = ("qinq", outer_vlan, ethertype)
async def get_mac_addr_table(self):
@@ -453,9 +472,11 @@ 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(
'Ethernet 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):
"""
@@ -468,6 +489,8 @@ 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(
'Ethernet switch "{name}" [{id}]: stopping packet capture on port {port}'.format(
name=self._name, id=self._id, port=port_number
)
)
@@ -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
)
)
File diff suppressed because it is too large. Load diff