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:
@ -22,7 +22,6 @@ order to run a QEMU VM.
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import math
|
||||
import shutil
|
||||
import struct
|
||||
@ -47,6 +46,7 @@ from ..base_node import BaseNode
|
||||
from ...utils.asyncio import monitor_process
|
||||
from ...utils.images import md5sum
|
||||
from ...utils import macaddress_to_int, int_to_macaddress
|
||||
from ...utils.hostname import is_rfc1123_hostname_valid
|
||||
|
||||
from gns3server.schemas.compute.qemu_nodes import Qemu, QemuPlatform
|
||||
|
||||
@ -86,6 +86,9 @@ class QemuVM(BaseNode):
|
||||
platform=None,
|
||||
):
|
||||
|
||||
if not is_rfc1123_hostname_valid(name):
|
||||
raise QemuError(f"'{name}' is an invalid name to create a Qemu node")
|
||||
|
||||
super().__init__(
|
||||
name,
|
||||
node_id,
|
||||
@ -172,6 +175,18 @@ class QemuVM(BaseNode):
|
||||
|
||||
log.info(f'QEMU VM "{self._name}" [{self._id}] has been created')
|
||||
|
||||
@BaseNode.name.setter
|
||||
def name(self, new_name):
|
||||
"""
|
||||
Sets the name of this Qemu VM.
|
||||
|
||||
:param new_name: name
|
||||
"""
|
||||
|
||||
if not is_rfc1123_hostname_valid(new_name):
|
||||
raise QemuError(f"'{new_name}' is an invalid name to rename Qemu node '{self._name}'")
|
||||
super(QemuVM, QemuVM).name.__set__(self, new_name)
|
||||
|
||||
@property
|
||||
def guest_cid(self):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user