mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Delete a project
This commit is contained in:
1 parent
9a0b260c56
commit
986a7f55ef
4 files changed
+54
-2
No files matched your search
@@ -49,9 +49,27 @@ class ProjectHandler:
|
||||
204: "Changes write on disk",
|
||||
404: "Project instance doesn't exist"
|
||||
})
|
||||
def create_project(request, response):
|
||||
def commit(request, response):
|
||||
|
||||
pm = ProjectManager.instance()
|
||||
project = pm.get_project(request.match_info["uuid"])
|
||||
project.commit()
|
||||
response.set_status(204)
|
||||
|
||||
@classmethod
|
||||
@Route.delete(
|
||||
r"/project/{uuid}",
|
||||
description="Delete a project from disk",
|
||||
parameters={
|
||||
"uuid": "Project instance UUID",
|
||||
},
|
||||
status_codes={
|
||||
204: "Changes write on disk",
|
||||
404: "Project instance doesn't exist"
|
||||
})
|
||||
def delete(request, response):
|
||||
|
||||
pm = ProjectManager.instance()
|
||||
project = pm.get_project(request.match_info["uuid"])
|
||||
project.delete()
|
||||
response.set_status(204)
|
||||
@@ -98,10 +98,23 @@ class Project:
|
||||
"location": self._location
|
||||
}
|
||||
|
||||
def close(self):
|
||||
"""Close the project, but keep informations on disk"""
|
||||
|
||||
pass
|
||||
|
||||
def commit(self):
|
||||
"""Write project changes on disk"""
|
||||
|
||||
while self._vms_to_destroy:
|
||||
vm = self._vms_to_destroy.pop()
|
||||
directory = self.vm_working_directory(vm)
|
||||
if os.path.exists(directory):
|
||||
shutil.rmtree(directory)
|
||||
|
||||
def delete(self):
|
||||
"""Remove project from disk"""
|
||||
|
||||
self.close()
|
||||
if os.path.exists(self.path):
|
||||
shutil.rmtree(self.path)
|
||||
Reference in new issue
Block a user