mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 16:28:11 +00:00
parent
1ed88eda85
commit
b9bd6aa501
@ -260,6 +260,9 @@ class GNS3VM:
|
||||
"""
|
||||
engine = self.current_engine()
|
||||
if not engine.running:
|
||||
if self._settings["vmname"] is None:
|
||||
return
|
||||
|
||||
log.info("Start the GNS3 VM")
|
||||
engine.vmname = self._settings["vmname"]
|
||||
engine.ram = self._settings["ram"]
|
||||
|
@ -376,7 +376,8 @@ def test_getProject(controller, async_run):
|
||||
def test_start(controller, async_run):
|
||||
controller.gns3vm.settings = {
|
||||
"enable": False,
|
||||
"engine": "vmware"
|
||||
"engine": "vmware",
|
||||
"vmname": "GNS3 VM"
|
||||
}
|
||||
with asyncio_patch("gns3server.controller.compute.Compute.connect") as mock:
|
||||
async_run(controller.start())
|
||||
@ -390,7 +391,8 @@ def test_start_vm(controller, async_run):
|
||||
"""
|
||||
controller.gns3vm.settings = {
|
||||
"enable": True,
|
||||
"engine": "vmware"
|
||||
"engine": "vmware",
|
||||
"vmname": "GNS3 VM"
|
||||
}
|
||||
with asyncio_patch("gns3server.controller.gns3vm.vmware_gns3_vm.VMwareGNS3VM.start") as mock:
|
||||
with asyncio_patch("gns3server.controller.compute.Compute.connect") as mock_connect:
|
||||
@ -415,7 +417,8 @@ def test_stop_vm(controller, async_run):
|
||||
controller.gns3vm.settings = {
|
||||
"enable": True,
|
||||
"engine": "vmware",
|
||||
"when_exit": "stop"
|
||||
"when_exit": "stop",
|
||||
"vmname": "GNS3 VM"
|
||||
}
|
||||
controller.gns3vm.current_engine().running = True
|
||||
with asyncio_patch("gns3server.controller.gns3vm.vmware_gns3_vm.VMwareGNS3VM.stop") as mock:
|
||||
@ -430,7 +433,8 @@ def test_suspend_vm(controller, async_run):
|
||||
controller.gns3vm.settings = {
|
||||
"enable": True,
|
||||
"engine": "vmware",
|
||||
"when_exit": "suspend"
|
||||
"when_exit": "suspend",
|
||||
"vmname": "GNS3 VM"
|
||||
}
|
||||
controller.gns3vm.current_engine().running = True
|
||||
with asyncio_patch("gns3server.controller.gns3vm.vmware_gns3_vm.VMwareGNS3VM.suspend") as mock:
|
||||
@ -445,7 +449,8 @@ def test_keep_vm(controller, async_run):
|
||||
controller.gns3vm.settings = {
|
||||
"enable": True,
|
||||
"engine": "vmware",
|
||||
"when_exit": "keep"
|
||||
"when_exit": "keep",
|
||||
"vmname": "GNS3 VM"
|
||||
}
|
||||
controller.gns3vm.current_engine().running = True
|
||||
with asyncio_patch("gns3server.controller.gns3vm.vmware_gns3_vm.VMwareGNS3VM.suspend") as mock:
|
||||
|
@ -21,6 +21,7 @@ from tests.utils import asyncio_patch, AsyncioMagicMock
|
||||
from gns3server.controller.gns3vm import GNS3VM
|
||||
from gns3server.controller.gns3vm.gns3_vm_error import GNS3VMError
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def dummy_engine():
|
||||
engine = AsyncioMagicMock()
|
||||
@ -65,7 +66,8 @@ def test_update_settings(controller, async_run):
|
||||
vm = GNS3VM(controller)
|
||||
vm.settings = {
|
||||
"enable": True,
|
||||
"engine": "vmware"
|
||||
"engine": "vmware",
|
||||
"vmname": "GNS3 VM"
|
||||
}
|
||||
with asyncio_patch("gns3server.controller.gns3vm.vmware_gns3_vm.VMwareGNS3VM.start"):
|
||||
async_run(vm.auto_start_vm())
|
||||
@ -94,4 +96,3 @@ def test_auto_start_with_error(async_run, controller, dummy_gns3vm, dummy_engine
|
||||
async_run(dummy_gns3vm.auto_start_vm())
|
||||
assert dummy_engine.start.called
|
||||
assert controller.computes["vm"].name == "GNS3 VM (Test VM)"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user