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"