Save IOS configs when a project is committed.

This commit is contained in:
Jeremy 2015-03-17 18:53:24 -06:00
parent 386b311755
commit 163d1e375d

View File

@ -115,6 +115,7 @@ class Dynamips(BaseManager):
self._devices = {} self._devices = {}
self._ghost_files = set() self._ghost_files = set()
self._dynamips_path = None self._dynamips_path = None
self._project_lock = asyncio.Lock()
@asyncio.coroutine @asyncio.coroutine
def unload(self): def unload(self):
@ -191,6 +192,7 @@ class Dynamips(BaseManager):
:param project: Project instance :param project: Project instance
""" """
with (yield from self._project_lock):
for vm in self._vms.values(): for vm in self._vms.values():
if vm.project.id == project.id: if vm.project.id == project.id:
yield from vm.hypervisor.set_working_dir(project.module_working_directory(self.module_name.lower())) yield from vm.hypervisor.set_working_dir(project.module_working_directory(self.module_name.lower()))
@ -207,11 +209,11 @@ class Dynamips(BaseManager):
:param project: Project instance :param project: Project instance
""" """
pass
# save the configs when the project is committed # save the configs when the project is committed
#for vm in self._vms.values(): with (yield from self._project_lock):
# if vm.project.id == project.id: for vm in self._vms.values():
# yield from vm.save_configs() if vm.project.id == project.id:
yield from vm.save_configs()
@property @property
def dynamips_path(self): def dynamips_path(self):