From 2b36746d5251a7db81d6c8d05a97a5039101cbe0 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Thu, 25 Jun 2015 09:52:10 +0200 Subject: [PATCH] Return the working directory of a Qemu VM --- gns3server/modules/qemu/qemu_vm.py | 3 ++- gns3server/schemas/qemu.py | 6 +++++- tests/handlers/api/test_qemu.py | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gns3server/modules/qemu/qemu_vm.py b/gns3server/modules/qemu/qemu_vm.py index 30ec03f84..145a0e29e 100644 --- a/gns3server/modules/qemu/qemu_vm.py +++ b/gns3server/modules/qemu/qemu_vm.py @@ -1229,7 +1229,8 @@ class QemuVM(BaseVM): def __json__(self): answer = { "project_id": self.project.id, - "vm_id": self.id + "vm_id": self.id, + "vm_directory": self.working_dir } # Qemu has a long list of options. The JSON schema is the single source of information for field in QEMU_OBJECT_SCHEMA["required"]: diff --git a/gns3server/schemas/qemu.py b/gns3server/schemas/qemu.py index 46843c49f..dd8765f11 100644 --- a/gns3server/schemas/qemu.py +++ b/gns3server/schemas/qemu.py @@ -358,6 +358,10 @@ QEMU_OBJECT_SCHEMA = { "description": "QEMU hdd disk image checksum", "type": ["string", "null"], }, + "vm_directory": { + "decription": "Path to the VM working directory", + "type": "string" + }, "ram": { "description": "amount of RAM in MB", "type": "integer" @@ -442,7 +446,7 @@ QEMU_OBJECT_SCHEMA = { "hdc_disk_image", "hdd_disk_image", "hda_disk_image_md5sum", "hdb_disk_image_md5sum", "hdc_disk_image_md5sum", "hdd_disk_image_md5sum", "ram", "adapters", "adapter_type", "mac_address", "console", "initrd", "kernel_image", "initrd_md5sum", "kernel_image_md5sum", "kernel_command_line", - "legacy_networking", "acpi_shutdown", "cpu_throttling", "process_priority", "options"] + "legacy_networking", "acpi_shutdown", "cpu_throttling", "process_priority", "options","vm_directory"] } QEMU_BINARY_LIST_SCHEMA = { diff --git a/tests/handlers/api/test_qemu.py b/tests/handlers/api/test_qemu.py index a5e8ab81a..e1d974684 100644 --- a/tests/handlers/api/test_qemu.py +++ b/tests/handlers/api/test_qemu.py @@ -108,6 +108,7 @@ def test_qemu_get(server, project, vm): assert response.route == "/projects/{project_id}/qemu/vms/{vm_id}" assert response.json["name"] == "PC TEST 1" assert response.json["project_id"] == project.id + assert response.json["vm_directory"] == os.path.join(project.path, "project-files", "qemu", vm["vm_id"]) def test_qemu_start(server, vm):