mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Dynamips devices support (packet capture to complete).
This commit is contained in:
1 parent
4f38d96522
commit
f99e834c37
18 files changed
+971
-539
No files matched your search
@@ -21,6 +21,7 @@ http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L593
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import re
|
||||
|
||||
from .device import Device
|
||||
from ..dynamips_error import DynamipsError
|
||||
@@ -34,17 +35,24 @@ class ATMSwitch(Device):
|
||||
Dynamips ATM switch.
|
||||
|
||||
:param name: name for this switch
|
||||
:param node_id: Node instance identifier
|
||||
:param device_id: Device instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
"""
|
||||
|
||||
def __init__(self, name, node_id, project, manager, hypervisor=None):
|
||||
def __init__(self, name, device_id, project, manager, hypervisor=None):
|
||||
|
||||
super().__init__(name, node_id, project, manager)
|
||||
super().__init__(name, device_id, project, manager, hypervisor)
|
||||
self._nios = {}
|
||||
self._mapping = {}
|
||||
self._mappings = {}
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"name": self.name,
|
||||
"device_id": self.id,
|
||||
"project_id": self.project.id,
|
||||
"mappings": self._mappings}
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
@@ -82,14 +90,14 @@ class ATMSwitch(Device):
|
||||
return self._nios
|
||||
|
||||
@property
|
||||
def mapping(self):
|
||||
def mappings(self):
|
||||
"""
|
||||
Returns port mapping
|
||||
Returns port mappings
|
||||
|
||||
:returns: mapping list
|
||||
:returns: mappings list
|
||||
"""
|
||||
|
||||
return self._mapping
|
||||
return self._mappings
|
||||
|
||||
@asyncio.coroutine
|
||||
def delete(self):
|
||||
@@ -97,10 +105,14 @@ class ATMSwitch(Device):
|
||||
Deletes this ATM switch.
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send('atmsw delete "{}"'.format(self._name))
|
||||
log.info('ATM switch "{name}" [{id}] has been deleted'.format(name=self._name, id=self._id))
|
||||
try:
|
||||
yield from self._hypervisor.send('atmsw delete "{}"'.format(self._name))
|
||||
log.info('ATM switch "{name}" [{id}] has been deleted'.format(name=self._name, id=self._id))
|
||||
except DynamipsError:
|
||||
log.debug("Could not properly delete ATM switch {}".format(self._name))
|
||||
self._hypervisor.devices.remove(self)
|
||||
self._instances.remove(self._id)
|
||||
if self._hypervisor and not self._hypervisor.devices:
|
||||
yield from self.hypervisor.stop()
|
||||
|
||||
def has_port(self, port):
|
||||
"""
|
||||
@@ -150,6 +162,36 @@ class ATMSwitch(Device):
|
||||
del self._nios[port_number]
|
||||
return nio
|
||||
|
||||
@asyncio.coroutine
|
||||
def set_mappings(self, mappings):
|
||||
"""
|
||||
Applies VC mappings
|
||||
|
||||
:param mappings: mappings (dict)
|
||||
"""
|
||||
|
||||
pvc_entry = re.compile(r"""^([0-9]*):([0-9]*):([0-9]*)$""")
|
||||
for source, destination in mappings.items():
|
||||
match_source_pvc = pvc_entry.search(source)
|
||||
match_destination_pvc = pvc_entry.search(destination)
|
||||
if match_source_pvc and match_destination_pvc:
|
||||
# add the virtual channels
|
||||
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.mapping and \
|
||||
(destination_port, destination_vpi, destination_vci) not in self.mappings:
|
||||
yield from self.map_pvc(source_port, source_vpi, source_vci, destination_port, destination_vpi, destination_vci)
|
||||
yield from 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(':'))
|
||||
if self.has_port(destination_port):
|
||||
if (source_port, source_vpi) not in self.mappings and (destination_port, destination_vpi) not in self.mappings:
|
||||
yield from self.map_vp(source_port, source_vpi, destination_port, destination_vpi)
|
||||
yield from self.map_vp(destination_port, destination_vpi, source_port, source_vpi)
|
||||
|
||||
@asyncio.coroutine
|
||||
def map_vp(self, port1, vpi1, port2, vpi2):
|
||||
"""
|
||||
@@ -183,7 +225,7 @@ class ATMSwitch(Device):
|
||||
port2=port2,
|
||||
vpi2=vpi2))
|
||||
|
||||
self._mapping[(port1, vpi1)] = (port2, vpi2)
|
||||
self._mappings[(port1, vpi1)] = (port2, vpi2)
|
||||
|
||||
@asyncio.coroutine
|
||||
def unmap_vp(self, port1, vpi1, port2, vpi2):
|
||||
@@ -218,7 +260,7 @@ class ATMSwitch(Device):
|
||||
port2=port2,
|
||||
vpi2=vpi2))
|
||||
|
||||
del self._mapping[(port1, vpi1)]
|
||||
del self._mappings[(port1, vpi1)]
|
||||
|
||||
@asyncio.coroutine
|
||||
def map_pvc(self, port1, vpi1, vci1, port2, vpi2, vci2):
|
||||
@@ -259,7 +301,7 @@ class ATMSwitch(Device):
|
||||
vpi2=vpi2,
|
||||
vci2=vci2))
|
||||
|
||||
self._mapping[(port1, vpi1, vci1)] = (port2, vpi2, vci2)
|
||||
self._mappings[(port1, vpi1, vci1)] = (port2, vpi2, vci2)
|
||||
|
||||
@asyncio.coroutine
|
||||
def unmap_pvc(self, port1, vpi1, vci1, port2, vpi2, vci2):
|
||||
@@ -299,7 +341,7 @@ class ATMSwitch(Device):
|
||||
port2=port2,
|
||||
vpi2=vpi2,
|
||||
vci2=vci2))
|
||||
del self._mapping[(port1, vpi1, vci1)]
|
||||
del self._mappings[(port1, vpi1, vci1)]
|
||||
|
||||
@asyncio.coroutine
|
||||
def start_capture(self, port_number, output_file, data_link_type="DLT_ATM_RFC1483"):
|
||||
|
||||
@@ -78,8 +78,8 @@ class Bridge(Device):
|
||||
Deletes this bridge.
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send('nio_bridge delete "{}"'.format(self._name))
|
||||
self._hypervisor.devices.remove(self)
|
||||
yield from self._hypervisor.send('nio_bridge delete "{}"'.format(self._name))
|
||||
|
||||
@asyncio.coroutine
|
||||
def add_nio(self, nio):
|
||||
|
||||
@@ -16,23 +16,23 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from ...base_vm import BaseVM
|
||||
|
||||
|
||||
class Device(BaseVM):
|
||||
class Device:
|
||||
"""
|
||||
Base device for switches and hubs
|
||||
|
||||
:param name: name for this bridge
|
||||
:param vm_id: Node instance identifier
|
||||
:param name: name for this device
|
||||
:param device_id: Device instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param manager: Parent manager
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
"""
|
||||
|
||||
def __init__(self, name, node_id, project, manager, hypervisor=None):
|
||||
def __init__(self, name, device_id, project, manager, hypervisor=None):
|
||||
|
||||
super().__init__(name, node_id, project, manager)
|
||||
self._name = name
|
||||
self._id = device_id
|
||||
self._project = project
|
||||
self._manager = manager
|
||||
self._hypervisor = hypervisor
|
||||
|
||||
@property
|
||||
@@ -45,10 +45,59 @@ class Device(BaseVM):
|
||||
|
||||
return self._hypervisor
|
||||
|
||||
def start(self):
|
||||
@property
|
||||
def project(self):
|
||||
"""
|
||||
Returns the device current project.
|
||||
|
||||
pass # Dynamips switches and hubs are always on
|
||||
:returns: Project instance.
|
||||
"""
|
||||
|
||||
def stop(self):
|
||||
return self._project
|
||||
|
||||
pass # Dynamips switches and hubs are always on
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
Returns the name for this device.
|
||||
|
||||
:returns: name
|
||||
"""
|
||||
|
||||
return self._name
|
||||
|
||||
@name.setter
|
||||
def name(self, new_name):
|
||||
"""
|
||||
Sets the name of this VM.
|
||||
|
||||
:param new_name: name
|
||||
"""
|
||||
|
||||
self._name = new_name
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
Returns the ID for this device.
|
||||
|
||||
:returns: device identifier (string)
|
||||
"""
|
||||
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def manager(self):
|
||||
"""
|
||||
Returns the manager for this device.
|
||||
|
||||
:returns: instance of manager
|
||||
"""
|
||||
|
||||
return self._manager
|
||||
|
||||
def create(self):
|
||||
"""
|
||||
Creates the device.
|
||||
"""
|
||||
|
||||
raise NotImplementedError
|
||||
@@ -33,32 +33,38 @@ class EthernetHub(Bridge):
|
||||
Dynamips Ethernet hub (based on Bridge)
|
||||
|
||||
:param name: name for this hub
|
||||
:param node_id: Node instance identifier
|
||||
:param device_id: Device instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
"""
|
||||
|
||||
def __init__(self, name, node_id, project, manager, hypervisor=None):
|
||||
def __init__(self, name, device_id, project, manager, hypervisor=None):
|
||||
|
||||
Bridge.__init__(self, name, node_id, project, manager, hypervisor)
|
||||
self._mapping = {}
|
||||
Bridge.__init__(self, name, device_id, project, manager, hypervisor)
|
||||
self._mappings = {}
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"name": self.name,
|
||||
"device_id": self.id,
|
||||
"project_id": self.project.id}
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
yield from Bridge.create()
|
||||
yield from Bridge.create(self)
|
||||
log.info('Ethernet hub "{name}" [{id}] has been created'.format(name=self._name, id=self._id))
|
||||
|
||||
@property
|
||||
def mapping(self):
|
||||
def mappings(self):
|
||||
"""
|
||||
Returns port mapping
|
||||
Returns port mappings
|
||||
|
||||
:returns: mapping list
|
||||
:returns: mappings list
|
||||
"""
|
||||
|
||||
return self._mapping
|
||||
return self._mappings
|
||||
|
||||
@asyncio.coroutine
|
||||
def delete(self):
|
||||
@@ -66,9 +72,13 @@ class EthernetHub(Bridge):
|
||||
Deletes this hub.
|
||||
"""
|
||||
|
||||
yield from Bridge.delete(self)
|
||||
log.info('Ethernet hub "{name}" [{id}] has been deleted'.format(name=self._name, id=self._id))
|
||||
self._instances.remove(self._id)
|
||||
try:
|
||||
yield from Bridge.delete(self)
|
||||
log.info('Ethernet hub "{name}" [{id}] has been deleted'.format(name=self._name, id=self._id))
|
||||
except DynamipsError:
|
||||
log.debug("Could not properly delete Ethernet hub {}".format(self._name))
|
||||
if self._hypervisor and not self._hypervisor.devices:
|
||||
yield from self.hypervisor.stop()
|
||||
|
||||
@asyncio.coroutine
|
||||
def add_nio(self, nio, port_number):
|
||||
@@ -79,7 +89,7 @@ class EthernetHub(Bridge):
|
||||
:param port_number: port to allocate for the NIO
|
||||
"""
|
||||
|
||||
if port_number in self._mapping:
|
||||
if port_number in self._mappings:
|
||||
raise DynamipsError("Port {} isn't free".format(port_number))
|
||||
|
||||
yield from Bridge.add_nio(self, nio)
|
||||
@@ -88,7 +98,7 @@ class EthernetHub(Bridge):
|
||||
id=self._id,
|
||||
nio=nio,
|
||||
port=port_number))
|
||||
self._mapping[port_number] = nio
|
||||
self._mappings[port_number] = nio
|
||||
|
||||
@asyncio.coroutine
|
||||
def remove_nio(self, port_number):
|
||||
@@ -100,10 +110,10 @@ class EthernetHub(Bridge):
|
||||
:returns: the NIO that was bound to the allocated port
|
||||
"""
|
||||
|
||||
if port_number not in self._mapping:
|
||||
if port_number not in self._mappings:
|
||||
raise DynamipsError("Port {} is not allocated".format(port_number))
|
||||
|
||||
nio = self._mapping[port_number]
|
||||
nio = self._mappings[port_number]
|
||||
yield from Bridge.remove_nio(self, nio)
|
||||
|
||||
log.info('Ethernet switch "{name}" [{id}]: NIO {nio} removed from port {port}'.format(name=self._name,
|
||||
@@ -111,7 +121,7 @@ class EthernetHub(Bridge):
|
||||
nio=nio,
|
||||
port=port_number))
|
||||
|
||||
del self._mapping[port_number]
|
||||
del self._mappings[port_number]
|
||||
return nio
|
||||
|
||||
@asyncio.coroutine
|
||||
@@ -124,10 +134,10 @@ class EthernetHub(Bridge):
|
||||
:param data_link_type: PCAP data link type (DLT_*), default is DLT_EN10MB
|
||||
"""
|
||||
|
||||
if port_number not in self._mapping:
|
||||
if port_number not in self._mappings:
|
||||
raise DynamipsError("Port {} is not allocated".format(port_number))
|
||||
|
||||
nio = self._mapping[port_number]
|
||||
nio = self._mappings[port_number]
|
||||
|
||||
data_link_type = data_link_type.lower()
|
||||
if data_link_type.startswith("dlt_"):
|
||||
@@ -151,10 +161,10 @@ class EthernetHub(Bridge):
|
||||
:param port_number: allocated port number
|
||||
"""
|
||||
|
||||
if port_number not in self._mapping:
|
||||
if port_number not in self._mappings:
|
||||
raise DynamipsError("Port {} is not allocated".format(port_number))
|
||||
|
||||
nio = self._mapping[port_number]
|
||||
nio = self._mappings[port_number]
|
||||
yield from nio.unbind_filter("both")
|
||||
log.info('Ethernet hub "{name}" [{id}]: stopping packet capture on {port}'.format(name=self._name,
|
||||
id=self._id,
|
||||
|
||||
@@ -35,17 +35,32 @@ class EthernetSwitch(Device):
|
||||
Dynamips Ethernet switch.
|
||||
|
||||
:param name: name for this switch
|
||||
:param node_id: Node instance identifier
|
||||
:param device_id: Device instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
"""
|
||||
|
||||
def __init__(self, name, node_id, project, manager, hypervisor=None):
|
||||
def __init__(self, name, device_id, project, manager, hypervisor=None):
|
||||
|
||||
super().__init__(name, node_id, project, manager, hypervisor)
|
||||
super().__init__(name, device_id, project, manager, hypervisor)
|
||||
self._nios = {}
|
||||
self._mapping = {}
|
||||
self._mappings = {}
|
||||
|
||||
def __json__(self):
|
||||
|
||||
ethernet_switch_info = {"name": self.name,
|
||||
"device_id": self.id,
|
||||
"project_id": self.project.id}
|
||||
|
||||
ports = []
|
||||
for port_number, settings in self._mappings.items():
|
||||
ports.append({"port": port_number,
|
||||
"type": settings[0],
|
||||
"vlan": settings[1]})
|
||||
|
||||
ethernet_switch_info["ports"] = ports
|
||||
return ethernet_switch_info
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
@@ -82,14 +97,14 @@ class EthernetSwitch(Device):
|
||||
return self._nios
|
||||
|
||||
@property
|
||||
def mapping(self):
|
||||
def mappings(self):
|
||||
"""
|
||||
Returns port mapping
|
||||
Returns port mappings
|
||||
|
||||
:returns: mapping list
|
||||
:returns: mappings list
|
||||
"""
|
||||
|
||||
return self._mapping
|
||||
return self._mappings
|
||||
|
||||
@asyncio.coroutine
|
||||
def delete(self):
|
||||
@@ -97,10 +112,14 @@ class EthernetSwitch(Device):
|
||||
Deletes this Ethernet switch.
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send('ethsw delete "{}"'.format(self._name))
|
||||
log.info('Ethernet switch "{name}" [{id}] has been deleted'.format(name=self._name, id=self._id))
|
||||
try:
|
||||
yield from self._hypervisor.send('ethsw delete "{}"'.format(self._name))
|
||||
log.info('Ethernet switch "{name}" [{id}] has been deleted'.format(name=self._name, id=self._id))
|
||||
except DynamipsError:
|
||||
log.debug("Could not properly delete Ethernet switch {}".format(self._name))
|
||||
self._hypervisor.devices.remove(self)
|
||||
self._instances.remove(self._id)
|
||||
if self._hypervisor and not self._hypervisor.devices:
|
||||
yield from self.hypervisor.stop()
|
||||
|
||||
@asyncio.coroutine
|
||||
def add_nio(self, nio, port_number):
|
||||
@@ -144,11 +163,27 @@ class EthernetSwitch(Device):
|
||||
port=port_number))
|
||||
|
||||
del self._nios[port_number]
|
||||
if port_number in self._mapping:
|
||||
del self._mapping[port_number]
|
||||
if port_number in self._mappings:
|
||||
del self._mappings[port_number]
|
||||
|
||||
return nio
|
||||
|
||||
@asyncio.coroutine
|
||||
def set_port_settings(self, port_number, settings):
|
||||
"""
|
||||
Applies port settings to a specific port.
|
||||
|
||||
:param port_number: port number to set the settings
|
||||
:param settings: port settings
|
||||
"""
|
||||
|
||||
if settings["type"] == "access":
|
||||
yield from self.set_access_port(port_number, settings["vlan"])
|
||||
elif settings["type"] == "dot1q":
|
||||
yield from self.set_dot1q_port(port_number, settings["vlan"])
|
||||
elif settings["type"] == "qinq":
|
||||
yield from self.set_qinq_port(port_number, settings["vlan"])
|
||||
|
||||
@asyncio.coroutine
|
||||
def set_access_port(self, port_number, vlan_id):
|
||||
"""
|
||||
@@ -170,7 +205,7 @@ class EthernetSwitch(Device):
|
||||
id=self._id,
|
||||
port=port_number,
|
||||
vlan_id=vlan_id))
|
||||
self._mapping[port_number] = ("access", vlan_id)
|
||||
self._mappings[port_number] = ("access", vlan_id)
|
||||
|
||||
@asyncio.coroutine
|
||||
def set_dot1q_port(self, port_number, native_vlan):
|
||||
@@ -194,7 +229,7 @@ class EthernetSwitch(Device):
|
||||
port=port_number,
|
||||
vlan_id=native_vlan))
|
||||
|
||||
self._mapping[port_number] = ("dot1q", native_vlan)
|
||||
self._mappings[port_number] = ("dot1q", native_vlan)
|
||||
|
||||
@asyncio.coroutine
|
||||
def set_qinq_port(self, port_number, outer_vlan):
|
||||
@@ -217,7 +252,7 @@ class EthernetSwitch(Device):
|
||||
id=self._id,
|
||||
port=port_number,
|
||||
vlan_id=outer_vlan))
|
||||
self._mapping[port_number] = ("qinq", outer_vlan)
|
||||
self._mappings[port_number] = ("qinq", outer_vlan)
|
||||
|
||||
@asyncio.coroutine
|
||||
def get_mac_addr_table(self):
|
||||
|
||||
@@ -34,17 +34,24 @@ class FrameRelaySwitch(Device):
|
||||
Dynamips Frame Relay switch.
|
||||
|
||||
:param name: name for this switch
|
||||
:param node_id: Node instance identifier
|
||||
:param device_id: Device instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
"""
|
||||
|
||||
def __init__(self, name, node_id, project, manager, hypervisor=None):
|
||||
def __init__(self, name, device_id, project, manager, hypervisor=None):
|
||||
|
||||
super().__init__(name, node_id, project, manager, hypervisor)
|
||||
super().__init__(name, device_id, project, manager, hypervisor)
|
||||
self._nios = {}
|
||||
self._mapping = {}
|
||||
self._mappings = {}
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"name": self.name,
|
||||
"device_id": self.id,
|
||||
"project_id": self.project.id,
|
||||
"mappings": self._mappings}
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
@@ -81,14 +88,14 @@ class FrameRelaySwitch(Device):
|
||||
return self._nios
|
||||
|
||||
@property
|
||||
def mapping(self):
|
||||
def mappings(self):
|
||||
"""
|
||||
Returns port mapping
|
||||
Returns port mappings
|
||||
|
||||
:returns: mapping list
|
||||
:returns: mappings list
|
||||
"""
|
||||
|
||||
return self._mapping
|
||||
return self._mappings
|
||||
|
||||
@asyncio.coroutine
|
||||
def delete(self):
|
||||
@@ -96,10 +103,14 @@ class FrameRelaySwitch(Device):
|
||||
Deletes this Frame Relay switch.
|
||||
"""
|
||||
|
||||
yield from self._hypervisor.send('frsw delete "{}"'.format(self._name))
|
||||
log.info('Frame Relay switch "{name}" [{id}] has been deleted'.format(name=self._name, id=self._id))
|
||||
try:
|
||||
yield from self._hypervisor.send('frsw delete "{}"'.format(self._name))
|
||||
log.info('Frame Relay switch "{name}" [{id}] has been deleted'.format(name=self._name, id=self._id))
|
||||
except DynamipsError:
|
||||
log.debug("Could not properly delete Frame relay switch {}".format(self._name))
|
||||
self._hypervisor.devices.remove(self)
|
||||
self._instances.remove(self._id)
|
||||
if self._hypervisor and not self._hypervisor.devices:
|
||||
yield from self.hypervisor.stop()
|
||||
|
||||
def has_port(self, port):
|
||||
"""
|
||||
@@ -151,6 +162,22 @@ class FrameRelaySwitch(Device):
|
||||
del self._nios[port_number]
|
||||
return nio
|
||||
|
||||
@asyncio.coroutine
|
||||
def set_mappings(self, mappings):
|
||||
"""
|
||||
Applies VC mappings
|
||||
|
||||
:param mappings: mappings (dict)
|
||||
"""
|
||||
|
||||
for source, destination in mappings.items():
|
||||
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.mappings and (destination_port, destination_dlci) not in self.mappings:
|
||||
yield from self.map_vc(source_port, source_dlci, destination_port, destination_dlci)
|
||||
yield from self.map_vc(destination_port, destination_dlci, source_port, source_dlci)
|
||||
|
||||
@asyncio.coroutine
|
||||
def map_vc(self, port1, dlci1, port2, dlci2):
|
||||
"""
|
||||
@@ -184,7 +211,7 @@ class FrameRelaySwitch(Device):
|
||||
port2=port2,
|
||||
dlci2=dlci2))
|
||||
|
||||
self._mapping[(port1, dlci1)] = (port2, dlci2)
|
||||
self._mappings[(port1, dlci1)] = (port2, dlci2)
|
||||
|
||||
@asyncio.coroutine
|
||||
def unmap_vc(self, port1, dlci1, port2, dlci2):
|
||||
@@ -218,7 +245,7 @@ class FrameRelaySwitch(Device):
|
||||
dlci1=dlci1,
|
||||
port2=port2,
|
||||
dlci2=dlci2))
|
||||
del self._mapping[(port1, dlci1)]
|
||||
del self._mappings[(port1, dlci1)]
|
||||
|
||||
@asyncio.coroutine
|
||||
def start_capture(self, port_number, output_file, data_link_type="DLT_FRELAY"):
|
||||
|
||||
@@ -294,8 +294,12 @@ class Router(BaseVM):
|
||||
# router is already closed
|
||||
return
|
||||
|
||||
if self._hypervisor:
|
||||
yield from self.stop()
|
||||
self._hypervisor.devices.remove(self)
|
||||
if self._hypervisor and not self._hypervisor.devices:
|
||||
try:
|
||||
yield from self.stop()
|
||||
except DynamipsError:
|
||||
pass
|
||||
yield from self.hypervisor.stop()
|
||||
|
||||
if self._console:
|
||||
|
||||
Reference in new issue
Block a user