From 8434a286b6d4e7436340aed088fa01444dd4f423 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 25 Feb 2015 16:35:13 +0100 Subject: [PATCH] Fix IOU old project import Fixes #69 --- gns3server/modules/iou/__init__.py | 10 ++++++++++ tests/modules/iou/test_iou_vm.py | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gns3server/modules/iou/__init__.py b/gns3server/modules/iou/__init__.py index c3ba15b4..30d35915 100644 --- a/gns3server/modules/iou/__init__.py +++ b/gns3server/modules/iou/__init__.py @@ -62,3 +62,13 @@ class IOU(BaseManager): """ return self._used_application_ids.get(vm_id, 1) + + def get_legacy_vm_workdir_name(legacy_vm_id): + """ + Returns the name of the legacy working directory (pre 1.3) name for a VM. + + :param legacy_vm_id: legacy VM identifier (integer) + :returns: working directory name + """ + + return "device-{}".format(legacy_vm_id) diff --git a/tests/modules/iou/test_iou_vm.py b/tests/modules/iou/test_iou_vm.py index 90d59759..cb5507cc 100644 --- a/tests/modules/iou/test_iou_vm.py +++ b/tests/modules/iou/test_iou_vm.py @@ -175,7 +175,6 @@ def test_path(vm, fake_iou_bin): assert vm.path == fake_iou_bin - def test_path_relative(vm, fake_iou_bin, tmpdir): with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}): @@ -302,3 +301,8 @@ def test_stop_capture(vm, tmpdir, manager, free_console_port, loop): assert vm._adapters[0].get_nio(0).capturing loop.run_until_complete(asyncio.async(vm.stop_capture(0, 0))) assert vm._adapters[0].get_nio(0).capturing is False + + +def test_get_legacy_vm_workdir_name(): + + assert IOU.get_legacy_vm_workdir_name(42) == "device-42"