mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-06-21 00:22:56 +00:00
Checks for valid hostname on server side for Dynamips, IOU, Qemu and Docker nodes
This commit is contained in:
@ -37,6 +37,7 @@ from ..dynamips_error import DynamipsError
|
||||
|
||||
from gns3server.utils.file_watcher import FileWatcher
|
||||
from gns3server.utils.asyncio import wait_run_in_executor, monitor_process
|
||||
from gns3server.utils.hostname import is_ios_hostname_valid
|
||||
from gns3server.utils.images import md5sum
|
||||
|
||||
|
||||
@ -75,6 +76,9 @@ class Router(BaseNode):
|
||||
ghost_flag=False,
|
||||
):
|
||||
|
||||
if not is_ios_hostname_valid(name):
|
||||
raise DynamipsError(f"{name} is an invalid name to create a Dynamips node")
|
||||
|
||||
super().__init__(
|
||||
name, node_id, project, manager, console=console, console_type=console_type, aux=aux, aux_type=aux_type
|
||||
)
|
||||
@ -1653,6 +1657,9 @@ class Router(BaseNode):
|
||||
:param new_name: new name string
|
||||
"""
|
||||
|
||||
if not is_ios_hostname_valid(new_name):
|
||||
raise DynamipsError(f"{new_name} is an invalid name to rename router '{self._name}'")
|
||||
|
||||
await self._hypervisor.send(f'vm rename "{self._name}" "{new_name}"')
|
||||
|
||||
# change the hostname in the startup-config
|
||||
|
Reference in New Issue
Block a user