1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 03:08:14 +00:00

Use $PATH also for dynamips and cleanup some $PATH usages

Fix #655
This commit is contained in:
Julien Duponchelle 2016-08-29 11:27:35 +02:00
parent 0eafb6f06c
commit da1cd9a3e7
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
6 changed files with 24 additions and 15 deletions

View File

@ -403,11 +403,10 @@ class BaseVM:
"""
path = self._manager.config.get_section_config("Server").get("ubridge_path", "ubridge")
if path == "ubridge":
path = shutil.which("ubridge")
path = shutil.which(path)
if path is None or len(path) == 0:
raise VMError("uBridge is not installed")
raise VMError("uBridge is not installed or uBridge path is invalid")
return path
@asyncio.coroutine

View File

@ -336,16 +336,16 @@ class Dynamips(BaseManager):
def find_dynamips(self):
# look for Dynamips
dynamips_path = self.config.get_section_config("Dynamips").get("dynamips_path")
if not dynamips_path:
dynamips_path = shutil.which("dynamips")
dynamips_path = self.config.get_section_config("Dynamips").get("dynamips_path", "dynamips")
if not os.path.isabs(dynamips_path):
dynamips_path = shutil.which(dynamips_path)
if not dynamips_path:
raise DynamipsError("Could not find Dynamips")
if not os.path.isfile(dynamips_path):
raise DynamipsError("Dynamips {} is not accessible".format(dynamips_path))
if not os.access(dynamips_path, os.X_OK):
raise DynamipsError("Dynamips is not executable")
raise DynamipsError("Dynamips {} is not executable".format(dynamips_path))
self._dynamips_path = dynamips_path
return dynamips_path

View File

@ -230,9 +230,11 @@ class IOUVM(BaseVM):
:returns: path to IOUYAP
"""
path = self._manager.config.get_section_config("IOU").get("iouyap_path", "iouyap")
if path == "iouyap":
path = shutil.which("iouyap")
search_path = self._manager.config.get_section_config("IOU").get("iouyap_path", "iouyap")
path = shutil.which(search_path)
# shutil.which return None if the path doesn't exists
if not path:
return search_path
return path
@property

View File

@ -66,7 +66,10 @@ class VirtualBox(BaseManager):
elif sys.platform.startswith("darwin"):
vboxmanage_path = "/Applications/VirtualBox.app/Contents/MacOS/VBoxManage"
else:
vboxmanage_path = shutil.which("vboxmanage")
vboxmanage_path = "vboxmanage"
if not os.path.abspath(vboxmanage_path):
vboxmanage_path = shutil.which(vboxmanage_path)
if not vboxmanage_path:
raise VirtualBoxError("Could not find VBoxManage")

View File

@ -105,7 +105,10 @@ class VMware(BaseManager):
elif sys.platform.startswith("darwin"):
vmrun_path = "/Applications/VMware Fusion.app/Contents/Library/vmrun"
else:
vmrun_path = shutil.which("vmrun")
vmrun_path = "vmrun"
if not os.path.abspath(vmrun_path):
vmrun_path = shutil.which(vmrun_path)
if not vmrun_path:
raise VMwareError("Could not find VMware vmrun, please make sure it is installed")

View File

@ -139,9 +139,11 @@ class VPCSVM(BaseVM):
:returns: path to VPCS
"""
path = self._manager.config.get_section_config("VPCS").get("vpcs_path", "vpcs")
if path == "vpcs":
path = shutil.which("vpcs")
search_path = self._manager.config.get_section_config("VPCS").get("vpcs_path", "vpcs")
path = shutil.which(search_path)
# shutil.which return None if the path doesn't exists
if not path:
return search_path
return path
@BaseVM.name.setter