mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Raise error if using a non linked clone VM twice
Fix https://github.com/GNS3/gns3-gui/issues/1593
This commit is contained in:
20 files changed
+100
-54
No files matched your search
@@ -33,7 +33,7 @@ from unittest.mock import patch, MagicMock, PropertyMock, call
|
||||
from gns3server.config import Config
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture()
|
||||
def manager(port_manager):
|
||||
m = Docker.instance()
|
||||
m.port_manager = port_manager
|
||||
|
||||
@@ -28,7 +28,7 @@ from gns3server.compute.dynamips.dynamips_error import DynamipsError
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture
|
||||
def manager(port_manager):
|
||||
m = Dynamips.instance()
|
||||
m.port_manager = port_manager
|
||||
|
||||
@@ -26,7 +26,7 @@ from gns3server.compute.dynamips import Dynamips
|
||||
from gns3server.config import Config
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture
|
||||
def manager(port_manager):
|
||||
m = Dynamips.instance()
|
||||
m.port_manager = port_manager
|
||||
|
||||
@@ -39,7 +39,7 @@ if not sys.platform.startswith("win"):
|
||||
from gns3server.config import Config
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture
|
||||
def manager(port_manager):
|
||||
m = IOU.instance()
|
||||
m.port_manager = port_manager
|
||||
|
||||
@@ -35,7 +35,7 @@ from gns3server.utils import force_unix_path, macaddress_to_int, int_to_macaddre
|
||||
from gns3server.compute.notification_manager import NotificationManager
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture
|
||||
def manager(port_manager):
|
||||
m = Qemu.instance()
|
||||
m.port_manager = port_manager
|
||||
@@ -601,6 +601,22 @@ def test_hda_disk_image(vm, images_dir):
|
||||
assert vm.hda_disk_image == force_unix_path(os.path.join(images_dir, "QEMU", "test2"))
|
||||
|
||||
|
||||
def test_hda_disk_image_non_linked_clone(vm, images_dir, project, manager, fake_qemu_binary, fake_qemu_img_binary):
|
||||
"""
|
||||
Two non linked can't use the same image at the same time
|
||||
"""
|
||||
|
||||
open(os.path.join(images_dir, "test1"), "w+").close()
|
||||
vm.linked_clone = False
|
||||
vm.hda_disk_image = os.path.join(images_dir, "test1")
|
||||
vm.manager._nodes[vm.id] = vm
|
||||
|
||||
vm2 = QemuVM("test", "00010203-0405-0607-0809-0a0b0c0d0eaa", project, manager, qemu_path=fake_qemu_binary)
|
||||
vm2.linked_clone = False
|
||||
with pytest.raises(QemuError):
|
||||
vm2.hda_disk_image = os.path.join(images_dir, "test1")
|
||||
|
||||
|
||||
def test_hda_disk_image_ova(vm, images_dir):
|
||||
|
||||
os.makedirs(os.path.join(images_dir, "QEMU", "test.ovf"))
|
||||
|
||||
@@ -30,7 +30,7 @@ from gns3server.compute.error import NodeError
|
||||
from gns3server.compute.vpcs import VPCS
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture(scope="function")
|
||||
def manager(port_manager):
|
||||
m = VPCS.instance()
|
||||
m.port_manager = port_manager
|
||||
|
||||
@@ -33,7 +33,7 @@ from gns3server.compute.vpcs import VPCS, VPCSVM
|
||||
from gns3server.config import Config
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture(scope="function")
|
||||
def manager(port_manager):
|
||||
m = VPCS.instance()
|
||||
m.port_manager = port_manager
|
||||
|
||||
@@ -30,7 +30,7 @@ from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError
|
||||
from tests.utils import asyncio_patch
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture
|
||||
def manager(port_manager):
|
||||
m = VirtualBox.instance()
|
||||
m.port_manager = port_manager
|
||||
|
||||
@@ -24,7 +24,7 @@ from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError
|
||||
from gns3server.compute.virtualbox import VirtualBox
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture
|
||||
def manager(port_manager):
|
||||
m = VirtualBox.instance()
|
||||
m.port_manager = port_manager
|
||||
|
||||
@@ -29,7 +29,7 @@ from gns3server.compute.vmware import VMware
|
||||
from tests.utils import asyncio_patch
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture
|
||||
def manager(port_manager):
|
||||
m = VMware.instance()
|
||||
m.port_manager = port_manager
|
||||
|
||||
@@ -24,7 +24,7 @@ from gns3server.compute.vmware.vmware_error import VMwareError
|
||||
from gns3server.compute.vmware import VMware
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture
|
||||
def manager(port_manager):
|
||||
m = VMware.instance()
|
||||
m.port_manager = port_manager
|
||||
|
||||
@@ -31,7 +31,7 @@ from gns3server.compute.vpcs import VPCS
|
||||
from gns3server.compute.notification_manager import NotificationManager
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@pytest.fixture
|
||||
def manager(port_manager):
|
||||
m = VPCS.instance()
|
||||
m.port_manager = port_manager
|
||||
|
||||
+4
-4
@@ -82,9 +82,6 @@ def http_server(request, loop, port_manager, monkeypatch, controller):
|
||||
app = web.Application()
|
||||
for method, route, handler in Route.get_routes():
|
||||
app.router.add_route(method, route, handler)
|
||||
for module in MODULES:
|
||||
instance = module.instance()
|
||||
instance.port_manager = port_manager
|
||||
|
||||
host = "localhost"
|
||||
|
||||
@@ -145,7 +142,7 @@ def project(tmpdir):
|
||||
return p
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@pytest.fixture(scope="function")
|
||||
def port_manager():
|
||||
"""An instance of port manager"""
|
||||
|
||||
@@ -198,6 +195,9 @@ def run_around_tests(monkeypatch, port_manager, controller, config):
|
||||
|
||||
tmppath = tempfile.mkdtemp()
|
||||
|
||||
for module in MODULES:
|
||||
module._instance = None
|
||||
|
||||
port_manager._instance = port_manager
|
||||
os.makedirs(os.path.join(tmppath, 'projects'))
|
||||
config.set("Server", "projects_path", os.path.join(tmppath, 'projects'))
|
||||
|
||||
Reference in new issue
Block a user