1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Look in old IOU images location in order to smooth transition

Fix #141
This commit is contained in:
Julien Duponchelle 2015-04-07 15:25:53 +02:00
parent 4189089e1b
commit 1c4a059982
2 changed files with 19 additions and 0 deletions

View File

@ -146,6 +146,16 @@ class IOUVM(BaseVM):
path = relative_path
self._path = path
# In 1.2 users uploaded images to the images roots
# after the migration their images are inside images/IOU
# but old topologies use old path
if "IOU" not in self._path:
location, filename = os.path.split(self._path)
fix_path = os.path.join(location, "IOU", filename)
if os.path.isfile(fix_path):
self._path = fix_path
if not os.path.isfile(self._path) or not os.path.exists(self._path):
if os.path.islink(self._path):
raise IOUError("IOU image '{}' linked to '{}' is not accessible".format(self._path, os.path.realpath(self._path)))

View File

@ -202,6 +202,15 @@ def test_path(vm, fake_iou_bin):
assert vm.path == fake_iou_bin
def test_path_12_location(vm, fake_iou_bin):
# In 1.2 users uploaded images to the images roots
# after the migration their images are inside images/IOU
# but old topologies use old path
vm.path = fake_iou_bin.replace("/IOU", "")
assert vm.path == fake_iou_bin
def test_path_relative(vm, fake_iou_bin, tmpdir):
config = Config.instance()