Checks for valid hostname on server side for Dynamips, IOU, Qemu and Docker nodes

This commit is contained in:
grossmj
2022-07-17 11:51:29 +02:00
parent 86368a1177
commit 80f5ca0c3f
13 changed files with 233 additions and 30 deletions

View File

@ -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