Merge pull request #1185 from GNS3/fix-delete-project

Don't create directory structure during json dump. Fixes #2270
This commit is contained in:
Jeremy Grossmann authored and GitHub committed 2017-10-02 13:49:46 -07:00
commit 897f7656da
10 files changed
+35 -8

No files matched your search

+8
View File
@@ -233,6 +233,14 @@ class BaseNode:
return self._project.node_working_directory(self)
@property
def working_path(self):
"""
Return the node working path. Doesn't create structure of directories when not present.
"""
return self._project.node_working_path(self)
@property
def temporary_directory(self):
if self._temporary_directory is None:
+1 -1
View File
@@ -86,7 +86,7 @@ class Cloud(BaseNode):
"ports_mapping": self._ports_mapping,
"interfaces": host_interfaces,
"status": self.status,
"node_directory": self.working_dir
"node_directory": self.working_path
}
@property
+1 -1
View File
@@ -114,7 +114,7 @@ class DockerVM(BaseNode):
"start_command": self.start_command,
"status": self.status,
"environment": self.environment,
"node_directory": self.working_dir
"node_directory": self.working_path
}
def _get_free_display_port(self):
+1 -1
View File
@@ -194,7 +194,7 @@ class IOUVM(BaseNode):
iou_vm_info = {"name": self.name,
"node_id": self.id,
"node_directory": self.working_dir,
"node_directory": self.working_path,
"console": self._console,
"console_type": "telnet",
"status": self.status,
+10 -1
View File
@@ -207,7 +207,7 @@ class Project:
:returns: Node working directory
"""
workdir = os.path.join(self._path, "project-files", node.manager.module_name.lower(), node.id)
workdir = self.node_working_path(node)
if not self._deleted:
try:
os.makedirs(workdir, exist_ok=True)
@@ -215,6 +215,15 @@ class Project:
raise aiohttp.web.HTTPInternalServerError(text="Could not create the node working directory: {}".format(e))
return workdir
def node_working_path(self, node):
"""
Returns a node working path for node. It doesn't create structure if not present on system.
:param node: Node instance
:return: Node working path
"""
return os.path.join(self._path, "project-files", node.manager.module_name.lower(), node.id)
def tmp_working_directory(self):
"""
A temporary directory. Will be clean at project open and close
+1 -1
View File
@@ -1628,7 +1628,7 @@ class QemuVM(BaseNode):
answer = {
"project_id": self.project.id,
"node_id": self.id,
"node_directory": self.working_dir
"node_directory": self.working_path
}
# Qemu has a long list of options. The JSON schema is the single source of information
for field in QEMU_OBJECT_SCHEMA["required"]:
@@ -89,7 +89,7 @@ class VirtualBoxVM(BaseNode):
"use_any_adapter": self.use_any_adapter,
"linked_clone": self.linked_clone}
if self.linked_clone:
json["node_directory"] = self.working_dir
json["node_directory"] = self.working_path
else:
json["node_directory"] = None
return json
+1 -1
View File
@@ -86,7 +86,7 @@ class VMwareVM(BaseNode):
"adapter_type": self.adapter_type,
"use_any_adapter": self.use_any_adapter,
"status": self.status,
"node_directory": self.working_dir,
"node_directory": self.working_path,
"linked_clone": self.linked_clone}
return json
+1 -1
View File
@@ -127,7 +127,7 @@ class VPCSVM(BaseNode):
return {"name": self.name,
"node_id": self.id,
"node_directory": self.working_dir,
"node_directory": self.working_path,
"status": self.status,
"console": self._console,
"console_type": "telnet",