diff --git a/gns3server/modules/dynamips/nodes/atm_switch.py b/gns3server/modules/dynamips/nodes/atm_switch.py index bf56945b..0fb9e1e1 100644 --- a/gns3server/modules/dynamips/nodes/atm_switch.py +++ b/gns3server/modules/dynamips/nodes/atm_switch.py @@ -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() diff --git a/gns3server/modules/dynamips/nodes/bridge.py b/gns3server/modules/dynamips/nodes/bridge.py index 174fbb86..7dc4e31b 100644 --- a/gns3server/modules/dynamips/nodes/bridge.py +++ b/gns3server/modules/dynamips/nodes/bridge.py @@ -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): diff --git a/gns3server/modules/dynamips/nodes/ethernet_hub.py b/gns3server/modules/dynamips/nodes/ethernet_hub.py index 23fb2129..d41e5117 100644 --- a/gns3server/modules/dynamips/nodes/ethernet_hub.py +++ b/gns3server/modules/dynamips/nodes/ethernet_hub.py @@ -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) diff --git a/gns3server/modules/dynamips/nodes/ethernet_switch.py b/gns3server/modules/dynamips/nodes/ethernet_switch.py index 3814e720..a748a9b3 100644 --- a/gns3server/modules/dynamips/nodes/ethernet_switch.py +++ b/gns3server/modules/dynamips/nodes/ethernet_switch.py @@ -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() diff --git a/gns3server/modules/dynamips/nodes/frame_relay_switch.py b/gns3server/modules/dynamips/nodes/frame_relay_switch.py index 1a21dd56..b46055b4 100644 --- a/gns3server/modules/dynamips/nodes/frame_relay_switch.py +++ b/gns3server/modules/dynamips/nodes/frame_relay_switch.py @@ -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()