mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 00:08:11 +00:00
Option to allocate or not the vCPUs and RAM settings for the GNS3 VM. Fixes https://github.com/GNS3/gns3-gui/issues/3069
This commit is contained in:
parent
e182f53d69
commit
d16cb5ef89
@ -49,6 +49,7 @@ class GNS3VM:
|
||||
"headless": False,
|
||||
"enable": False,
|
||||
"engine": "vmware",
|
||||
"allocate_vcpus_ram": True,
|
||||
"ram": 2048,
|
||||
"vcpus": 1,
|
||||
"port": 80,
|
||||
@ -311,6 +312,7 @@ class GNS3VM:
|
||||
if self._settings["vmname"] is None:
|
||||
return
|
||||
log.info("Start the GNS3 VM")
|
||||
engine.allocate_vcpus_ram = self._settings["allocate_vcpus_ram"]
|
||||
engine.vmname = self._settings["vmname"]
|
||||
engine.ram = self._settings["ram"]
|
||||
engine.vcpus = self._settings["vcpus"]
|
||||
|
@ -30,6 +30,7 @@ class BaseGNS3VM:
|
||||
self._ip_address = None
|
||||
self._port = 80 # value not used, will be overwritten
|
||||
self._headless = False
|
||||
self._allocate_vcpus_ram = True
|
||||
self._vcpus = 1
|
||||
self._ram = 1024
|
||||
self._user = ""
|
||||
@ -203,6 +204,26 @@ class BaseGNS3VM:
|
||||
|
||||
self._headless = value
|
||||
|
||||
@property
|
||||
def allocate_vcpus_ram(self):
|
||||
"""
|
||||
Returns whether VCPUs and RAM settings should be configured for the GNS3 VM.
|
||||
|
||||
:returns: boolean
|
||||
"""
|
||||
|
||||
return self._allocate_vcpus_ram
|
||||
|
||||
@allocate_vcpus_ram.setter
|
||||
def allocate_vcpus_ram(self, value):
|
||||
"""
|
||||
Sets whether VCPUs and RAM settings should be configured for the GNS3 VM.
|
||||
|
||||
:param value: boolean
|
||||
"""
|
||||
|
||||
self._allocate_vcpus_ram = value
|
||||
|
||||
@property
|
||||
def vcpus(self):
|
||||
"""
|
||||
|
@ -251,9 +251,10 @@ class HyperVGNS3VM(BaseGNS3VM):
|
||||
raise GNS3VMError("Could not find Hyper-V VM {}".format(self.vmname))
|
||||
|
||||
if not self._is_running():
|
||||
log.info("Update GNS3 VM settings (CPU and RAM)")
|
||||
# set the number of vCPUs and amount of RAM
|
||||
self._set_vcpus_ram(self.vcpus, self.ram)
|
||||
if self.allocate_vcpus_ram:
|
||||
log.info("Update GNS3 VM settings (CPU and RAM)")
|
||||
# set the number of vCPUs and amount of RAM
|
||||
self._set_vcpus_ram(self.vcpus, self.ram)
|
||||
|
||||
# start the VM
|
||||
try:
|
||||
|
@ -15,8 +15,6 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import asyncio
|
||||
|
||||
from .base_gns3_vm import BaseGNS3VM
|
||||
from .gns3_vm_error import GNS3VMError
|
||||
|
||||
|
@ -259,9 +259,12 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
|
||||
log.info('"{}" state is {}'.format(self._vmname, vm_state))
|
||||
|
||||
if vm_state == "poweroff":
|
||||
log.info("Update GNS3 VM settings (CPU, RAM and Hardware Virtualization)")
|
||||
await self.set_vcpus(self.vcpus)
|
||||
await self.set_ram(self.ram)
|
||||
if self.allocate_vcpus_ram:
|
||||
log.info("Update GNS3 VM vCPUs and RAM settings")
|
||||
await self.set_vcpus(self.vcpus)
|
||||
await self.set_ram(self.ram)
|
||||
|
||||
log.info("Update GNS3 VM Hardware Virtualization setting")
|
||||
await self.enable_nested_hw_virt()
|
||||
|
||||
if vm_state in ("poweroff", "saved"):
|
||||
|
@ -148,9 +148,12 @@ class VMwareGNS3VM(BaseGNS3VM):
|
||||
except VMwareError as e:
|
||||
raise GNS3VMError("Could not list VMware VMs: {}".format(str(e)))
|
||||
if not running:
|
||||
log.info("Update GNS3 VM settings (CPU, RAM and Hardware Virtualization)")
|
||||
# set the number of vCPUs and amount of RAM
|
||||
await self._set_vcpus_ram(self.vcpus, self.ram)
|
||||
if self.allocate_vcpus_ram:
|
||||
log.info("Update GNS3 VM vCPUs and RAM settings")
|
||||
await self._set_vcpus_ram(self.vcpus, self.ram)
|
||||
|
||||
log.info("Update GNS3 VM Hardware Virtualization setting")
|
||||
await self._set_extra_options()
|
||||
|
||||
# start the VM
|
||||
|
@ -41,6 +41,10 @@ GNS3VM_SETTINGS_SCHEMA = {
|
||||
"description": "The engine to use for the VM. Null to disable",
|
||||
"enum": ["vmware", "virtualbox", None]
|
||||
},
|
||||
"allocate_vcpus_ram": {
|
||||
"description": "Allocate vCPUS and RAM settings",
|
||||
"type": "boolean"
|
||||
},
|
||||
"vcpus": {
|
||||
"description": "Number of vCPUS affected to the VM",
|
||||
"type": "integer"
|
||||
|
Loading…
Reference in New Issue
Block a user