|
|
|
@ -389,45 +389,50 @@ def test_build_command_with_invalid_options(vm, loop, fake_qemu_binary):
|
|
|
|
|
|
|
|
|
|
def test_hda_disk_image(vm, tmpdir):
|
|
|
|
|
|
|
|
|
|
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
|
|
|
|
vm.hda_disk_image = "/tmp/test"
|
|
|
|
|
assert vm.hda_disk_image == "/tmp/test"
|
|
|
|
|
vm.hda_disk_image = "test"
|
|
|
|
|
assert vm.hda_disk_image == str(tmpdir / "QEMU" / "test")
|
|
|
|
|
vm.manager.config.set("Server", "images_path", str(tmpdir))
|
|
|
|
|
|
|
|
|
|
vm.hda_disk_image = "/tmp/test"
|
|
|
|
|
assert vm.hda_disk_image == "/tmp/test"
|
|
|
|
|
vm.hda_disk_image = "test"
|
|
|
|
|
assert vm.hda_disk_image == str(tmpdir / "QEMU" / "test")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_hda_disk_image_ova(vm, tmpdir):
|
|
|
|
|
|
|
|
|
|
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
|
|
|
|
vm.hda_disk_image = "test.ovf/test.vmdk"
|
|
|
|
|
assert vm.hda_disk_image == str(tmpdir / "QEMU" / "test.ovf" / "test.vmdk")
|
|
|
|
|
vm.manager.config.set("Server", "images_path", str(tmpdir))
|
|
|
|
|
|
|
|
|
|
vm.hda_disk_image = "test.ovf/test.vmdk"
|
|
|
|
|
assert vm.hda_disk_image == str(tmpdir / "QEMU" / "test.ovf" / "test.vmdk")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_hdb_disk_image(vm, tmpdir):
|
|
|
|
|
|
|
|
|
|
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
|
|
|
|
vm.hdb_disk_image = "/tmp/test"
|
|
|
|
|
assert vm.hdb_disk_image == "/tmp/test"
|
|
|
|
|
vm.hdb_disk_image = "test"
|
|
|
|
|
assert vm.hdb_disk_image == str(tmpdir / "QEMU" / "test")
|
|
|
|
|
vm.manager.config.set("Server", "images_path", str(tmpdir))
|
|
|
|
|
|
|
|
|
|
vm.hdb_disk_image = "/tmp/test"
|
|
|
|
|
assert vm.hdb_disk_image == "/tmp/test"
|
|
|
|
|
vm.hdb_disk_image = "test"
|
|
|
|
|
assert vm.hdb_disk_image == str(tmpdir / "QEMU" / "test")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_hdc_disk_image(vm, tmpdir):
|
|
|
|
|
|
|
|
|
|
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
|
|
|
|
vm.hdc_disk_image = "/tmp/test"
|
|
|
|
|
assert vm.hdc_disk_image == "/tmp/test"
|
|
|
|
|
vm.hdc_disk_image = "test"
|
|
|
|
|
assert vm.hdc_disk_image == str(tmpdir / "QEMU" / "test")
|
|
|
|
|
vm.manager.config.set("Server", "images_path", str(tmpdir))
|
|
|
|
|
|
|
|
|
|
vm.hdc_disk_image = "/tmp/test"
|
|
|
|
|
assert vm.hdc_disk_image == "/tmp/test"
|
|
|
|
|
vm.hdc_disk_image = "test"
|
|
|
|
|
assert vm.hdc_disk_image == str(tmpdir / "QEMU" / "test")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_hdd_disk_image(vm, tmpdir):
|
|
|
|
|
|
|
|
|
|
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
|
|
|
|
vm.hdd_disk_image = "/tmp/test"
|
|
|
|
|
assert vm.hdd_disk_image == "/tmp/test"
|
|
|
|
|
vm.hdd_disk_image = "test"
|
|
|
|
|
assert vm.hdd_disk_image == str(tmpdir / "QEMU" / "test")
|
|
|
|
|
vm.manager.config.set("Server", "images_path", str(tmpdir))
|
|
|
|
|
|
|
|
|
|
vm.hdd_disk_image = "/tmp/test"
|
|
|
|
|
assert vm.hdd_disk_image == "/tmp/test"
|
|
|
|
|
vm.hdd_disk_image = "test"
|
|
|
|
|
assert vm.hdd_disk_image == str(tmpdir / "QEMU" / "test")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_options(vm):
|
|
|
|
@ -455,48 +460,41 @@ def test_get_qemu_img_not_exist(vm, tmpdir):
|
|
|
|
|
|
|
|
|
|
def test_run_with_kvm_darwin(darwin_platform, vm):
|
|
|
|
|
|
|
|
|
|
with patch("configparser.SectionProxy.getboolean", return_value=True):
|
|
|
|
|
assert vm._run_with_kvm("qemu-system-x86_64", "") is False
|
|
|
|
|
vm.manager.config.set("Qemu", "enable_kvm", False)
|
|
|
|
|
assert vm._run_with_kvm("qemu-system-x86_64", "") is False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_run_with_kvm_windows(windows_platform, vm):
|
|
|
|
|
|
|
|
|
|
with patch("configparser.SectionProxy.getboolean", return_value=True):
|
|
|
|
|
assert vm._run_with_kvm("qemu-system-x86_64.exe", "") is False
|
|
|
|
|
vm.manager.config.set("Qemu", "enable_kvm", False)
|
|
|
|
|
assert vm._run_with_kvm("qemu-system-x86_64.exe", "") is False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_run_with_kvm_linux(linux_platform, vm):
|
|
|
|
|
|
|
|
|
|
with patch("os.path.exists", return_value=True) as os_path:
|
|
|
|
|
with patch("configparser.SectionProxy.getboolean", return_value=True):
|
|
|
|
|
assert vm._run_with_kvm("qemu-system-x86_64", "") is True
|
|
|
|
|
os_path.assert_called_with("/dev/kvm")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_run_with_kvm_linux_config_desactivated(linux_platform, vm):
|
|
|
|
|
|
|
|
|
|
with patch("os.path.exists", return_value=True) as os_path:
|
|
|
|
|
with patch("configparser.SectionProxy.getboolean", return_value=False):
|
|
|
|
|
assert vm._run_with_kvm("qemu-system-x86_64", "") is False
|
|
|
|
|
vm.manager.config.set("Qemu", "enable_kvm", True)
|
|
|
|
|
assert vm._run_with_kvm("qemu-system-x86_64", "") is True
|
|
|
|
|
os_path.assert_called_with("/dev/kvm")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_run_with_kvm_linux_options_no_kvm(linux_platform, vm):
|
|
|
|
|
|
|
|
|
|
with patch("os.path.exists", return_value=True) as os_path:
|
|
|
|
|
with patch("configparser.SectionProxy.getboolean", return_value=True):
|
|
|
|
|
assert vm._run_with_kvm("qemu-system-x86_64", "-no-kvm") is False
|
|
|
|
|
vm.manager.config.set("Qemu", "enable_kvm", True)
|
|
|
|
|
assert vm._run_with_kvm("qemu-system-x86_64", "-no-kvm") is False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_run_with_kvm_not_x86(linux_platform, vm):
|
|
|
|
|
|
|
|
|
|
with patch("os.path.exists", return_value=True) as os_path:
|
|
|
|
|
with patch("configparser.SectionProxy.getboolean", return_value=True):
|
|
|
|
|
assert vm._run_with_kvm("qemu-system-arm", "") is False
|
|
|
|
|
vm.manager.config.set("Qemu", "enable_kvm", True)
|
|
|
|
|
assert vm._run_with_kvm("qemu-system-arm", "") is False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_run_with_kvm_linux_dev_kvm_missing(linux_platform, vm):
|
|
|
|
|
|
|
|
|
|
with patch("os.path.exists", return_value=False) as os_path:
|
|
|
|
|
with patch("configparser.SectionProxy.getboolean", return_value=True):
|
|
|
|
|
with pytest.raises(QemuError):
|
|
|
|
|
vm._run_with_kvm("qemu-system-x86_64", "")
|
|
|
|
|
vm.manager.config.set("Qemu", "enable_kvm", True)
|
|
|
|
|
with pytest.raises(QemuError):
|
|
|
|
|
vm._run_with_kvm("qemu-system-x86_64", "")
|
|
|
|
|