mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
OVA file support
This commit is contained in:
1 parent
034ac392b7
commit
3d7d8682ee
7 files changed
+102
-10
No files matched your search
@@ -232,6 +232,25 @@ def test_upload_vm(server, tmpdir):
|
||||
assert checksum == "033bd94b1168d7e4f0d644c3c95e35bf"
|
||||
|
||||
|
||||
def test_upload_vm_ova(server, tmpdir):
|
||||
with patch("gns3server.modules.Qemu.get_images_directory", return_value=str(tmpdir),):
|
||||
response = server.post("/qemu/vms/test2.ova/test2.vmdk", body="TEST", raw=True)
|
||||
assert response.status == 204
|
||||
|
||||
with open(str(tmpdir / "test2.ova" / "test2.vmdk")) as f:
|
||||
assert f.read() == "TEST"
|
||||
|
||||
with open(str(tmpdir / "test2.ova" / "test2.vmdk.md5sum")) as f:
|
||||
checksum = f.read()
|
||||
assert checksum == "033bd94b1168d7e4f0d644c3c95e35bf"
|
||||
|
||||
|
||||
def test_upload_vm_forbiden_location(server, tmpdir):
|
||||
with patch("gns3server.modules.Qemu.get_images_directory", return_value=str(tmpdir),):
|
||||
response = server.post("/qemu/vms/../../test2", body="TEST", raw=True)
|
||||
assert response.status == 403
|
||||
|
||||
|
||||
def test_upload_vm_permission_denied(server, tmpdir):
|
||||
with open(str(tmpdir / "test2"), "w+") as f:
|
||||
f.write("")
|
||||
|
||||
@@ -396,6 +396,13 @@ def test_hda_disk_image(vm, tmpdir):
|
||||
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")
|
||||
|
||||
|
||||
def test_hdb_disk_image(vm, tmpdir):
|
||||
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
||||
|
||||
@@ -123,6 +123,16 @@ def test_get_relative_image_path(qemu, tmpdir):
|
||||
assert qemu.get_relative_image_path("../test1.bin") == path1
|
||||
|
||||
|
||||
def test_get_relative_image_path_ova(qemu, tmpdir):
|
||||
os.makedirs(str(tmpdir / "QEMU" / "test.ovf"))
|
||||
path = str(tmpdir / "QEMU" / "test.ovf" / "test.bin")
|
||||
open(path, 'w+').close()
|
||||
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
||||
assert qemu.get_relative_image_path(path) == os.path.join("test.ovf", "test.bin")
|
||||
assert qemu.get_relative_image_path(os.path.join("test.ovf", "test.bin")) == os.path.join("test.ovf", "test.bin")
|
||||
|
||||
|
||||
def test_list_images(loop, qemu, tmpdir):
|
||||
|
||||
fake_images = ["a.bin", "b.bin", ".blu.bin", "a.bin.md5sum"]
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2015 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/>.
|
||||
|
||||
|
||||
from gns3server.utils import force_unix_path
|
||||
|
||||
|
||||
def test_force_unix_path():
|
||||
assert force_unix_path("a/b") == "a/b"
|
||||
assert force_unix_path("a\\b") == "a/b"
|
||||
assert force_unix_path("a\\b\\..\\c") == "a/c"
|
||||
Reference in new issue
Block a user