From e9fef928b08ef49d5d3b170ec065bd2e07514438 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 16 May 2017 10:49:45 +0200 Subject: [PATCH] Fix dynamips node creation error --- gns3server/controller/node.py | 3 ++- tests/controller/test_node.py | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/gns3server/controller/node.py b/gns3server/controller/node.py index ade3c695..5a8783c6 100644 --- a/gns3server/controller/node.py +++ b/gns3server/controller/node.py @@ -98,7 +98,8 @@ class Node: log.critical("Can't set attribute %s", prop) raise e else: - self.properties[prop] = kwargs[prop] + if prop not in self.CONTROLLER_ONLY_PROPERTIES and kwargs[prop] is not None and kwargs[prop] != "": + self.properties[prop] = kwargs[prop] if self._symbol is None: self.symbol = ":/symbols/computer.svg" diff --git a/tests/controller/test_node.py b/tests/controller/test_node.py index e979b7dc..6421e727 100644 --- a/tests/controller/test_node.py +++ b/tests/controller/test_node.py @@ -83,7 +83,7 @@ def test_name(compute, project): def test_vmname(compute, project): """ - Additionnal properties should add to the properties + Additionnal properties should be add to the properties field """ node = Node(project, compute, "PC", @@ -93,6 +93,23 @@ def test_vmname(compute, project): assert node.properties["vmname"] == "test" +def test_empty_properties(compute, project): + """ + Empty properties need to be ignored + """ + node = Node(project, compute, "PC", + node_id=str(uuid.uuid4()), + node_type="virtualbox", + aa="", + bb=None, + category=2, + cc="xx") + assert "aa" not in node.properties + assert "bb" not in node.properties + assert "cc" in node.properties + assert "category" not in node.properties # Controller only + + def test_eq(compute, project, node, controller): assert node == Node(project, compute, "demo1", node_id=node.id, node_type="qemu") assert node != "a"