mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-22 06:07:51 +00:00
Stop Dynamips hypervisors used by devices before the project is closed.
This is to avoid locked files by hypervisors preventing temporary project working directories to be deleted.
This commit is contained in:
parent
3ef529fb0e
commit
c48ca212bd
@ -121,6 +121,8 @@ class ProjectHandler:
|
||||
|
||||
pm = ProjectManager.instance()
|
||||
project = pm.get_project(request.match_info["project_id"])
|
||||
for module in MODULES:
|
||||
yield from module.instance().project_closing(project)
|
||||
yield from project.close()
|
||||
for module in MODULES:
|
||||
yield from module.instance().project_closed(project)
|
||||
|
@ -234,6 +234,16 @@ class BaseManager:
|
||||
vm.close()
|
||||
return vm
|
||||
|
||||
@asyncio.coroutine
|
||||
def project_closing(self, project):
|
||||
"""
|
||||
Called when a project is about to be closed.
|
||||
|
||||
:param project: Project instance
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
@asyncio.coroutine
|
||||
def project_closed(self, project):
|
||||
"""
|
||||
|
@ -136,9 +136,9 @@ class Dynamips(BaseManager):
|
||||
continue
|
||||
|
||||
@asyncio.coroutine
|
||||
def project_closed(self, project):
|
||||
def project_closing(self, project):
|
||||
"""
|
||||
Called when a project is closed.
|
||||
Called when a project is about to be closed.
|
||||
|
||||
:param project: Project instance
|
||||
"""
|
||||
@ -157,7 +157,15 @@ class Dynamips(BaseManager):
|
||||
except Exception as e:
|
||||
log.error("Could not delete device {}".format(e), exc_info=1)
|
||||
|
||||
# delete useless files
|
||||
@asyncio.coroutine
|
||||
def project_closed(self, project):
|
||||
"""
|
||||
Called when a project is closed.
|
||||
|
||||
:param project: Project instance
|
||||
"""
|
||||
|
||||
# delete useless Dynamips files
|
||||
project_dir = project.module_working_directory(self.module_name.lower())
|
||||
files = glob.glob(os.path.join(project_dir, "*.ghost"))
|
||||
files += glob.glob(os.path.join(project_dir, "*_lock"))
|
||||
|
Loading…
Reference in New Issue
Block a user