mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Merge branch 'master' into 1.5
This commit is contained in:
6 files changed
+389
-33
No files matched your search
@@ -21,7 +21,6 @@ Represents a Dynamips hypervisor and starts/stops the associated Dynamips proces
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import asyncio
|
||||
|
||||
from gns3server.utils.asyncio import wait_for_process_termination
|
||||
@@ -120,10 +119,9 @@ class Hypervisor(DynamipsHypervisor):
|
||||
self._command = self._build_command()
|
||||
try:
|
||||
log.info("Starting Dynamips: {}".format(self._command))
|
||||
|
||||
with tempfile.NamedTemporaryFile(delete=False) as fd:
|
||||
self._stdout_file = fd.name
|
||||
log.info("Dynamips process logging to {}".format(fd.name))
|
||||
self._stdout_file = os.path.join(self.working_dir, "dynamips_i{}_stdout.txt".format(self._id))
|
||||
log.info("Dynamips process logging to {}".format(self._stdout_file))
|
||||
with open(self._stdout_file, "w", encoding="utf-8") as fd:
|
||||
self._process = yield from asyncio.create_subprocess_exec(*self._command,
|
||||
stdout=fd,
|
||||
stderr=subprocess.STDOUT,
|
||||
|
||||
@@ -616,26 +616,39 @@ class VMware(BaseManager):
|
||||
yield from self.check_vmware_version()
|
||||
|
||||
inventory_path = self.get_vmware_inventory_path()
|
||||
if os.path.exists(inventory_path):
|
||||
# FIXME: inventory may exist if VMware workstation has not been fully uninstalled, therefore VMware player VMs are not searched
|
||||
if os.path.exists(inventory_path) and self.host_type == "ws":
|
||||
# inventory may exist for VMware player if VMware workstation has been previously installed
|
||||
return self._get_vms_from_inventory(inventory_path)
|
||||
else:
|
||||
# VMware player has no inventory file, let's search the default location for VMs.
|
||||
# VMware player has no inventory file, let's search the default location for VMs
|
||||
vmware_preferences_path = self.get_vmware_preferences_path()
|
||||
default_vm_path = self.get_vmware_default_vm_path()
|
||||
|
||||
pairs = {}
|
||||
if os.path.exists(vmware_preferences_path):
|
||||
# the default vm path may be present in VMware preferences file.
|
||||
try:
|
||||
pairs = self.parse_vmware_file(vmware_preferences_path)
|
||||
if "prefvmx.defaultvmpath" in pairs:
|
||||
default_vm_path = pairs["prefvmx.defaultvmpath"]
|
||||
except OSError as e:
|
||||
log.warning('Could not read VMware preferences file "{}": {}'.format(vmware_preferences_path, e))
|
||||
|
||||
if "prefvmx.defaultvmpath" in pairs:
|
||||
default_vm_path = pairs["prefvmx.defaultvmpath"]
|
||||
if not os.path.isdir(default_vm_path):
|
||||
raise VMwareError('Could not find the default VM directory: "{}"'.format(default_vm_path))
|
||||
return self._get_vms_from_directory(default_vm_path)
|
||||
vms = self._get_vms_from_directory(default_vm_path)
|
||||
|
||||
# looks for VMX paths in the preferences file in case not all VMs are in the default directory
|
||||
for key, value in pairs.items():
|
||||
m = re.match(r'pref.mruVM(\d+)\.filename', key)
|
||||
if m:
|
||||
display_name = "pref.mruVM{}.displayName".format(m.group(1))
|
||||
if display_name in pairs:
|
||||
found = False
|
||||
for vm in vms:
|
||||
if vm["vmname"] == display_name:
|
||||
found = True
|
||||
if found is False:
|
||||
vms.append({"vmname": pairs[display_name], "vmx_path": value})
|
||||
return vms
|
||||
|
||||
@staticmethod
|
||||
def _get_linux_vmware_binary():
|
||||
|
||||
@@ -318,7 +318,7 @@ class VMwareVM(BaseVM):
|
||||
vmnet_interface = os.path.basename(self._vmx_pairs[vnet])
|
||||
if sys.platform.startswith("linux"):
|
||||
yield from self._ubridge_hypervisor.send('bridge add_nio_linux_raw {name} "{interface}"'.format(name=vnet,
|
||||
interface=vmnet_interface))
|
||||
interface=vmnet_interface))
|
||||
elif sys.platform.startswith("win"):
|
||||
windows_interfaces = get_windows_interfaces()
|
||||
npf = None
|
||||
@@ -454,21 +454,25 @@ class VMwareVM(BaseVM):
|
||||
else:
|
||||
yield from self._control_vm("start")
|
||||
|
||||
if self._use_ubridge and self._ubridge_hypervisor:
|
||||
for adapter_number in range(0, self._adapters):
|
||||
nio = self._ethernet_adapters[adapter_number].get_nio(0)
|
||||
if nio:
|
||||
yield from self._add_ubridge_connection(nio, adapter_number)
|
||||
try:
|
||||
if self._use_ubridge and self._ubridge_hypervisor:
|
||||
for adapter_number in range(0, self._adapters):
|
||||
nio = self._ethernet_adapters[adapter_number].get_nio(0)
|
||||
if nio:
|
||||
yield from self._add_ubridge_connection(nio, adapter_number)
|
||||
|
||||
if self._enable_remote_console and self._console is not None:
|
||||
try:
|
||||
if sys.platform.startswith("win"):
|
||||
yield from wait_for_named_pipe_creation(self._get_pipe_name())
|
||||
else:
|
||||
yield from wait_for_file_creation(self._get_pipe_name()) # wait for VMware to create the pipe file.
|
||||
except asyncio.TimeoutError:
|
||||
raise VMwareError('Pipe file "{}" for remote console has not been created by VMware'.format(self._get_pipe_name()))
|
||||
self._start_remote_console()
|
||||
if self._enable_remote_console and self._console is not None:
|
||||
try:
|
||||
if sys.platform.startswith("win"):
|
||||
yield from wait_for_named_pipe_creation(self._get_pipe_name())
|
||||
else:
|
||||
yield from wait_for_file_creation(self._get_pipe_name()) # wait for VMware to create the pipe file.
|
||||
except asyncio.TimeoutError:
|
||||
raise VMwareError('Pipe file "{}" for remote console has not been created by VMware'.format(self._get_pipe_name()))
|
||||
self._start_remote_console()
|
||||
except VMwareError:
|
||||
yield from self.stop()
|
||||
raise
|
||||
|
||||
if self._get_vmx_setting("vhv.enable", "TRUE"):
|
||||
self._hw_virtualization = True
|
||||
@@ -488,11 +492,12 @@ class VMwareVM(BaseVM):
|
||||
yield from self._ubridge_hypervisor.stop()
|
||||
|
||||
try:
|
||||
if self.acpi_shutdown:
|
||||
# use ACPI to shutdown the VM
|
||||
yield from self._control_vm("stop", "soft")
|
||||
else:
|
||||
yield from self._control_vm("stop")
|
||||
if (yield from self.is_running()):
|
||||
if self.acpi_shutdown:
|
||||
# use ACPI to shutdown the VM
|
||||
yield from self._control_vm("stop", "soft")
|
||||
else:
|
||||
yield from self._control_vm("stop")
|
||||
finally:
|
||||
self._started = False
|
||||
|
||||
|
||||
Reference in new issue
Block a user