1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-29 02:08:10 +00:00

Add appliance UUID added to the node data. Fixes #1334.

This commit is contained in:
grossmj 2018-08-09 17:45:33 +07:00
parent a54359d243
commit 89f7169589
3 changed files with 13 additions and 2 deletions

View File

@ -38,13 +38,14 @@ class Node:
"port_name_format", "first_port_name", "port_segment_size", "ports",
"category", "console_auto_start"]
def __init__(self, project, compute, name, node_id=None, node_type=None, **kwargs):
def __init__(self, project, compute, name, node_id=None, node_type=None, appliance_id=None, **kwargs):
"""
:param project: Project of the node
:param compute: Compute server where the server will run
:param name: Node name
:param node_id: UUID of the node (integer)
:param node_type: Type of emulator
:param appliance_id: Appliance ID used to create this node
:param kwargs: Node properties
"""
@ -69,6 +70,7 @@ class Node:
self._command_line = None
self._node_directory = None
self._status = "stopped"
self._appliance_id = appliance_id
self._x = 0
self._y = 0
self._z = 1 # default z value is 1
@ -683,6 +685,7 @@ class Node:
"compute_id": str(self._compute.id),
"node_id": self._id,
"node_type": self._node_type,
"appliance_id": self._appliance_id,
"name": self._name,
"console": self._console,
"console_type": self._console_type,
@ -704,6 +707,7 @@ class Node:
"compute_id": str(self._compute.id),
"project_id": self._project.id,
"node_id": self._id,
"appliance_id": self._appliance_id,
"node_type": self._node_type,
"node_directory": self._node_directory,
"name": self._name,

View File

@ -480,7 +480,7 @@ class Project:
default_name_format = template.pop("default_name_format", "{name}-{0}")
name = default_name_format.replace("{name}", name)
node_id = str(uuid.uuid4())
node = yield from self.add_node(compute, name, node_id, node_type=node_type, **template)
node = yield from self.add_node(compute, name, node_id, node_type=node_type, appliance_id=appliance_id, **template)
return node
@open_required

View File

@ -119,6 +119,13 @@ NODE_OBJECT_SCHEMA = {
"maxLength": 36,
"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}$"
},
"appliance_id": {
"description": "Appliance UUID from which the node has been created. Read only",
"type": ["null", "string"],
"minLength": 36,
"maxLength": 36,
"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_type": NODE_TYPE_SCHEMA,
"node_directory": {
"description": "Working directory of the node. Read only",