diff --git a/gns3server/modules/iou/__init__.py b/gns3server/modules/iou/__init__.py index 3cdddfe7..7b80107a 100644 --- a/gns3server/modules/iou/__init__.py +++ b/gns3server/modules/iou/__init__.py @@ -49,9 +49,10 @@ class IOU(BaseManager): def close_vm(self, vm_id, *args, **kwargs): vm = self.get_vm(vm_id) - i = self._used_application_ids[vm_id] - self._free_application_ids.insert(0, i) - del self._used_application_ids[vm_id] + if vm_id in self._used_application_ids: + i = self._used_application_ids[vm_id] + self._free_application_ids.insert(0, i) + del self._used_application_ids[vm_id] yield from super().close_vm(vm_id, *args, **kwargs) return vm