mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-01 04:38:12 +00:00
Explicitly delete Dynamips NIOs and unmap VCs for ATM and Frame-Relay switches.
This commit is contained in:
parent
de5e8f852d
commit
78bc6e29a8
@ -181,10 +181,8 @@ class DynamipsDeviceHandler:
|
||||
dynamips_manager = Dynamips.instance()
|
||||
device = dynamips_manager.get_device(request.match_info["device_id"], project_id=request.match_info["project_id"])
|
||||
port_number = int(request.match_info["port_number"])
|
||||
if asyncio.iscoroutinefunction(device.remove_nio):
|
||||
yield from device.remove_nio(port_number)
|
||||
else:
|
||||
device.remove_nio(port_number)
|
||||
nio = yield from device.remove_nio(port_number)
|
||||
yield from nio.delete()
|
||||
response.set_status(204)
|
||||
|
||||
@Route.post(
|
||||
|
@ -290,7 +290,8 @@ class DynamipsVMHandler:
|
||||
vm = dynamips_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
|
||||
slot_number = int(request.match_info["adapter_number"])
|
||||
port_number = int(request.match_info["port_number"])
|
||||
yield from vm.slot_remove_nio_binding(slot_number, port_number)
|
||||
nio = yield from vm.slot_remove_nio_binding(slot_number, port_number)
|
||||
yield from nio.delete()
|
||||
response.set_status(204)
|
||||
|
||||
@Route.post(
|
||||
|
@ -150,6 +150,7 @@ class ATMSwitch(Device):
|
||||
|
||||
self._nios[port_number] = nio
|
||||
|
||||
@asyncio.coroutine
|
||||
def remove_nio(self, port_number):
|
||||
"""
|
||||
Removes the specified NIO as member of this ATM switch.
|
||||
@ -160,6 +161,23 @@ class ATMSwitch(Device):
|
||||
if port_number not in self._nios:
|
||||
raise DynamipsError("Port {} is not allocated".format(port_number))
|
||||
|
||||
# remove VCs mapped with the port
|
||||
for source, destination in self._mappings.copy().items():
|
||||
if len(source) == 3 and len(destination) == 3:
|
||||
# remove the virtual channels mapped with this port/nio
|
||||
source_port, source_vpi, source_vci = source
|
||||
destination_port, destination_vpi, destination_vci = destination
|
||||
if port_number == source_port:
|
||||
yield from self.unmap_pvc(source_port, source_vpi, source_vci, destination_port, destination_vpi, destination_vci)
|
||||
yield from 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:
|
||||
yield from self.unmap_vp(source_port, source_vpi, destination_port, destination_vpi)
|
||||
yield from 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)
|
||||
|
@ -149,6 +149,7 @@ class FrameRelaySwitch(Device):
|
||||
|
||||
self._nios[port_number] = nio
|
||||
|
||||
@asyncio.coroutine
|
||||
def remove_nio(self, port_number):
|
||||
"""
|
||||
Removes the specified NIO as member of this Frame Relay switch.
|
||||
@ -161,6 +162,14 @@ class FrameRelaySwitch(Device):
|
||||
if port_number not in self._nios:
|
||||
raise DynamipsError("Port {} is not allocated".format(port_number))
|
||||
|
||||
# remove VCs mapped with the port
|
||||
for source, destination in self._mappings.copy().items():
|
||||
source_port, source_dlci = source
|
||||
destination_port, destination_dlci = destination
|
||||
if port_number == source_port:
|
||||
yield from self.unmap_vc(source_port, source_dlci, destination_port, destination_dlci)
|
||||
yield from self.unmap_vc(destination_port, destination_dlci, source_port, source_dlci)
|
||||
|
||||
nio = self._nios[port_number]
|
||||
if isinstance(nio, NIOUDP):
|
||||
self.manager.port_manager.release_udp_port(nio.lport, self._project)
|
||||
|
@ -172,14 +172,6 @@ class Router(BaseVM):
|
||||
|
||||
return router_info
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
"""
|
||||
Resets the instance count and the allocated instances list.
|
||||
"""
|
||||
|
||||
cls._dynamips_ids.clear()
|
||||
|
||||
@property
|
||||
def dynamips_id(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user