diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index f7179c2b..6801cb01 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -368,7 +368,8 @@ class Project: if base_name is None: return None base_name = re.sub(r"[ ]", "", base_name) - base_name = re.sub(r"[0-9]+$", "{0}", base_name) + if base_name in self._allocated_node_names: + base_name = re.sub(r"[0-9]+$", "{0}", base_name) if '{0}' in base_name or '{id}' in base_name: # base name is a template, replace {0} or {id} by an unique identifier diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py index bbc0a5f7..1fd54d47 100644 --- a/tests/controller/test_project.py +++ b/tests/controller/test_project.py @@ -602,6 +602,9 @@ def test_node_name(project, async_run): node = async_run(project.add_node(compute, "VPCS-1", None, node_type="vpcs", properties={"startup_config": "test.cfg"})) assert node.name == "VPCS-2" + node = async_run(project.add_node(compute, "R3", None, node_type="vpcs", properties={"startup_config": "test.cfg"})) + assert node.name == "R3" + def test_add_iou_node_and_check_if_gets_application_id(project, async_run): compute = MagicMock()