2020-10-31 04:37:12 +00:00
#
# Copyright (C) 2020 GNS3 Technologies Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2020-10-31 05:32:21 +00:00
from . templates import Category , TemplateBase
from . qemu_nodes import (
2020-10-31 04:37:12 +00:00
QemuConsoleType ,
QemuPlatform ,
QemuAdapterType ,
QemuOnCloseAction ,
QemuBootPriority ,
QemuDiskInterfaceType ,
QemuProcessPriority ,
CustomAdapter
)
from pydantic import Field
from typing import Optional , List
class QemuTemplate ( TemplateBase ) :
category : Optional [ Category ] = " guest "
default_name_format : Optional [ str ] = " {name} - {0} "
symbol : Optional [ str ] = " :/symbols/qemu_guest.svg "
2020-11-11 06:48:41 +00:00
qemu_path : Optional [ str ] = Field ( " " , description = " Qemu executable path " )
2020-10-31 04:37:12 +00:00
platform : Optional [ QemuPlatform ] = Field ( " i386 " , description = " Platform to emulate " )
linked_clone : Optional [ bool ] = Field ( True , description = " Whether the VM is a linked clone or not " )
ram : Optional [ int ] = Field ( 256 , description = " Amount of RAM in MB " )
cpus : Optional [ int ] = Field ( 1 , ge = 1 , le = 255 , description = " Number of vCPUs " )
maxcpus : Optional [ int ] = Field ( 1 , ge = 1 , le = 255 , description = " Maximum number of hotpluggable vCPUs " )
adapters : Optional [ int ] = Field ( 1 , ge = 0 , le = 275 , description = " Number of adapters " )
adapter_type : Optional [ QemuAdapterType ] = Field ( " e1000 " , description = " QEMU adapter type " )
mac_address : Optional [ str ] = Field ( " " , description = " QEMU MAC address " , regex = " ^([0-9a-fA-F] {2} [:]) {5} ([0-9a-fA-F] {2} )$|^$ " )
first_port_name : Optional [ str ] = Field ( " " , description = " Optional name of the first networking port example: eth0 " )
port_name_format : Optional [ str ] = Field ( " Ethernet {0} " , description = " Optional formatting of the networking port example: eth {0} " )
port_segment_size : Optional [ int ] = Field ( 0 , description = " Optional port segment size. A port segment is a block of port. For example Ethernet0/0 Ethernet0/1 is the module 0 with a port segment size of 2 " )
console_type : Optional [ QemuConsoleType ] = Field ( " telnet " , description = " Console type " )
console_auto_start : Optional [ bool ] = Field ( False , description = " Automatically start the console when the node has started " )
aux_type : Optional [ QemuConsoleType ] = Field ( " none " , description = " Auxiliary console type " )
boot_priority : Optional [ QemuBootPriority ] = Field ( " c " , description = " QEMU boot priority " )
2020-11-11 06:48:41 +00:00
hda_disk_image : Optional [ str ] = Field ( " " , description = " QEMU hda disk image path " )
2020-10-31 04:37:12 +00:00
hda_disk_interface : Optional [ QemuDiskInterfaceType ] = Field ( " none " , description = " QEMU hda interface " )
2020-11-11 06:48:41 +00:00
hdb_disk_image : Optional [ str ] = Field ( " " , description = " QEMU hdb disk image path " )
2020-10-31 04:37:12 +00:00
hdb_disk_interface : Optional [ QemuDiskInterfaceType ] = Field ( " none " , description = " QEMU hdb interface " )
2020-11-11 06:48:41 +00:00
hdc_disk_image : Optional [ str ] = Field ( " " , description = " QEMU hdc disk image path " )
2020-10-31 04:37:12 +00:00
hdc_disk_interface : Optional [ QemuDiskInterfaceType ] = Field ( " none " , description = " QEMU hdc interface " )
2020-11-11 06:48:41 +00:00
hdd_disk_image : Optional [ str ] = Field ( " " , description = " QEMU hdd disk image path " )
2020-10-31 04:37:12 +00:00
hdd_disk_interface : Optional [ QemuDiskInterfaceType ] = Field ( " none " , description = " QEMU hdd interface " )
2020-11-11 06:48:41 +00:00
cdrom_image : Optional [ str ] = Field ( " " , description = " QEMU cdrom image path " )
initrd : Optional [ str ] = Field ( " " , description = " QEMU initrd path " )
kernel_image : Optional [ str ] = Field ( " " , description = " QEMU kernel image path " )
bios_image : Optional [ str ] = Field ( " " , description = " QEMU bios image path " )
2020-10-31 04:37:12 +00:00
kernel_command_line : Optional [ str ] = Field ( " " , description = " QEMU kernel command line " )
legacy_networking : Optional [ bool ] = Field ( False , description = " Use QEMU legagy networking commands (-net syntax) " )
replicate_network_connection_state : Optional [ bool ] = Field ( True , description = " Replicate the network connection state for links in Qemu " )
create_config_disk : Optional [ bool ] = Field ( False , description = " Automatically create a config disk on HDD disk interface (secondary slave) " )
on_close : Optional [ QemuOnCloseAction ] = Field ( " power_off " , description = " Action to execute on the VM is closed " )
cpu_throttling : Optional [ int ] = Field ( 0 , ge = 0 , le = 800 , description = " Percentage of CPU allowed for QEMU " )
process_priority : Optional [ QemuProcessPriority ] = Field ( " normal " , description = " Process priority for QEMU " )
options : Optional [ str ] = Field ( " " , description = " Additional QEMU options " )
2021-04-02 07:15:16 +00:00
custom_adapters : Optional [ List [ CustomAdapter ] ] = Field ( default_factory = list , description = " Custom adapters " )