From 5910b4b0be942d2e2adc36196580ee773a796d89 Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 9 Mar 2015 21:57:21 -0600 Subject: [PATCH] Have the server look in the right place for relative image paths. --- gns3server/modules/dynamips/nodes/router.py | 2 +- gns3server/modules/iou/iou_vm.py | 2 +- gns3server/modules/qemu/qemu_vm.py | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/gns3server/modules/dynamips/nodes/router.py b/gns3server/modules/dynamips/nodes/router.py index 92079aad..98d9384f 100644 --- a/gns3server/modules/dynamips/nodes/router.py +++ b/gns3server/modules/dynamips/nodes/router.py @@ -423,7 +423,7 @@ class Router(BaseVM): if not os.path.isabs(image): server_config = Config.instance().get_section_config("Server") - image = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), image) + image = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), "IOS", image) if not os.path.isfile(image): raise DynamipsError("IOS image '{}' is not accessible".format(image)) diff --git a/gns3server/modules/iou/iou_vm.py b/gns3server/modules/iou/iou_vm.py index ea90f446..059db000 100644 --- a/gns3server/modules/iou/iou_vm.py +++ b/gns3server/modules/iou/iou_vm.py @@ -133,7 +133,7 @@ class IOUVM(BaseVM): if not os.path.isabs(path): server_config = Config.instance().get_section_config("Server") - path = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), path) + path = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), "IOU", path) self._path = path if not os.path.isfile(self._path) or not os.path.exists(self._path): diff --git a/gns3server/modules/qemu/qemu_vm.py b/gns3server/modules/qemu/qemu_vm.py index a270e0f3..09f87d51 100644 --- a/gns3server/modules/qemu/qemu_vm.py +++ b/gns3server/modules/qemu/qemu_vm.py @@ -185,7 +185,7 @@ class QemuVM(BaseVM): if os.path.isabs(hda_disk_image): server_config = Config.instance().get_section_config("Server") - hda_disk_image = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), hda_disk_image) + hda_disk_image = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), "QEMU", hda_disk_image) log.info("QEMU VM {name} [id={id}] has set the QEMU hda disk image path to {disk_image}".format(name=self._name, id=self._id, @@ -212,7 +212,7 @@ class QemuVM(BaseVM): if not os.path.isabs(hdb_disk_image): server_config = Config.instance().get_section_config("Server") - hdb_disk_image = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), hdb_disk_image) + hdb_disk_image = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), "QEMU", hdb_disk_image) log.info("QEMU VM {name} [id={id}] has set the QEMU hdb disk image path to {disk_image}".format(name=self._name, id=self._id, @@ -406,6 +406,10 @@ class QemuVM(BaseVM): :param initrd: QEMU initrd path """ + if os.path.isabs(initrd): + server_config = Config.instance().get_section_config("Server") + initrd = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), "QEMU", initrd) + log.info("QEMU VM {name} [id={id}] has set the QEMU initrd path to {initrd}".format(name=self._name, id=self._id, initrd=initrd)) @@ -429,6 +433,10 @@ class QemuVM(BaseVM): :param kernel_image: QEMU kernel image path """ + if os.path.isabs(kernel_image): + server_config = Config.instance().get_section_config("Server") + kernel_image = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), "QEMU", kernel_image) + log.info("QEMU VM {name} [id={id}] has set the QEMU kernel image path to {kernel_image}".format(name=self._name, id=self._id, kernel_image=kernel_image))