Correctly recover id when closing VMS

Fixes #91
This commit is contained in:
Julien Duponchelle committed 2015-03-06 15:48:16 +01:00
1 parent d657f94c18
commit e37392c482
4 files changed
+12 -15

No files matched your search

+3 -2
View File
@@ -46,13 +46,14 @@ class IOU(BaseManager):
return vm
@asyncio.coroutine
def delete_vm(self, vm_id, *args, **kwargs):
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]
yield from super().delete_vm(vm_id, *args, **kwargs)
yield from super().close_vm(vm_id, *args, **kwargs)
return vm
def get_application_id(self, vm_id):
"""
+1 -4
View File
@@ -274,10 +274,7 @@ class Project:
tasks = []
for vm in self._vms:
if asyncio.iscoroutinefunction(vm.close):
tasks.append(asyncio.async(vm.close()))
else:
vm.close()
tasks.append(asyncio.async(vm.manager.close_vm(vm.id)))
if tasks:
done, _ = yield from asyncio.wait(tasks)
+3 -2
View File
@@ -47,13 +47,14 @@ class VPCS(BaseManager):
return vm
@asyncio.coroutine
def delete_vm(self, vm_id, *args, **kwargs):
def close_vm(self, vm_id, *args, **kwargs):
vm = self.get_vm(vm_id)
i = self._used_mac_ids[vm_id]
self._free_mac_ids[vm.project.id].insert(0, i)
del self._used_mac_ids[vm_id]
yield from super().delete_vm(vm_id, *args, **kwargs)
yield from super().close_vm(vm_id, *args, **kwargs)
return vm
def get_mac_id(self, vm_id):
"""