1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-12 19:38:57 +00:00

Fixes small issues when deleting Dynamips devices.

This commit is contained in:
Jeremy 2015-02-25 11:52:52 -07:00
parent f12d3f07f7
commit 349d9d4540
5 changed files with 11 additions and 6 deletions

View File

@ -116,7 +116,8 @@ class ATMSwitch(Device):
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)
if self._hypervisor and self in self._hypervisor.devices:
self._hypervisor.devices.remove(self)
if self._hypervisor and not self._hypervisor.devices:
yield from self.hypervisor.stop()

View File

@ -80,8 +80,10 @@ class Bridge(Device):
Deletes this bridge.
"""
self._hypervisor.devices.remove(self)
yield from self._hypervisor.send('nio_bridge delete "{}"'.format(self._name))
if self._hypervisor and self in self._hypervisor.devices:
self._hypervisor.devices.remove(self)
if self._hypervisor and not self._hypervisor.devices:
yield from self._hypervisor.send('nio_bridge delete "{}"'.format(self._name))
@asyncio.coroutine
def add_nio(self, nio):

View File

@ -74,7 +74,7 @@ class EthernetHub(Bridge):
Deletes this hub.
"""
for nio in self._nios.values():
for nio in self._nios:
if nio and isinstance(nio, NIOUDP):
self.manager.port_manager.release_udp_port(nio.lport)

View File

@ -124,7 +124,8 @@ class EthernetSwitch(Device):
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)
if self._hypervisor and self in self._hypervisor.devices:
self._hypervisor.devices.remove(self)
if self._hypervisor and not self._hypervisor.devices:
yield from self.hypervisor.stop()

View File

@ -115,7 +115,8 @@ class FrameRelaySwitch(Device):
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)
if self._hypervisor and self in self._hypervisor.devices:
self._hypervisor.devices.remove(self)
if self._hypervisor and not self._hypervisor.devices:
yield from self.hypervisor.stop()