mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-21 05:35:15 +02:00
fix(controller): make node names from template names valid hostnames
Creating a node from a template whose name has characters invalid in a hostname, such as "MikroTik CCR1072-1G-8S+", failed on the compute with "'MikroTikCCR1072-1G-8S+-1' is an invalid name to create a Qemu node": the template name was only stripped of spaces. Replace the other invalid characters by hyphens, following the rules the compute validates node names with (RFC 1123 for Qemu and Docker, IOS for Dynamips and IOU), as project import already does for existing nodes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b9cf9158ca
commit
dd69a01fba
4 files changed
+69
-1
No files matched your search
@@ -38,6 +38,7 @@ from ..config import Config
|
||||
from ..utils.application_id import get_next_application_id, is_iol_runner_environment
|
||||
from ..utils.asyncio import aiozipstream, locking, wait_run_in_executor
|
||||
from ..utils.asyncio.pool import Pool
|
||||
from ..utils.hostname import template_name_to_node_name
|
||||
from ..utils.packet_filter_validation import validate_bpf_syntax
|
||||
from ..utils.path import check_path_allowed, get_default_project_directory
|
||||
from .compute import ComputeError
|
||||
@@ -622,7 +623,7 @@ class Project:
|
||||
log.info(f'Creating node from template "{template_name}" on compute "{compute.name}" [{compute.id}]')
|
||||
default_name_format = template.pop("default_name_format", "{name}-{0}")
|
||||
if name is None:
|
||||
name = default_name_format.replace("{name}", template_name)
|
||||
name = default_name_format.replace("{name}", template_name_to_node_name(template_name, node_type))
|
||||
# the appliance metadata stays template level: only the default
|
||||
# credentials are seeded on the node (where they can be overridden)
|
||||
appliance_metadata = template.pop("appliance_metadata", None) or {}
|
||||
|
||||
Reference in new issue
Block a user