Rewrote image search

This code is more generic and support all cases. Previously
we had bug where the user lost his image path if the image
was not located in image directory.
This commit is contained in:
Julien Duponchelle
2015-04-14 18:46:55 +02:00
parent e51a129216
commit aa2472fb30
9 changed files with 124 additions and 70 deletions

View File

@ -151,10 +151,7 @@ class Router(BaseVM):
"system_id": self._system_id}
# return the relative path if the IOS image is in the images_path directory
server_config = self.manager.config.get_section_config("Server")
relative_image = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), "IOS", self._image)
if os.path.exists(relative_image):
router_info["image"] = os.path.basename(self._image)
router_info["image"] = self.manager.get_relative_image_path(self._image)
# add the slots
slot_number = 0
@ -427,9 +424,7 @@ class Router(BaseVM):
:param image: path to IOS image file
"""
if not os.path.isabs(image):
server_config = self.manager.config.get_section_config("Server")
image = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), "IOS", image)
image = self.manager.get_abs_image_path(image)
if not os.path.isfile(image):
raise DynamipsError("IOS image '{}' is not accessible".format(image))