From 42a4df5079236aac8f10fc6c6aaba02c24841b7e Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 1 Dec 2015 10:54:51 +0100 Subject: [PATCH] Support VM usage for qemu Ref https://github.com/GNS3/gns3-gui/issues/829 --- gns3server/modules/base_vm.py | 21 +++++++++++++ gns3server/schemas/qemu.py | 57 +++++++++++++++++++++++++++++++---- 2 files changed, 72 insertions(+), 6 deletions(-) diff --git a/gns3server/modules/base_vm.py b/gns3server/modules/base_vm.py index 2cf32c45..2dd43cce 100644 --- a/gns3server/modules/base_vm.py +++ b/gns3server/modules/base_vm.py @@ -48,6 +48,7 @@ class BaseVM: def __init__(self, name, vm_id, project, manager, console=None, console_type="telnet"): self._name = name + self._usage = "" self._id = vm_id self._project = project self._manager = manager @@ -124,6 +125,26 @@ class BaseVM: new_name=new_name)) self._name = new_name + @property + def usage(self): + """ + Returns the usage for this VM. + + :returns: usage + """ + + return self._usage + + @usage.setter + def usage(self, new_usage): + """ + Sets the usage of this VM. + + :param new_usage: usage + """ + + self._usage = new_usage + @property def id(self): """ diff --git a/gns3server/schemas/qemu.py b/gns3server/schemas/qemu.py index 2354d729..03dc8cd8 100644 --- a/gns3server/schemas/qemu.py +++ b/gns3server/schemas/qemu.py @@ -38,6 +38,10 @@ QEMU_CREATE_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the qemu VM", + "type": "string", + }, "linked_clone": { "description": "either the VM is a linked clone or not", "type": "boolean" @@ -211,6 +215,10 @@ QEMU_UPDATE_SCHEMA = { "type": ["string", "null"], "minLength": 1, }, + "usage": { + "description": "How to use the qemu VM", + "type": "string", + }, "qemu_path": { "description": "Path to QEMU", "type": ["string", "null"], @@ -389,6 +397,10 @@ QEMU_OBJECT_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the qemu VM", + "type": "string", + }, "qemu_path": { "description": "path to QEMU", "type": "string", @@ -548,12 +560,45 @@ QEMU_OBJECT_SCHEMA = { }, }, "additionalProperties": False, - "required": ["vm_id", "project_id", "name", "qemu_path", "platform", "console_type", "hda_disk_image", "hdb_disk_image", - "hdc_disk_image", "hdd_disk_image", "hda_disk_image_md5sum", "hdb_disk_image_md5sum", - "hdc_disk_image_md5sum", "hdd_disk_image_md5sum", "hda_disk_interface", "hdb_disk_interface", "hdc_disk_interface", - "hdd_disk_interface", "cdrom_image", "cdrom_image_md5sum", "boot_priority", "ram", "cpus", "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", "vm_directory"] + "required": ["vm_id", + "project_id", + "name", + "usage", + "qemu_path", + "platform", + "console_type", + "hda_disk_image", + "hdb_disk_image", + "hdc_disk_image", + "hdd_disk_image", + "hda_disk_image_md5sum", + "hdb_disk_image_md5sum", + "hdc_disk_image_md5sum", + "hdd_disk_image_md5sum", + "hda_disk_interface", + "hdb_disk_interface", + "hdc_disk_interface", + "hdd_disk_interface", + "cdrom_image", + "cdrom_image_md5sum", + "boot_priority", + "ram", + "cpus", + "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", + "vm_directory"] } QEMU_BINARY_LIST_SCHEMA = {