mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 00:38:10 +00:00
Avoid duplicate node name when reloading a project
This commit is contained in:
parent
c9bdd76922
commit
bda1812811
@ -54,7 +54,15 @@ class Node:
|
|||||||
self._compute = compute
|
self._compute = compute
|
||||||
self._node_type = node_type
|
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 = None
|
||||||
self._console_type = None
|
self._console_type = None
|
||||||
self._properties = {}
|
self._properties = {}
|
||||||
@ -67,13 +75,7 @@ class Node:
|
|||||||
self._y = 0
|
self._y = 0
|
||||||
self._z = 0
|
self._z = 0
|
||||||
self._symbol = ":/symbols/computer.svg"
|
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
|
# Update node properties with additional elements
|
||||||
for prop in kwargs:
|
for prop in kwargs:
|
||||||
try:
|
try:
|
||||||
|
@ -51,10 +51,10 @@ def node(compute, project):
|
|||||||
|
|
||||||
|
|
||||||
def test_eq(compute, project, node, controller):
|
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 != "a"
|
||||||
assert node != Node(project, compute, "demo", node_id=str(uuid.uuid4()), 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, "demo", node_id=node.id, 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):
|
def test_json(node, compute):
|
||||||
|
@ -116,16 +116,16 @@ def test_choose_capture_side(async_run, project):
|
|||||||
|
|
||||||
assert link._choose_capture_side()["node"] == node_iou
|
assert link._choose_capture_side()["node"] == node_iou
|
||||||
|
|
||||||
node_vpcs = Node(project, compute1, "node1", node_type="vpcs")
|
node_vpcs = Node(project, compute1, "node3", node_type="vpcs")
|
||||||
node_vpcs2 = Node(project, compute1, "node2", node_type="vpcs")
|
node_vpcs2 = Node(project, compute1, "node4", node_type="vpcs")
|
||||||
|
|
||||||
link = UDPLink(project)
|
link = UDPLink(project)
|
||||||
async_run(link.add_node(node_vpcs, 0, 4))
|
async_run(link.add_node(node_vpcs, 0, 4))
|
||||||
async_run(link.add_node(node_vpcs2, 3, 1))
|
async_run(link.add_node(node_vpcs2, 3, 1))
|
||||||
|
|
||||||
# Capture should run on the local node
|
# Capture should run on the local node
|
||||||
node_iou = Node(project, compute1, "node1", node_type="iou")
|
node_iou = Node(project, compute1, "node5", node_type="iou")
|
||||||
node_iou2 = Node(project, compute2, "node2", node_type="iou")
|
node_iou2 = Node(project, compute2, "node6", node_type="iou")
|
||||||
|
|
||||||
link = UDPLink(project)
|
link = UDPLink(project)
|
||||||
async_run(link.add_node(node_iou, 0, 4))
|
async_run(link.add_node(node_iou, 0, 4))
|
||||||
|
Loading…
Reference in New Issue
Block a user