diff --git a/gns3server/compute/builtin/nodes/cloud.py b/gns3server/compute/builtin/nodes/cloud.py index 0f3262e2..630905df 100644 --- a/gns3server/compute/builtin/nodes/cloud.py +++ b/gns3server/compute/builtin/nodes/cloud.py @@ -81,7 +81,9 @@ class Cloud(BaseNode): "project_id": self.project.id, "ports_mapping": self._ports_mapping, "interfaces": host_interfaces, - "status": self.status} + "status": self.status, + "node_directory": self.working_dir + } @property def ports_mapping(self): diff --git a/gns3server/schemas/cloud.py b/gns3server/schemas/cloud.py index f5c23508..a67d8d35 100644 --- a/gns3server/schemas/cloud.py +++ b/gns3server/schemas/cloud.py @@ -75,7 +75,7 @@ CLOUD_CREATE_SCHEMA = { {"$ref": "#/definitions/HostInterfaces"} ]}, ] - }, + } }, "additionalProperties": False, "required": ["name"] @@ -123,6 +123,10 @@ CLOUD_OBJECT_SCHEMA = { ]}, ] }, + "node_directory": { + "description": "Path to the VM working directory", + "type": "string" + }, "status": { "description": "Node status", "enum": ["started", "stopped", "suspended"] diff --git a/gns3server/schemas/dynamips_vm.py b/gns3server/schemas/dynamips_vm.py index c5225c21..8cb03c9b 100644 --- a/gns3server/schemas/dynamips_vm.py +++ b/gns3server/schemas/dynamips_vm.py @@ -511,7 +511,7 @@ VM_OBJECT_SCHEMA = { "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" }, "node_directory": { - "decription": "Path to the vm working directory", + "description": "Path to the vm working directory", "type": "string" }, "project_id": { diff --git a/gns3server/schemas/qemu.py b/gns3server/schemas/qemu.py index 36e2fa6b..bdf3e55c 100644 --- a/gns3server/schemas/qemu.py +++ b/gns3server/schemas/qemu.py @@ -503,7 +503,7 @@ QEMU_OBJECT_SCHEMA = { "enum": ["c", "d", "n", "cn", "cd"] }, "node_directory": { - "decription": "Path to the VM working directory", + "description": "Path to the VM working directory", "type": "string" }, "ram": { diff --git a/gns3server/schemas/virtualbox.py b/gns3server/schemas/virtualbox.py index 5b2661b6..769d373f 100644 --- a/gns3server/schemas/virtualbox.py +++ b/gns3server/schemas/virtualbox.py @@ -124,7 +124,7 @@ VBOX_OBJECT_SCHEMA = { "enum": ["started", "stopped", "suspended"] }, "node_directory": { - "decription": "Path to the VM working directory", + "description": "Path to the VM working directory", "type": ["string", "null"] }, "headless": { diff --git a/gns3server/schemas/vmware.py b/gns3server/schemas/vmware.py index efd2cd8b..72a009fe 100644 --- a/gns3server/schemas/vmware.py +++ b/gns3server/schemas/vmware.py @@ -103,7 +103,7 @@ VMWARE_OBJECT_SCHEMA = { "enum": ["started", "stopped", "suspended"] }, "node_directory": { - "decription": "Path to the node working directory", + "description": "Path to the node working directory", "type": ["string", "null"] }, "project_id": { diff --git a/gns3server/schemas/vpcs.py b/gns3server/schemas/vpcs.py index 283f1091..80a212f9 100644 --- a/gns3server/schemas/vpcs.py +++ b/gns3server/schemas/vpcs.py @@ -109,7 +109,7 @@ VPCS_OBJECT_SCHEMA = { "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" }, "node_directory": { - "decription": "Path to the VM working directory", + "description": "Path to the VM working directory", "type": "string" }, "status": { diff --git a/tests/compute/builtin/nodes/test_cloud.py b/tests/compute/builtin/nodes/test_cloud.py index 52687c97..43fee80d 100644 --- a/tests/compute/builtin/nodes/test_cloud.py +++ b/tests/compute/builtin/nodes/test_cloud.py @@ -29,21 +29,29 @@ def nio(): return NIOUDP(4242, "127.0.0.1", 4343) -def test_json_with_ports(on_gns3vm, project): +@pytest.fixture +def manager(): + m = MagicMock() + m.module_name = "builtins" + return m + + +def test_json_with_ports(on_gns3vm, project, manager): ports = [ { "interface": "virbr0", "name": "virbr0", "port_number": 0, - "type": "ethernet" + "type": "ethernet", } ] - cloud = Cloud("cloud1", str(uuid.uuid4()), project, MagicMock(), ports=ports) + cloud = Cloud("cloud1", str(uuid.uuid4()), project, manager, ports=ports) assert cloud.__json__() == { "name": "cloud1", "node_id": cloud.id, "project_id": project.id, "status": "stopped", + "node_directory": cloud.working_dir, "ports_mapping": [ { "interface": "virbr0", @@ -60,16 +68,17 @@ def test_json_with_ports(on_gns3vm, project): } -def test_json_without_ports(on_gns3vm, project): +def test_json_without_ports(on_gns3vm, project, manager): """ If no interface is provide the cloud is prefill with non special interfaces """ - cloud = Cloud("cloud1", str(uuid.uuid4()), project, MagicMock(), ports=None) + cloud = Cloud("cloud1", str(uuid.uuid4()), project, manager, ports=None) assert cloud.__json__() == { "name": "cloud1", "node_id": cloud.id, "project_id": project.id, "status": "stopped", + "node_directory": cloud.working_dir, "ports_mapping": [ { "interface": "eth0",