From 89f716958974904cd87842b147c20d4296c1e4ad Mon Sep 17 00:00:00 2001 From: grossmj Date: Thu, 9 Aug 2018 17:45:33 +0700 Subject: [PATCH] Add appliance UUID added to the node data. Fixes #1334. --- gns3server/controller/node.py | 6 +++++- gns3server/controller/project.py | 2 +- gns3server/schemas/node.py | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gns3server/controller/node.py b/gns3server/controller/node.py index 801f7193..11562489 100644 --- a/gns3server/controller/node.py +++ b/gns3server/controller/node.py @@ -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, diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index 26bd1904..0e8efc45 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -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 diff --git a/gns3server/schemas/node.py b/gns3server/schemas/node.py index 896b6f94..814480a3 100644 --- a/gns3server/schemas/node.py +++ b/gns3server/schemas/node.py @@ -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",