1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-25 16:28:11 +00:00

Avoid duplicate node name when reloading a project

This commit is contained in:
Julien Duponchelle 2016-07-18 19:09:08 +02:00
parent c9bdd76922
commit bda1812811
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
3 changed files with 17 additions and 15 deletions

View File

@ -54,7 +54,15 @@ class Node:
self._compute = compute
self._node_type = node_type
self._name = name
self._label = {
"y": -25,
"text": "",
"style": "font-size: 10;font-familly: Verdana",
"x": -17,
"rotation": 0
}
self._name = None
self.name = name
self._console = None
self._console_type = None
self._properties = {}
@ -67,13 +75,7 @@ class Node:
self._y = 0
self._z = 0
self._symbol = ":/symbols/computer.svg"
self._label = {
"y": -25,
"text": "",
"style": "font-size: 10;font-familly: Verdana",
"x": -17,
"rotation": 0
}
# Update node properties with additional elements
for prop in kwargs:
try:

View File

@ -51,10 +51,10 @@ def node(compute, project):
def test_eq(compute, project, node, controller):
assert node == Node(project, compute, "demo", node_id=node.id, node_type="qemu")
assert node == Node(project, compute, "demo1", node_id=node.id, node_type="qemu")
assert node != "a"
assert node != Node(project, compute, "demo", node_id=str(uuid.uuid4()), node_type="qemu")
assert node != Node(Project(str(uuid.uuid4()), controller=controller), compute, "demo", node_id=node.id, node_type="qemu")
assert node != Node(project, compute, "demo2", node_id=str(uuid.uuid4()), node_type="qemu")
assert node != Node(Project(str(uuid.uuid4()), controller=controller), compute, "demo3", node_id=node.id, node_type="qemu")
def test_json(node, compute):

View File

@ -116,16 +116,16 @@ def test_choose_capture_side(async_run, project):
assert link._choose_capture_side()["node"] == node_iou
node_vpcs = Node(project, compute1, "node1", node_type="vpcs")
node_vpcs2 = Node(project, compute1, "node2", node_type="vpcs")
node_vpcs = Node(project, compute1, "node3", node_type="vpcs")
node_vpcs2 = Node(project, compute1, "node4", node_type="vpcs")
link = UDPLink(project)
async_run(link.add_node(node_vpcs, 0, 4))
async_run(link.add_node(node_vpcs2, 3, 1))
# Capture should run on the local node
node_iou = Node(project, compute1, "node1", node_type="iou")
node_iou2 = Node(project, compute2, "node2", node_type="iou")
node_iou = Node(project, compute1, "node5", node_type="iou")
node_iou2 = Node(project, compute2, "node6", node_type="iou")
link = UDPLink(project)
async_run(link.add_node(node_iou, 0, 4))