From 589c9754e8707cd729aa8106c17f24ad705aa53c Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 19 Feb 2019 00:09:59 +0800 Subject: [PATCH] Fix symlink not being created for duplicated IOU devices. Fixes https://github.com/GNS3/gns3-gui/issues/2699 --- gns3server/compute/base_manager.py | 2 +- gns3server/compute/iou/iou_vm.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gns3server/compute/base_manager.py b/gns3server/compute/base_manager.py index 602b0017..ca2fa016 100644 --- a/gns3server/compute/base_manager.py +++ b/gns3server/compute/base_manager.py @@ -276,7 +276,7 @@ class BaseManager: destination_dir = destination_node.working_dir try: shutil.rmtree(destination_dir) - shutil.copytree(source_node.working_dir, destination_dir) + shutil.copytree(source_node.working_dir, destination_dir, symlinks=True, ignore_dangling_symlinks=True) except OSError as e: raise aiohttp.web.HTTPConflict(text="Can't duplicate node data: {}".format(e)) diff --git a/gns3server/compute/iou/iou_vm.py b/gns3server/compute/iou/iou_vm.py index 6b0e7c30..53cfe25d 100644 --- a/gns3server/compute/iou/iou_vm.py +++ b/gns3server/compute/iou/iou_vm.py @@ -522,8 +522,9 @@ class IOUVM(BaseNode): # on newer images, see https://github.com/GNS3/gns3-server/issues/1484 try: symlink = os.path.join(self.working_dir, os.path.basename(self.path)) - if not os.path.islink(symlink): - os.symlink(self.path, symlink) + if os.path.islink(symlink): + os.unlink(symlink) + os.symlink(self.path, symlink) except OSError as e: raise IOUError("Could not create symbolic link: {}".format(e))