mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 19:28:07 +00:00
Support for "usage" for "Cloud" nodes. Fixes https://github.com/GNS3/gns3-gui/issues/2887
Allow "usage" for all builtin nodes (not exposed in Ui).
This commit is contained in:
parent
d11897c1ec
commit
dff035d957
@ -85,6 +85,7 @@ class Cloud(BaseNode):
|
|||||||
"special": interface["special"]})
|
"special": interface["special"]})
|
||||||
|
|
||||||
return {"name": self.name,
|
return {"name": self.name,
|
||||||
|
"usage": self.usage,
|
||||||
"node_id": self.id,
|
"node_id": self.id,
|
||||||
"project_id": self.project.id,
|
"project_id": self.project.id,
|
||||||
"remote_console_host": self.remote_console_host,
|
"remote_console_host": self.remote_console_host,
|
||||||
|
@ -41,6 +41,7 @@ class EthernetHub(BaseNode):
|
|||||||
def __json__(self):
|
def __json__(self):
|
||||||
|
|
||||||
return {"name": self.name,
|
return {"name": self.name,
|
||||||
|
"usage": self.usage,
|
||||||
"node_id": self.id,
|
"node_id": self.id,
|
||||||
"project_id": self.project.id}
|
"project_id": self.project.id}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ class EthernetSwitch(BaseNode):
|
|||||||
def __json__(self):
|
def __json__(self):
|
||||||
|
|
||||||
return {"name": self.name,
|
return {"name": self.name,
|
||||||
|
"usage": self.usage,
|
||||||
"node_id": self.id,
|
"node_id": self.id,
|
||||||
"project_id": self.project.id}
|
"project_id": self.project.id}
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ class Nat(Cloud):
|
|||||||
def __json__(self):
|
def __json__(self):
|
||||||
return {
|
return {
|
||||||
"name": self.name,
|
"name": self.name,
|
||||||
|
"usage": self.usage,
|
||||||
"node_id": self.id,
|
"node_id": self.id,
|
||||||
"project_id": self.project.id,
|
"project_id": self.project.id,
|
||||||
"status": "started",
|
"status": "started",
|
||||||
|
@ -59,6 +59,7 @@ class ATMSwitch(Device):
|
|||||||
mappings[source] = destination
|
mappings[source] = destination
|
||||||
|
|
||||||
return {"name": self.name,
|
return {"name": self.name,
|
||||||
|
"usage": self.usage,
|
||||||
"node_id": self.id,
|
"node_id": self.id,
|
||||||
"project_id": self.project.id,
|
"project_id": self.project.id,
|
||||||
"mappings": mappings,
|
"mappings": mappings,
|
||||||
|
@ -31,6 +31,7 @@ class Device:
|
|||||||
def __init__(self, name, node_id, project, manager, hypervisor=None):
|
def __init__(self, name, node_id, project, manager, hypervisor=None):
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
|
self._usage = ""
|
||||||
self._id = node_id
|
self._id = node_id
|
||||||
self._project = project
|
self._project = project
|
||||||
self._manager = manager
|
self._manager = manager
|
||||||
@ -76,6 +77,26 @@ class Device:
|
|||||||
|
|
||||||
self._name = new_name
|
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
|
@property
|
||||||
def id(self):
|
def id(self):
|
||||||
"""
|
"""
|
||||||
|
@ -57,6 +57,7 @@ class EthernetHub(Bridge):
|
|||||||
def __json__(self):
|
def __json__(self):
|
||||||
|
|
||||||
return {"name": self.name,
|
return {"name": self.name,
|
||||||
|
"usage": self.usage,
|
||||||
"node_id": self.id,
|
"node_id": self.id,
|
||||||
"project_id": self.project.id,
|
"project_id": self.project.id,
|
||||||
"ports_mapping": self._ports,
|
"ports_mapping": self._ports,
|
||||||
|
@ -109,6 +109,7 @@ class EthernetSwitch(Device):
|
|||||||
def __json__(self):
|
def __json__(self):
|
||||||
|
|
||||||
ethernet_switch_info = {"name": self.name,
|
ethernet_switch_info = {"name": self.name,
|
||||||
|
"usage": self.usage,
|
||||||
"console": self.console,
|
"console": self.console,
|
||||||
"console_type": self.console_type,
|
"console_type": self.console_type,
|
||||||
"node_id": self.id,
|
"node_id": self.id,
|
||||||
|
@ -58,6 +58,7 @@ class FrameRelaySwitch(Device):
|
|||||||
mappings[source] = destination
|
mappings[source] = destination
|
||||||
|
|
||||||
return {"name": self.name,
|
return {"name": self.name,
|
||||||
|
"usage": self.usage,
|
||||||
"node_id": self.id,
|
"node_id": self.id,
|
||||||
"project_id": self.project.id,
|
"project_id": self.project.id,
|
||||||
"mappings": mappings,
|
"mappings": mappings,
|
||||||
|
@ -63,7 +63,7 @@ class CloudHandler:
|
|||||||
node.remote_console_port = request.json.get("remote_console_port", node.remote_console_port)
|
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_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.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.set_status(201)
|
||||||
response.json(node)
|
response.json(node)
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@ ATM_SWITCH_CREATE_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the ATM switch",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"node_id": {
|
"node_id": {
|
||||||
"description": "Node UUID",
|
"description": "Node UUID",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
@ -55,6 +59,10 @@ ATM_SWITCH_OBJECT_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the ATM switch",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"node_id": {
|
"node_id": {
|
||||||
"description": "Node UUID",
|
"description": "Node UUID",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -53,6 +53,10 @@ CLOUD_CREATE_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the cloud",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"node_id": {
|
"node_id": {
|
||||||
"description": "Node UUID",
|
"description": "Node UUID",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
@ -113,6 +117,10 @@ CLOUD_OBJECT_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the cloud",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"node_id": {
|
"node_id": {
|
||||||
"description": "Node UUID",
|
"description": "Node UUID",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -26,11 +26,6 @@ DOCKER_TEMPLATE_PROPERTIES = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1
|
"minLength": 1
|
||||||
},
|
},
|
||||||
"usage": {
|
|
||||||
"description": "How to use the Docker container",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"adapters": {
|
"adapters": {
|
||||||
"description": "Number of adapters",
|
"description": "Number of adapters",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
@ -30,11 +30,6 @@ DYNAMIPS_TEMPLATE_PROPERTIES = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1
|
"minLength": 1
|
||||||
},
|
},
|
||||||
"usage": {
|
|
||||||
"description": "How to use the Dynamips VM",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"mmap": {
|
"mmap": {
|
||||||
"description": "MMAP feature",
|
"description": "MMAP feature",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
@ -46,6 +46,10 @@ ETHERNET_HUB_CREATE_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the hub",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"node_id": {
|
"node_id": {
|
||||||
"description": "Node UUID",
|
"description": "Node UUID",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
@ -98,6 +102,10 @@ ETHERNET_HUB_OBJECT_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the hub",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"node_id": {
|
"node_id": {
|
||||||
"description": "Node UUID",
|
"description": "Node UUID",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -58,6 +58,10 @@ ETHERNET_SWITCH_CREATE_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the switch",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"console": {
|
"console": {
|
||||||
"description": "Console TCP port",
|
"description": "Console TCP port",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
@ -132,6 +136,10 @@ ETHERNET_SWITCH_OBJECT_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the switch",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"node_id": {
|
"node_id": {
|
||||||
"description": "Node UUID",
|
"description": "Node UUID",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -27,6 +27,10 @@ FRAME_RELAY_SWITCH_CREATE_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the Frame Relay switch",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"node_id": {
|
"node_id": {
|
||||||
"description": "Node UUID",
|
"description": "Node UUID",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
@ -55,6 +59,10 @@ FRAME_RELAY_SWITCH_OBJECT_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the Frame Relay switch",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"node_id": {
|
"node_id": {
|
||||||
"description": "Node UUID",
|
"description": "Node UUID",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -25,11 +25,6 @@ IOU_TEMPLATE_PROPERTIES = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1
|
"minLength": 1
|
||||||
},
|
},
|
||||||
"usage": {
|
|
||||||
"description": "How to use the IOU VM",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"ethernet_adapters": {
|
"ethernet_adapters": {
|
||||||
"description": "Number of ethernet adapters",
|
"description": "Number of ethernet adapters",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
@ -28,6 +28,10 @@ NAT_OBJECT_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the Nat instance",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"node_id": {
|
"node_id": {
|
||||||
"description": "Node UUID",
|
"description": "Node UUID",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -27,11 +27,6 @@ QEMU_TEMPLATE_PROPERTIES = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"default": ""
|
"default": ""
|
||||||
},
|
},
|
||||||
"usage": {
|
|
||||||
"description": "How to use the Qemu VM",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"platform": {
|
"platform": {
|
||||||
"description": "Platform to emulate",
|
"description": "Platform to emulate",
|
||||||
"enum": QEMU_PLATFORMS,
|
"enum": QEMU_PLATFORMS,
|
||||||
|
@ -35,6 +35,11 @@ BASE_TEMPLATE_PROPERTIES = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use this template",
|
||||||
|
"type": "string",
|
||||||
|
"default": ""
|
||||||
|
},
|
||||||
"compute_id": {
|
"compute_id": {
|
||||||
"description": "Compute identifier",
|
"description": "Compute identifier",
|
||||||
"type": ["null", "string"]
|
"type": ["null", "string"]
|
||||||
|
@ -26,11 +26,6 @@ VIRTUALBOX_TEMPLATE_PROPERTIES = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
"usage": {
|
|
||||||
"description": "How to use the VirtualBox VM",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"ram": {
|
"ram": {
|
||||||
"description": "Amount of RAM",
|
"description": "Amount of RAM",
|
||||||
"minimum": 0,
|
"minimum": 0,
|
||||||
|
@ -26,11 +26,6 @@ VMWARE_TEMPLATE_PROPERTIES = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
"usage": {
|
|
||||||
"description": "How to use the VMware VM",
|
|
||||||
"type": "string",
|
|
||||||
"default": ""
|
|
||||||
},
|
|
||||||
"linked_clone": {
|
"linked_clone": {
|
||||||
"description": "Whether the VM is a linked clone or not",
|
"description": "Whether the VM is a linked clone or not",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
@ -26,6 +26,10 @@ VPCS_CREATE_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the VPCS VM",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"node_id": {
|
"node_id": {
|
||||||
"description": "Node UUID",
|
"description": "Node UUID",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
@ -65,6 +69,10 @@ VPCS_UPDATE_SCHEMA = {
|
|||||||
"type": ["string", "null"],
|
"type": ["string", "null"],
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the VPCS VM",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"console": {
|
"console": {
|
||||||
"description": "Console TCP port",
|
"description": "Console TCP port",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
@ -89,6 +97,10 @@ VPCS_OBJECT_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"usage": {
|
||||||
|
"description": "How to use the VPCS VM",
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"node_id": {
|
"node_id": {
|
||||||
"description": "Node UUID",
|
"description": "Node UUID",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -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)
|
cloud = Cloud("cloud1", str(uuid.uuid4()), compute_project, manager, ports=ports)
|
||||||
assert cloud.__json__() == {
|
assert cloud.__json__() == {
|
||||||
"name": "cloud1",
|
"name": "cloud1",
|
||||||
|
"usage": "",
|
||||||
"node_id": cloud.id,
|
"node_id": cloud.id,
|
||||||
"project_id": compute_project.id,
|
"project_id": compute_project.id,
|
||||||
"remote_console_host": "",
|
"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)
|
cloud = Cloud("cloud1", str(uuid.uuid4()), compute_project, manager, ports=None)
|
||||||
assert cloud.__json__() == {
|
assert cloud.__json__() == {
|
||||||
"name": "cloud1",
|
"name": "cloud1",
|
||||||
|
"usage": "",
|
||||||
"node_id": cloud.id,
|
"node_id": cloud.id,
|
||||||
"project_id": compute_project.id,
|
"project_id": compute_project.id,
|
||||||
"remote_console_host": "",
|
"remote_console_host": "",
|
||||||
|
@ -26,6 +26,7 @@ def test_json_gns3vm(on_gns3vm, compute_project):
|
|||||||
nat = Nat("nat1", str(uuid.uuid4()), compute_project, MagicMock())
|
nat = Nat("nat1", str(uuid.uuid4()), compute_project, MagicMock())
|
||||||
assert nat.__json__() == {
|
assert nat.__json__() == {
|
||||||
"name": "nat1",
|
"name": "nat1",
|
||||||
|
"usage": "",
|
||||||
"node_id": nat.id,
|
"node_id": nat.id,
|
||||||
"project_id": compute_project.id,
|
"project_id": compute_project.id,
|
||||||
"status": "started",
|
"status": "started",
|
||||||
@ -48,6 +49,7 @@ def test_json_darwin(darwin_platform, compute_project):
|
|||||||
nat = Nat("nat1", str(uuid.uuid4()), compute_project, MagicMock())
|
nat = Nat("nat1", str(uuid.uuid4()), compute_project, MagicMock())
|
||||||
assert nat.__json__() == {
|
assert nat.__json__() == {
|
||||||
"name": "nat1",
|
"name": "nat1",
|
||||||
|
"usage": "",
|
||||||
"node_id": nat.id,
|
"node_id": nat.id,
|
||||||
"project_id": compute_project.id,
|
"project_id": compute_project.id,
|
||||||
"status": "started",
|
"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())
|
nat = Nat("nat1", str(uuid.uuid4()), project, MagicMock())
|
||||||
assert nat.__json__() == {
|
assert nat.__json__() == {
|
||||||
"name": "nat1",
|
"name": "nat1",
|
||||||
|
"usage": "",
|
||||||
"node_id": nat.id,
|
"node_id": nat.id,
|
||||||
"project_id": project.id,
|
"project_id": project.id,
|
||||||
"status": "started",
|
"status": "started",
|
||||||
|
Loading…
Reference in New Issue
Block a user