diff --git a/gns3server/modules/dynamips/__init__.py b/gns3server/modules/dynamips/__init__.py index 181347df..b36169e1 100644 --- a/gns3server/modules/dynamips/__init__.py +++ b/gns3server/modules/dynamips/__init__.py @@ -115,6 +115,7 @@ class Dynamips(BaseManager): self._devices = {} self._ghost_files = set() self._dynamips_path = None + self._project_lock = asyncio.Lock() @asyncio.coroutine def unload(self): @@ -191,13 +192,14 @@ class Dynamips(BaseManager): :param project: Project instance """ - for vm in self._vms.values(): - if vm.project.id == project.id: - yield from vm.hypervisor.set_working_dir(project.module_working_directory(self.module_name.lower())) + with (yield from self._project_lock): + for vm in self._vms.values(): + if vm.project.id == project.id: + yield from vm.hypervisor.set_working_dir(project.module_working_directory(self.module_name.lower())) - for device in self._devices.values(): - if device.project.id == project.id: - yield from device.hypervisor.set_working_dir(project.module_working_directory(self.module_name.lower())) + for device in self._devices.values(): + if device.project.id == project.id: + yield from device.hypervisor.set_working_dir(project.module_working_directory(self.module_name.lower())) @asyncio.coroutine def project_committed(self, project): @@ -207,11 +209,11 @@ class Dynamips(BaseManager): :param project: Project instance """ - pass # save the configs when the project is committed - #for vm in self._vms.values(): - # if vm.project.id == project.id: - # yield from vm.save_configs() + with (yield from self._project_lock): + for vm in self._vms.values(): + if vm.project.id == project.id: + yield from vm.save_configs() @property def dynamips_path(self):