mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Fix an issue in IOU relative path looking
This commit is contained in:
parent
f31071d510
commit
ddb8a9f06e
@ -139,9 +139,10 @@ class IOUVM(BaseVM):
|
|||||||
|
|
||||||
if not os.path.isabs(path):
|
if not os.path.isabs(path):
|
||||||
server_config = self.manager.config.get_section_config("Server")
|
server_config = self.manager.config.get_section_config("Server")
|
||||||
path = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), path)
|
relative_path = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), path)
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(relative_path):
|
||||||
path = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), "IOU", path)
|
relative_path = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), "IOU", path)
|
||||||
|
path = relative_path
|
||||||
|
|
||||||
self._path = path
|
self._path = path
|
||||||
if not os.path.isfile(self._path) or not os.path.exists(self._path):
|
if not os.path.isfile(self._path) or not os.path.exists(self._path):
|
||||||
|
@ -28,7 +28,7 @@ from unittest.mock import patch, MagicMock
|
|||||||
from gns3server.modules.iou.iou_vm import IOUVM
|
from gns3server.modules.iou.iou_vm import IOUVM
|
||||||
from gns3server.modules.iou.iou_error import IOUError
|
from gns3server.modules.iou.iou_error import IOUError
|
||||||
from gns3server.modules.iou import IOU
|
from gns3server.modules.iou import IOU
|
||||||
|
from gns3server.config import Config
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def manager(port_manager):
|
def manager(port_manager):
|
||||||
@ -196,7 +196,8 @@ def test_path(vm, fake_iou_bin):
|
|||||||
|
|
||||||
def test_path_relative(vm, fake_iou_bin, tmpdir):
|
def test_path_relative(vm, fake_iou_bin, tmpdir):
|
||||||
|
|
||||||
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
config = Config.instance()
|
||||||
|
config.set("Server", "images_path", str(tmpdir))
|
||||||
vm.path = "iou.bin"
|
vm.path = "iou.bin"
|
||||||
assert vm.path == fake_iou_bin
|
assert vm.path == fake_iou_bin
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user