From 473eb0280e801da268b17b00ead461fee9db2a27 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 25 Feb 2015 17:19:37 -0700 Subject: [PATCH] Support for relative path in Dynamips. --- gns3server/modules/dynamips/nodes/router.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gns3server/modules/dynamips/nodes/router.py b/gns3server/modules/dynamips/nodes/router.py index 3d53b16b..e8c6dfef 100644 --- a/gns3server/modules/dynamips/nodes/router.py +++ b/gns3server/modules/dynamips/nodes/router.py @@ -33,6 +33,8 @@ log = logging.getLogger(__name__) from ...base_vm import BaseVM from ..dynamips_error import DynamipsError from ..nios.nio_udp import NIOUDP + +from gns3server.config import Config from gns3server.utils.asyncio import wait_run_in_executor @@ -413,6 +415,14 @@ class Router(BaseVM): :param image: path to IOS image file """ + if not os.path.dirname(image): + # this must be a relative path + server_config = Config.instance().get_section_config("Server") + image = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), image) + + if not os.path.isfile(image): + raise DynamipsError("IOS image '{}' is not accessible".format(image)) + yield from self._hypervisor.send('vm set_ios "{name}" "{image}"'.format(name=self._name, image=image)) log.info('Router "{name}" [{id}]: has a new IOS image set: "{image}"'.format(name=self._name,