diff --git a/gns3server/compute/builtin/nodes/cloud.py b/gns3server/compute/builtin/nodes/cloud.py index 02bcdce5..86f8d932 100644 --- a/gns3server/compute/builtin/nodes/cloud.py +++ b/gns3server/compute/builtin/nodes/cloud.py @@ -85,6 +85,7 @@ class Cloud(BaseNode): "special": interface["special"]}) return {"name": self.name, + "usage": self.usage, "node_id": self.id, "project_id": self.project.id, "remote_console_host": self.remote_console_host, diff --git a/gns3server/compute/builtin/nodes/ethernet_hub.py b/gns3server/compute/builtin/nodes/ethernet_hub.py index 6137b588..015350fb 100644 --- a/gns3server/compute/builtin/nodes/ethernet_hub.py +++ b/gns3server/compute/builtin/nodes/ethernet_hub.py @@ -41,6 +41,7 @@ class EthernetHub(BaseNode): def __json__(self): return {"name": self.name, + "usage": self.usage, "node_id": self.id, "project_id": self.project.id} diff --git a/gns3server/compute/builtin/nodes/ethernet_switch.py b/gns3server/compute/builtin/nodes/ethernet_switch.py index 69c5b736..241dac09 100644 --- a/gns3server/compute/builtin/nodes/ethernet_switch.py +++ b/gns3server/compute/builtin/nodes/ethernet_switch.py @@ -41,6 +41,7 @@ class EthernetSwitch(BaseNode): def __json__(self): return {"name": self.name, + "usage": self.usage, "node_id": self.id, "project_id": self.project.id} diff --git a/gns3server/compute/builtin/nodes/nat.py b/gns3server/compute/builtin/nodes/nat.py index 35984315..21265f6e 100644 --- a/gns3server/compute/builtin/nodes/nat.py +++ b/gns3server/compute/builtin/nodes/nat.py @@ -75,6 +75,7 @@ class Nat(Cloud): def __json__(self): return { "name": self.name, + "usage": self.usage, "node_id": self.id, "project_id": self.project.id, "status": "started", diff --git a/gns3server/compute/dynamips/nodes/atm_switch.py b/gns3server/compute/dynamips/nodes/atm_switch.py index 3b9cea0c..46d975a9 100644 --- a/gns3server/compute/dynamips/nodes/atm_switch.py +++ b/gns3server/compute/dynamips/nodes/atm_switch.py @@ -59,6 +59,7 @@ class ATMSwitch(Device): mappings[source] = destination return {"name": self.name, + "usage": self.usage, "node_id": self.id, "project_id": self.project.id, "mappings": mappings, diff --git a/gns3server/compute/dynamips/nodes/device.py b/gns3server/compute/dynamips/nodes/device.py index c898e733..8ac8e56d 100644 --- a/gns3server/compute/dynamips/nodes/device.py +++ b/gns3server/compute/dynamips/nodes/device.py @@ -31,6 +31,7 @@ class Device: def __init__(self, name, node_id, project, manager, hypervisor=None): self._name = name + self._usage = "" self._id = node_id self._project = project self._manager = manager @@ -76,6 +77,26 @@ class Device: self._name = new_name + @property + def usage(self): + """ + Returns the usage for this device. + + :returns: usage + """ + + return self._usage + + @usage.setter + def usage(self, new_usage): + """ + Sets the usage of this device. + + :param new_usage: usage + """ + + self._usage = new_usage + @property def id(self): """ diff --git a/gns3server/compute/dynamips/nodes/ethernet_hub.py b/gns3server/compute/dynamips/nodes/ethernet_hub.py index cdfea41a..264dc119 100644 --- a/gns3server/compute/dynamips/nodes/ethernet_hub.py +++ b/gns3server/compute/dynamips/nodes/ethernet_hub.py @@ -57,6 +57,7 @@ class EthernetHub(Bridge): def __json__(self): return {"name": self.name, + "usage": self.usage, "node_id": self.id, "project_id": self.project.id, "ports_mapping": self._ports, diff --git a/gns3server/compute/dynamips/nodes/ethernet_switch.py b/gns3server/compute/dynamips/nodes/ethernet_switch.py index fa296a95..7a6edb1f 100644 --- a/gns3server/compute/dynamips/nodes/ethernet_switch.py +++ b/gns3server/compute/dynamips/nodes/ethernet_switch.py @@ -109,6 +109,7 @@ class EthernetSwitch(Device): def __json__(self): ethernet_switch_info = {"name": self.name, + "usage": self.usage, "console": self.console, "console_type": self.console_type, "node_id": self.id, diff --git a/gns3server/compute/dynamips/nodes/frame_relay_switch.py b/gns3server/compute/dynamips/nodes/frame_relay_switch.py index 535187c7..0e7040a0 100644 --- a/gns3server/compute/dynamips/nodes/frame_relay_switch.py +++ b/gns3server/compute/dynamips/nodes/frame_relay_switch.py @@ -58,6 +58,7 @@ class FrameRelaySwitch(Device): mappings[source] = destination return {"name": self.name, + "usage": self.usage, "node_id": self.id, "project_id": self.project.id, "mappings": mappings, diff --git a/gns3server/handlers/api/compute/cloud_handler.py b/gns3server/handlers/api/compute/cloud_handler.py index b735e866..62711a81 100644 --- a/gns3server/handlers/api/compute/cloud_handler.py +++ b/gns3server/handlers/api/compute/cloud_handler.py @@ -53,17 +53,17 @@ class CloudHandler: builtin_manager = Builtin.instance() node = await builtin_manager.create_node(request.json.pop("name"), - request.match_info["project_id"], - request.json.get("node_id"), - node_type="cloud", - ports=request.json.get("ports_mapping")) + request.match_info["project_id"], + request.json.get("node_id"), + node_type="cloud", + ports=request.json.get("ports_mapping")) # add the remote console settings node.remote_console_host = request.json.get("remote_console_host", node.remote_console_host) node.remote_console_port = request.json.get("remote_console_port", node.remote_console_port) node.remote_console_type = request.json.get("remote_console_type", node.remote_console_type) node.remote_console_http_path = request.json.get("remote_console_http_path", node.remote_console_http_path) - + node.usage = request.json.get("usage", "") response.set_status(201) response.json(node) diff --git a/gns3server/schemas/atm_switch.py b/gns3server/schemas/atm_switch.py index 17cb109b..d0cbe4c9 100644 --- a/gns3server/schemas/atm_switch.py +++ b/gns3server/schemas/atm_switch.py @@ -27,6 +27,10 @@ ATM_SWITCH_CREATE_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the ATM switch", + "type": "string", + }, "node_id": { "description": "Node UUID", "oneOf": [ @@ -55,6 +59,10 @@ ATM_SWITCH_OBJECT_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the ATM switch", + "type": "string", + }, "node_id": { "description": "Node UUID", "type": "string", diff --git a/gns3server/schemas/cloud.py b/gns3server/schemas/cloud.py index 190a5e6d..ec6028d5 100644 --- a/gns3server/schemas/cloud.py +++ b/gns3server/schemas/cloud.py @@ -53,6 +53,10 @@ CLOUD_CREATE_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the cloud", + "type": "string", + }, "node_id": { "description": "Node UUID", "oneOf": [ @@ -113,6 +117,10 @@ CLOUD_OBJECT_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the cloud", + "type": "string", + }, "node_id": { "description": "Node UUID", "type": "string", diff --git a/gns3server/schemas/docker_template.py b/gns3server/schemas/docker_template.py index 0e04bbd1..dd569bcb 100644 --- a/gns3server/schemas/docker_template.py +++ b/gns3server/schemas/docker_template.py @@ -26,11 +26,6 @@ DOCKER_TEMPLATE_PROPERTIES = { "type": "string", "minLength": 1 }, - "usage": { - "description": "How to use the Docker container", - "type": "string", - "default": "" - }, "adapters": { "description": "Number of adapters", "type": "integer", diff --git a/gns3server/schemas/dynamips_template.py b/gns3server/schemas/dynamips_template.py index 61a41fc1..244bca4e 100644 --- a/gns3server/schemas/dynamips_template.py +++ b/gns3server/schemas/dynamips_template.py @@ -30,11 +30,6 @@ DYNAMIPS_TEMPLATE_PROPERTIES = { "type": "string", "minLength": 1 }, - "usage": { - "description": "How to use the Dynamips VM", - "type": "string", - "default": "" - }, "mmap": { "description": "MMAP feature", "type": "boolean", diff --git a/gns3server/schemas/ethernet_hub.py b/gns3server/schemas/ethernet_hub.py index 363ad470..1930828d 100644 --- a/gns3server/schemas/ethernet_hub.py +++ b/gns3server/schemas/ethernet_hub.py @@ -46,6 +46,10 @@ ETHERNET_HUB_CREATE_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the hub", + "type": "string", + }, "node_id": { "description": "Node UUID", "oneOf": [ @@ -98,6 +102,10 @@ ETHERNET_HUB_OBJECT_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the hub", + "type": "string", + }, "node_id": { "description": "Node UUID", "type": "string", diff --git a/gns3server/schemas/ethernet_switch.py b/gns3server/schemas/ethernet_switch.py index 52951d3b..ab971a48 100644 --- a/gns3server/schemas/ethernet_switch.py +++ b/gns3server/schemas/ethernet_switch.py @@ -58,6 +58,10 @@ ETHERNET_SWITCH_CREATE_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the switch", + "type": "string", + }, "console": { "description": "Console TCP port", "minimum": 1, @@ -132,6 +136,10 @@ ETHERNET_SWITCH_OBJECT_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the switch", + "type": "string", + }, "node_id": { "description": "Node UUID", "type": "string", diff --git a/gns3server/schemas/frame_relay_switch.py b/gns3server/schemas/frame_relay_switch.py index 0f99508c..e2420c6e 100644 --- a/gns3server/schemas/frame_relay_switch.py +++ b/gns3server/schemas/frame_relay_switch.py @@ -27,6 +27,10 @@ FRAME_RELAY_SWITCH_CREATE_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the Frame Relay switch", + "type": "string", + }, "node_id": { "description": "Node UUID", "oneOf": [ @@ -55,6 +59,10 @@ FRAME_RELAY_SWITCH_OBJECT_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the Frame Relay switch", + "type": "string", + }, "node_id": { "description": "Node UUID", "type": "string", diff --git a/gns3server/schemas/iou_template.py b/gns3server/schemas/iou_template.py index 769234ee..aadfaf97 100644 --- a/gns3server/schemas/iou_template.py +++ b/gns3server/schemas/iou_template.py @@ -25,11 +25,6 @@ IOU_TEMPLATE_PROPERTIES = { "type": "string", "minLength": 1 }, - "usage": { - "description": "How to use the IOU VM", - "type": "string", - "default": "" - }, "ethernet_adapters": { "description": "Number of ethernet adapters", "type": "integer", diff --git a/gns3server/schemas/nat.py b/gns3server/schemas/nat.py index b2de1cde..b0c2fbd8 100644 --- a/gns3server/schemas/nat.py +++ b/gns3server/schemas/nat.py @@ -28,6 +28,10 @@ NAT_OBJECT_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the Nat instance", + "type": "string", + }, "node_id": { "description": "Node UUID", "type": "string", diff --git a/gns3server/schemas/qemu_template.py b/gns3server/schemas/qemu_template.py index f98c81d7..28cb9d50 100644 --- a/gns3server/schemas/qemu_template.py +++ b/gns3server/schemas/qemu_template.py @@ -27,11 +27,6 @@ QEMU_TEMPLATE_PROPERTIES = { "type": "string", "default": "" }, - "usage": { - "description": "How to use the Qemu VM", - "type": "string", - "default": "" - }, "platform": { "description": "Platform to emulate", "enum": QEMU_PLATFORMS, diff --git a/gns3server/schemas/template.py b/gns3server/schemas/template.py index 6cfdb30d..17d3c3d9 100644 --- a/gns3server/schemas/template.py +++ b/gns3server/schemas/template.py @@ -35,6 +35,11 @@ BASE_TEMPLATE_PROPERTIES = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use this template", + "type": "string", + "default": "" + }, "compute_id": { "description": "Compute identifier", "type": ["null", "string"] diff --git a/gns3server/schemas/virtualbox_template.py b/gns3server/schemas/virtualbox_template.py index 1160b056..36ff47c2 100644 --- a/gns3server/schemas/virtualbox_template.py +++ b/gns3server/schemas/virtualbox_template.py @@ -26,11 +26,6 @@ VIRTUALBOX_TEMPLATE_PROPERTIES = { "type": "string", "minLength": 1, }, - "usage": { - "description": "How to use the VirtualBox VM", - "type": "string", - "default": "" - }, "ram": { "description": "Amount of RAM", "minimum": 0, diff --git a/gns3server/schemas/vmware_template.py b/gns3server/schemas/vmware_template.py index f9a65d30..c4c6ac88 100644 --- a/gns3server/schemas/vmware_template.py +++ b/gns3server/schemas/vmware_template.py @@ -26,11 +26,6 @@ VMWARE_TEMPLATE_PROPERTIES = { "type": "string", "minLength": 1, }, - "usage": { - "description": "How to use the VMware VM", - "type": "string", - "default": "" - }, "linked_clone": { "description": "Whether the VM is a linked clone or not", "type": "boolean", diff --git a/gns3server/schemas/vpcs.py b/gns3server/schemas/vpcs.py index 0de28c82..5cc0412a 100644 --- a/gns3server/schemas/vpcs.py +++ b/gns3server/schemas/vpcs.py @@ -26,6 +26,10 @@ VPCS_CREATE_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the VPCS VM", + "type": "string", + }, "node_id": { "description": "Node UUID", "oneOf": [ @@ -65,6 +69,10 @@ VPCS_UPDATE_SCHEMA = { "type": ["string", "null"], "minLength": 1, }, + "usage": { + "description": "How to use the VPCS VM", + "type": "string", + }, "console": { "description": "Console TCP port", "minimum": 1, @@ -89,6 +97,10 @@ VPCS_OBJECT_SCHEMA = { "type": "string", "minLength": 1, }, + "usage": { + "description": "How to use the VPCS VM", + "type": "string", + }, "node_id": { "description": "Node UUID", "type": "string", diff --git a/tests/compute/builtin/nodes/test_cloud.py b/tests/compute/builtin/nodes/test_cloud.py index 3e5e5113..66bd2242 100644 --- a/tests/compute/builtin/nodes/test_cloud.py +++ b/tests/compute/builtin/nodes/test_cloud.py @@ -51,6 +51,7 @@ async def test_json_with_ports(on_gns3vm, compute_project, manager): cloud = Cloud("cloud1", str(uuid.uuid4()), compute_project, manager, ports=ports) assert cloud.__json__() == { "name": "cloud1", + "usage": "", "node_id": cloud.id, "project_id": compute_project.id, "remote_console_host": "", @@ -83,6 +84,7 @@ def test_json_without_ports(on_gns3vm, compute_project, manager): cloud = Cloud("cloud1", str(uuid.uuid4()), compute_project, manager, ports=None) assert cloud.__json__() == { "name": "cloud1", + "usage": "", "node_id": cloud.id, "project_id": compute_project.id, "remote_console_host": "", diff --git a/tests/compute/builtin/nodes/test_nat.py b/tests/compute/builtin/nodes/test_nat.py index a0c497ff..c26a87f7 100644 --- a/tests/compute/builtin/nodes/test_nat.py +++ b/tests/compute/builtin/nodes/test_nat.py @@ -26,6 +26,7 @@ def test_json_gns3vm(on_gns3vm, compute_project): nat = Nat("nat1", str(uuid.uuid4()), compute_project, MagicMock()) assert nat.__json__() == { "name": "nat1", + "usage": "", "node_id": nat.id, "project_id": compute_project.id, "status": "started", @@ -48,6 +49,7 @@ def test_json_darwin(darwin_platform, compute_project): nat = Nat("nat1", str(uuid.uuid4()), compute_project, MagicMock()) assert nat.__json__() == { "name": "nat1", + "usage": "", "node_id": nat.id, "project_id": compute_project.id, "status": "started", @@ -68,6 +70,7 @@ def test_json_windows_with_full_name_of_interface(windows_platform, project): nat = Nat("nat1", str(uuid.uuid4()), project, MagicMock()) assert nat.__json__() == { "name": "nat1", + "usage": "", "node_id": nat.id, "project_id": project.id, "status": "started",