Merge branch 'master' into 2.0

This commit is contained in:
Julien Duponchelle committed 2016-08-29 14:08:23 +02:00
commit 72fe5d3489
14 files changed
+314 -30

No files matched your search

+2 -6
View File
@@ -452,11 +452,7 @@ class BaseNode:
"""
path = self._manager.config.get_section_config("Server").get("ubridge_path", "ubridge")
if path == "ubridge" or path == "None":
path = shutil.which("ubridge")
if path is None or len(path) == 0:
raise NodeError("uBridge is not installed")
path = shutil.which(path)
return path
@asyncio.coroutine
@@ -481,7 +477,7 @@ class BaseNode:
"""
if self.ubridge_path is None:
raise NodeError("uBridge is not available")
raise NodeError("uBridge is not available or path doesn't exist")
if not self._manager.has_privileged_access(self.ubridge_path):
raise NodeError("uBridge requires root access or capability to interact with network adapters")
+4 -4
View File
@@ -303,16 +303,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
+5 -3
View File
@@ -233,9 +233,11 @@ class IOUVM(BaseNode):
:returns: path to IOUYAP
"""
path = self._config().get("iouyap_path", "iouyap")
if path == "iouyap":
path = shutil.which("iouyap")
search_path = self._config().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
+5 -1
View File
@@ -61,7 +61,11 @@ class Qcow2:
struct_format = ">IIQi"
with open(self._path, 'rb') as f:
content = f.read(struct.calcsize(struct_format))
self.magic, self.version, self.backing_file_offset, self.backing_file_size = struct.unpack_from(struct_format, content)
try:
self.magic, self.version, self.backing_file_offset, self.backing_file_size = struct.unpack_from(struct_format, content)
except struct.error:
raise Qcow2Error("Invalid file header for {}".format(self._path))
if self.magic != 1363560955: # The first 4 bytes contain the characters 'Q', 'F', 'I' followed by 0xfb.
raise Qcow2Error("Invalid magic for {}".format(self._path))
+4 -1
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")
@@ -30,7 +30,7 @@ import asyncio
from gns3server.utils import parse_version
from gns3server.utils.telnet_server import TelnetServer
from gns3server.utils.asyncio import wait_for_file_creation, wait_for_named_pipe_creation
from gns3server.utils.asyncio import wait_for_file_creation, wait_for_named_pipe_creation, locked_coroutine
from .virtualbox_error import VirtualBoxError
from ..nios.nio_udp import NIOUDP
from ..adapters.ethernet_adapter import EthernetAdapter
@@ -242,7 +242,7 @@ class VirtualBoxVM(BaseNode):
if (yield from self.check_hw_virtualization()):
self._hw_virtualization = True
@asyncio.coroutine
@locked_coroutine
def stop(self):
"""
Stops this VirtualBox VM.
@@ -943,8 +943,8 @@ class VirtualBoxVM(BaseNode):
if self.ubridge and self.ubridge.is_running():
yield from self._add_ubridge_udp_connection("VBOX-{}-{}".format(self._id, adapter_number),
self._local_udp_tunnels[adapter_number][1],
nio)
self._local_udp_tunnels[adapter_number][1],
nio)
else:
vm_state = yield from self._get_vm_state()
if vm_state == "running":
+5 -1
View File
@@ -39,6 +39,7 @@ from gns3server.compute.base_manager import BaseManager
from gns3server.compute.vmware.vmware_vm import VMwareVM
from gns3server.compute.vmware.vmware_error import VMwareError
class VMware(BaseManager):
_NODE_CLASS = VMwareVM
@@ -103,7 +104,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")
+5 -3
View File
@@ -153,9 +153,11 @@ class VPCSVM(BaseNode):
: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
@BaseNode.name.setter