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,13 +192,14 @@ class Dynamips(BaseManager):
:param project: Project instance :param project: Project instance
""" """
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.hypervisor.set_working_dir(project.module_working_directory(self.module_name.lower())) 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(): for device in self._devices.values():
if device.project.id == project.id: if device.project.id == project.id:
yield from device.hypervisor.set_working_dir(project.module_working_directory(self.module_name.lower())) yield from device.hypervisor.set_working_dir(project.module_working_directory(self.module_name.lower()))
@asyncio.coroutine @asyncio.coroutine
def project_committed(self, project): def project_committed(self, project):
@ -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):