Drop Python 3.4 and switch to async / await syntax for asyncio. Fixes #1425

This commit is contained in:
grossmj committed 2018-10-15 17:05:49 +07:00
1 parent 8baa480b79
commit 76af98404a
119 files changed
+2432 -3084

No files matched your search

+31 -41
View File
@@ -32,7 +32,6 @@ import shlex
from collections import OrderedDict
from gns3server.utils.interfaces import interfaces
from gns3server.utils.asyncio import subprocess_check_output
from gns3server.utils.asyncio import asyncio_ensure_future
from gns3server.utils import parse_version
log = logging.getLogger(__name__)
@@ -40,7 +39,6 @@ log = logging.getLogger(__name__)
from gns3server.compute.base_manager import BaseManager
from gns3server.compute.vmware.vmware_vm import VMwareVM
from gns3server.compute.vmware.vmware_error import VMwareError
from gns3server.utils.asyncio import asyncio_ensure_future
class VMware(BaseManager):
@@ -142,8 +140,7 @@ class VMware(BaseManager):
version = match.group(1)
return version
@asyncio.coroutine
def _check_vmware_player_requirements(self, player_version):
async def _check_vmware_player_requirements(self, player_version):
"""
Check minimum requirements to use VMware Player.
@@ -159,17 +156,16 @@ class VMware(BaseManager):
if player_version < 6:
raise VMwareError("Using VMware Player requires version 6 or above")
elif player_version == 6:
yield from self.check_vmrun_version(minimum_required_version="1.13.0")
await self.check_vmrun_version(minimum_required_version="1.13.0")
elif player_version == 7:
yield from self.check_vmrun_version(minimum_required_version="1.14.0")
await self.check_vmrun_version(minimum_required_version="1.14.0")
elif player_version >= 12:
yield from self.check_vmrun_version(minimum_required_version="1.15.0")
await self.check_vmrun_version(minimum_required_version="1.15.0")
elif player_version >= 14:
yield from self.check_vmrun_version(minimum_required_version="1.17.0")
await self.check_vmrun_version(minimum_required_version="1.17.0")
self._host_type = "player"
@asyncio.coroutine
def _check_vmware_workstation_requirements(self, ws_version):
async def _check_vmware_workstation_requirements(self, ws_version):
"""
Check minimum requirements to use VMware Workstation.
@@ -185,17 +181,16 @@ class VMware(BaseManager):
if ws_version < 10:
raise VMwareError("Using VMware Workstation requires version 10 or above")
elif ws_version == 10:
yield from self.check_vmrun_version(minimum_required_version="1.13.0")
await self.check_vmrun_version(minimum_required_version="1.13.0")
elif ws_version == 11:
yield from self.check_vmrun_version(minimum_required_version="1.14.0")
await self.check_vmrun_version(minimum_required_version="1.14.0")
elif ws_version >= 12:
yield from self.check_vmrun_version(minimum_required_version="1.15.0")
await self.check_vmrun_version(minimum_required_version="1.15.0")
elif ws_version >= 14:
yield from self.check_vmrun_version(minimum_required_version="1.17.0")
await self.check_vmrun_version(minimum_required_version="1.17.0")
self._host_type = "ws"
@asyncio.coroutine
def check_vmware_version(self):
async def check_vmware_version(self):
"""
Check VMware version
"""
@@ -207,13 +202,13 @@ class VMware(BaseManager):
player_version = self._find_vmware_version_registry(r"SOFTWARE\Wow6432Node\VMware, Inc.\VMware Player")
if player_version:
log.debug("VMware Player version {} detected".format(player_version))
yield from self._check_vmware_player_requirements(player_version)
await self._check_vmware_player_requirements(player_version)
else:
log.warning("Could not find VMware version")
self._host_type = "ws"
else:
log.debug("VMware Workstation version {} detected".format(ws_version))
yield from self._check_vmware_workstation_requirements(ws_version)
await self._check_vmware_workstation_requirements(ws_version)
else:
if sys.platform.startswith("darwin"):
if not os.path.isdir("/Applications/VMware Fusion.app"):
@@ -226,20 +221,20 @@ class VMware(BaseManager):
raise VMwareError("VMware is not installed (vmware or vmplayer executable could not be found in $PATH)")
try:
output = yield from subprocess_check_output(vmware_path, "-v")
output = await subprocess_check_output(vmware_path, "-v")
match = re.search("VMware Workstation ([0-9]+)\.", output)
version = None
if match:
# VMware Workstation has been detected
version = match.group(1)
log.debug("VMware Workstation version {} detected".format(version))
yield from self._check_vmware_workstation_requirements(version)
await self._check_vmware_workstation_requirements(version)
match = re.search("VMware Player ([0-9]+)\.", output)
if match:
# VMware Player has been detected
version = match.group(1)
log.debug("VMware Player version {} detected".format(version))
yield from self._check_vmware_player_requirements(version)
await self._check_vmware_player_requirements(version)
if version is None:
log.warning("Could not find VMware version. Output of VMware: {}".format(output))
raise VMwareError("Could not find VMware version. Output of VMware: {}".format(output))
@@ -365,28 +360,26 @@ class VMware(BaseManager):
return self._host_type
@asyncio.coroutine
def execute(self, subcommand, args, timeout=120, log_level=logging.INFO):
async def execute(self, subcommand, args, timeout=120, log_level=logging.INFO):
trial = 2
while True:
try:
return (yield from self._execute(subcommand, args, timeout=timeout, log_level=log_level))
return (await self._execute(subcommand, args, timeout=timeout, log_level=log_level))
except VMwareError as e:
# We can fail to detect that it's VMware player instead of Workstation (due to marketing change Player is now Player Workstation)
if self.host_type == "ws" and "VIX_SERVICEPROVIDER_VMWARE_WORKSTATION" in str(e):
self._host_type = "player"
return (yield from self._execute(subcommand, args, timeout=timeout, log_level=log_level))
return (await self._execute(subcommand, args, timeout=timeout, log_level=log_level))
else:
if trial <= 0:
raise e
trial -= 1
yield from asyncio.sleep(0.5)
await asyncio.sleep(0.5)
@asyncio.coroutine
def _execute(self, subcommand, args, timeout=120, log_level=logging.INFO):
async def _execute(self, subcommand, args, timeout=120, log_level=logging.INFO):
if self.host_type is None:
yield from self.check_vmware_version()
await self.check_vmware_version()
vmrun_path = self.vmrun_path
if not vmrun_path:
@@ -397,12 +390,12 @@ class VMware(BaseManager):
command_string = " ".join([shlex.quote(c) for c in command])
log.log(log_level, "Executing vmrun with command: {}".format(command_string))
try:
process = yield from asyncio.create_subprocess_exec(*command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
process = await asyncio.create_subprocess_exec(*command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
except (OSError, subprocess.SubprocessError) as e:
raise VMwareError("Could not execute vmrun: {}".format(e))
try:
stdout_data, _ = yield from asyncio.wait_for(process.communicate(), timeout=timeout)
stdout_data, _ = await asyncio.wait_for(process.communicate(), timeout=timeout)
except asyncio.TimeoutError:
raise VMwareError("vmrun has timed out after {} seconds!\nTry to run {} in a terminal to see more details.\n\nMake sure GNS3 and VMware run under the same user and whitelist vmrun.exe in your antivirus.".format(timeout, command_string))
@@ -413,8 +406,7 @@ class VMware(BaseManager):
return stdout_data.decode("utf-8", errors="ignore").splitlines()
@asyncio.coroutine
def check_vmrun_version(self, minimum_required_version="1.13.0"):
async def check_vmrun_version(self, minimum_required_version="1.13.0"):
"""
Checks the vmrun version.
@@ -431,7 +423,7 @@ class VMware(BaseManager):
vmrun_path = self.find_vmrun()
try:
output = yield from subprocess_check_output(vmrun_path)
output = await subprocess_check_output(vmrun_path)
match = re.search("vmrun version ([0-9\.]+)", output)
version = None
if match:
@@ -446,15 +438,14 @@ class VMware(BaseManager):
log.error("Error while looking for the VMware vmrun version: {}".format(e))
raise VMwareError("Error while looking for the VMware vmrun version: {}".format(e))
@asyncio.coroutine
def remove_from_vmware_inventory(self, vmx_path):
async def remove_from_vmware_inventory(self, vmx_path):
"""
Removes a linked clone from the VMware inventory file.
:param vmx_path: path of the linked clone VMX file
"""
with (yield from self._vmware_inventory_lock):
async with self._vmware_inventory_lock:
inventory_path = self.get_vmware_inventory_path()
if os.path.exists(inventory_path):
try:
@@ -677,14 +668,13 @@ class VMware(BaseManager):
else:
return [os.path.expanduser("~/vmware")]
@asyncio.coroutine
def list_vms(self):
async def list_vms(self):
"""
Gets VMware VM list.
"""
# check for the right VMware version
yield from self.check_vmware_version()
await self.check_vmware_version()
vmware_vms = []
inventory_path = self.get_vmware_inventory_path()
if os.path.exists(inventory_path) and self.host_type != "player":
@@ -746,4 +736,4 @@ if __name__ == '__main__':
loop = asyncio.get_event_loop()
vmware = VMware.instance()
print("=> Check version")
loop.run_until_complete(asyncio_ensure_future(vmware.check_vmware_version()))
loop.run_until_complete(asyncio.ensure_future(vmware.check_vmware_version()))
+69 -90
View File
@@ -95,12 +95,11 @@ class VMwareVM(BaseNode):
return self._vmnets
@locking
@asyncio.coroutine
def _control_vm(self, subcommand, *additional_args):
async def _control_vm(self, subcommand, *additional_args):
args = [self._vmx_path]
args.extend(additional_args)
result = yield from self.manager.execute(subcommand, args)
result = await self.manager.execute(subcommand, args)
log.debug("Control VM '{}' result: {}".format(subcommand, result))
return result
@@ -124,16 +123,14 @@ class VMwareVM(BaseNode):
except OSError as e:
raise VMwareError('Could not write VMware VMX file "{}": {}'.format(self._vmx_path, e))
@asyncio.coroutine
def is_running(self):
async def is_running(self):
result = yield from self.manager.execute("list", [])
result = await self.manager.execute("list", [])
if self._vmx_path in result:
return True
return False
@asyncio.coroutine
def _check_duplicate_linked_clone(self):
async def _check_duplicate_linked_clone(self):
"""
Without linked clone two VM using the same image can't run
at the same time.
@@ -157,17 +154,16 @@ class VMwareVM(BaseNode):
if not found:
return
trial += 1
yield from asyncio.sleep(1)
await asyncio.sleep(1)
@asyncio.coroutine
def create(self):
async def create(self):
"""
Creates this VM and handle linked clones.
"""
if not self.linked_clone:
yield from self._check_duplicate_linked_clone()
await self._check_duplicate_linked_clone()
yield from self.manager.check_vmrun_version()
await self.manager.check_vmrun_version()
if self.linked_clone and not os.path.exists(os.path.join(self.working_dir, os.path.basename(self._vmx_path))):
if self.manager.host_type == "player":
raise VMwareError("Linked clones are not supported by VMware Player")
@@ -187,11 +183,11 @@ class VMwareVM(BaseNode):
break
if not gns3_snapshot_exists:
log.info("Creating snapshot '{}'".format(base_snapshot_name))
yield from self._control_vm("snapshot", base_snapshot_name)
await self._control_vm("snapshot", base_snapshot_name)
# create the linked clone based on the base snapshot
new_vmx_path = os.path.join(self.working_dir, self.name + ".vmx")
yield from self._control_vm("clone",
await self._control_vm("clone",
new_vmx_path,
"linked",
"-snapshot={}".format(base_snapshot_name),
@@ -323,8 +319,7 @@ class VMwareVM(BaseNode):
raise VMwareError("vnet {} not in VMX file".format(vnet))
return vnet
@asyncio.coroutine
def _add_ubridge_connection(self, nio, adapter_number):
async def _add_ubridge_connection(self, nio, adapter_number):
"""
Creates a connection in uBridge.
@@ -333,30 +328,29 @@ class VMwareVM(BaseNode):
"""
vnet = self._get_vnet(adapter_number)
yield from self._ubridge_send("bridge create {name}".format(name=vnet))
await self._ubridge_send("bridge create {name}".format(name=vnet))
vmnet_interface = os.path.basename(self._vmx_pairs[vnet])
if sys.platform.startswith("darwin"):
# special case on OSX, we cannot bind VMnet interfaces using the libpcap
yield from self._ubridge_send('bridge add_nio_fusion_vmnet {name} "{interface}"'.format(name=vnet, interface=vmnet_interface))
await self._ubridge_send('bridge add_nio_fusion_vmnet {name} "{interface}"'.format(name=vnet, interface=vmnet_interface))
else:
block_host_traffic = self.manager.config.get_section_config("VMware").getboolean("block_host_traffic", False)
yield from self._add_ubridge_ethernet_connection(vnet, vmnet_interface, block_host_traffic)
await self._add_ubridge_ethernet_connection(vnet, vmnet_interface, block_host_traffic)
if isinstance(nio, NIOUDP):
yield from self._ubridge_send('bridge add_nio_udp {name} {lport} {rhost} {rport}'.format(name=vnet,
await self._ubridge_send('bridge add_nio_udp {name} {lport} {rhost} {rport}'.format(name=vnet,
lport=nio.lport,
rhost=nio.rhost,
rport=nio.rport))
if nio.capturing:
yield from self._ubridge_send('bridge start_capture {name} "{pcap_file}"'.format(name=vnet, pcap_file=nio.pcap_output_file))
await self._ubridge_send('bridge start_capture {name} "{pcap_file}"'.format(name=vnet, pcap_file=nio.pcap_output_file))
yield from self._ubridge_send('bridge start {name}'.format(name=vnet))
yield from self._ubridge_apply_filters(vnet, nio.filters)
await self._ubridge_send('bridge start {name}'.format(name=vnet))
await self._ubridge_apply_filters(vnet, nio.filters)
@asyncio.coroutine
def _update_ubridge_connection(self, adapter_number, nio):
async def _update_ubridge_connection(self, adapter_number, nio):
"""
Update a connection in uBridge.
@@ -367,10 +361,9 @@ class VMwareVM(BaseNode):
bridge_name = self._get_vnet(adapter_number)
except VMwareError:
return # vnet not yet available
yield from self._ubridge_apply_filters(bridge_name, nio.filters)
await self._ubridge_apply_filters(bridge_name, nio.filters)
@asyncio.coroutine
def _delete_ubridge_connection(self, adapter_number):
async def _delete_ubridge_connection(self, adapter_number):
"""
Deletes a connection in uBridge.
@@ -380,10 +373,9 @@ class VMwareVM(BaseNode):
vnet = "ethernet{}.vnet".format(adapter_number)
if vnet not in self._vmx_pairs:
raise VMwareError("vnet {} not in VMX file".format(vnet))
yield from self._ubridge_send("bridge delete {name}".format(name=vnet))
await self._ubridge_send("bridge delete {name}".format(name=vnet))
@asyncio.coroutine
def _start_ubridge_capture(self, adapter_number, output_file):
async def _start_ubridge_capture(self, adapter_number, output_file):
"""
Start a packet capture in uBridge.
@@ -396,11 +388,10 @@ class VMwareVM(BaseNode):
raise VMwareError("vnet {} not in VMX file".format(vnet))
if not self._ubridge_hypervisor:
raise VMwareError("Cannot start the packet capture: uBridge is not running")
yield from self._ubridge_send('bridge start_capture {name} "{output_file}"'.format(name=vnet,
await self._ubridge_send('bridge start_capture {name} "{output_file}"'.format(name=vnet,
output_file=output_file))
@asyncio.coroutine
def _stop_ubridge_capture(self, adapter_number):
async def _stop_ubridge_capture(self, adapter_number):
"""
Stop a packet capture in uBridge.
@@ -412,7 +403,7 @@ class VMwareVM(BaseNode):
raise VMwareError("vnet {} not in VMX file".format(vnet))
if not self._ubridge_hypervisor:
raise VMwareError("Cannot stop the packet capture: uBridge is not running")
yield from self._ubridge_send("bridge stop_capture {name}".format(name=vnet))
await self._ubridge_send("bridge stop_capture {name}".format(name=vnet))
def check_hw_virtualization(self):
"""
@@ -426,8 +417,7 @@ class VMwareVM(BaseNode):
return True
return False
@asyncio.coroutine
def start(self):
async def start(self):
"""
Starts this VMware VM.
"""
@@ -435,14 +425,14 @@ class VMwareVM(BaseNode):
if self.status == "started":
return
if (yield from self.is_running()):
if (await self.is_running()):
raise VMwareError("The VM is already running in VMware")
ubridge_path = self.ubridge_path
if not ubridge_path or not os.path.isfile(ubridge_path):
raise VMwareError("ubridge is necessary to start a VMware VM")
yield from self._start_ubridge()
await self._start_ubridge()
self._read_vmx_file()
# check if there is enough RAM to run
if "memsize" in self._vmx_pairs:
@@ -452,20 +442,20 @@ class VMwareVM(BaseNode):
self._write_vmx_file()
if self._headless:
yield from self._control_vm("start", "nogui")
await self._control_vm("start", "nogui")
else:
yield from self._control_vm("start")
await self._control_vm("start")
try:
if 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)
await self._add_ubridge_connection(nio, adapter_number)
yield from self._start_console()
await self._start_console()
except VMwareError:
yield from self.stop()
await self.stop()
raise
if self._get_vmx_setting("vhv.enable", "TRUE"):
@@ -475,25 +465,24 @@ class VMwareVM(BaseNode):
self.status = "started"
log.info("VMware VM '{name}' [{id}] started".format(name=self.name, id=self.id))
@asyncio.coroutine
def stop(self):
async def stop(self):
"""
Stops this VMware VM.
"""
self._hw_virtualization = False
yield from self._stop_remote_console()
yield from self._stop_ubridge()
await self._stop_remote_console()
await self._stop_ubridge()
try:
if (yield from self.is_running()):
if (await self.is_running()):
if self.on_close == "save_vm_state":
yield from self._control_vm("suspend")
await self._control_vm("suspend")
elif self.on_close == "shutdown_signal":
# use ACPI to shutdown the VM
yield from self._control_vm("stop", "soft")
await self._control_vm("stop", "soft")
else:
yield from self._control_vm("stop")
await self._control_vm("stop")
finally:
self._started = False
self.status = "stopped"
@@ -519,49 +508,45 @@ class VMwareVM(BaseNode):
self._vmx_pairs["ethernet{}.startconnected".format(adapter_number)] = "TRUE"
self._write_vmx_file()
yield from super().stop()
await super().stop()
log.info("VMware VM '{name}' [{id}] stopped".format(name=self.name, id=self.id))
@asyncio.coroutine
def suspend(self):
async def suspend(self):
"""
Suspends this VMware VM.
"""
if self.manager.host_type != "ws":
raise VMwareError("Pausing a VM is only supported by VMware Workstation")
yield from self._control_vm("pause")
await self._control_vm("pause")
self.status = "suspended"
log.info("VMware VM '{name}' [{id}] paused".format(name=self.name, id=self.id))
@asyncio.coroutine
def resume(self):
async def resume(self):
"""
Resumes this VMware VM.
"""
if self.manager.host_type != "ws":
raise VMwareError("Unpausing a VM is only supported by VMware Workstation")
yield from self._control_vm("unpause")
await self._control_vm("unpause")
self.status = "started"
log.info("VMware VM '{name}' [{id}] resumed".format(name=self.name, id=self.id))
@asyncio.coroutine
def reload(self):
async def reload(self):
"""
Reloads this VMware VM.
"""
yield from self._control_vm("reset")
await self._control_vm("reset")
log.info("VMware VM '{name}' [{id}] reloaded".format(name=self.name, id=self.id))
@asyncio.coroutine
def close(self):
async def close(self):
"""
Closes this VMware VM.
"""
if not (yield from super().close()):
if not (await super().close()):
return False
for adapter in self._ethernet_adapters.values():
@@ -571,12 +556,12 @@ class VMwareVM(BaseNode):
self.manager.port_manager.release_udp_port(nio.lport, self._project)
try:
self.on_close = "power_off"
yield from self.stop()
await self.stop()
except VMwareError:
pass
if self.linked_clone:
yield from self.manager.remove_from_vmware_inventory(self._vmx_path)
await self.manager.remove_from_vmware_inventory(self._vmx_path)
@property
def headless(self):
@@ -722,8 +707,7 @@ class VMwareVM(BaseNode):
log.info("VMware VM '{name}' [{id}] is not allowed to use any adapter".format(name=self.name, id=self.id))
self._use_any_adapter = use_any_adapter
@asyncio.coroutine
def adapter_add_nio_binding(self, adapter_number, nio):
async def adapter_add_nio_binding(self, adapter_number, nio):
"""
Adds an adapter NIO binding.
@@ -743,7 +727,7 @@ class VMwareVM(BaseNode):
# check for the connection type
connection_type = "ethernet{}.connectiontype".format(adapter_number)
if not self._use_any_adapter and connection_type in self._vmx_pairs and self._vmx_pairs[connection_type] in ("nat", "bridged", "hostonly"):
if (yield from self.is_running()):
if (await self.is_running()):
raise VMwareError("Attachment '{attachment}' is configured on network adapter {adapter_number}. "
"Please stop VMware VM '{name}' to link to this adapter and allow GNS3 to change the attachment type.".format(attachment=self._vmx_pairs[connection_type],
adapter_number=adapter_number,
@@ -757,15 +741,14 @@ class VMwareVM(BaseNode):
adapter.add_nio(0, nio)
if self._started and self._ubridge_hypervisor:
yield from self._add_ubridge_connection(nio, adapter_number)
await self._add_ubridge_connection(nio, adapter_number)
log.info("VMware VM '{name}' [{id}]: {nio} added to adapter {adapter_number}".format(name=self.name,
id=self.id,
nio=nio,
adapter_number=adapter_number))
@asyncio.coroutine
def adapter_update_nio_binding(self, adapter_number, nio):
async def adapter_update_nio_binding(self, adapter_number, nio):
"""
Update a port NIO binding.
@@ -775,15 +758,14 @@ class VMwareVM(BaseNode):
if self._ubridge_hypervisor:
try:
yield from self._update_ubridge_connection(adapter_number, nio)
await self._update_ubridge_connection(adapter_number, nio)
except IndexError:
raise VMwareError('Adapter {adapter_number} does not exist on VMware VM "{name}"'.format(
name=self._name,
adapter_number=adapter_number
))
@asyncio.coroutine
def adapter_remove_nio_binding(self, adapter_number):
async def adapter_remove_nio_binding(self, adapter_number):
"""
Removes an adapter NIO binding.
@@ -803,7 +785,7 @@ class VMwareVM(BaseNode):
self.manager.port_manager.release_udp_port(nio.lport, self._project)
adapter.remove_nio(0)
if self._started and self._ubridge_hypervisor:
yield from self._delete_ubridge_connection(adapter_number)
await self._delete_ubridge_connection(adapter_number)
log.info("VMware VM '{name}' [{id}]: {nio} removed from adapter {adapter_number}".format(name=self.name,
id=self.id,
@@ -842,8 +824,7 @@ class VMwareVM(BaseNode):
"serial0.startconnected": "TRUE"}
self._vmx_pairs.update(serial_port)
@asyncio.coroutine
def _start_console(self):
async def _start_console(self):
"""
Starts remote console support for this VM.
"""
@@ -851,7 +832,7 @@ class VMwareVM(BaseNode):
if self.console and self.console_type == "telnet":
pipe_name = self._get_pipe_name()
try:
self._remote_pipe = yield from asyncio_open_serial(self._get_pipe_name())
self._remote_pipe = await asyncio_open_serial(self._get_pipe_name())
except OSError as e:
raise VMwareError("Could not open serial pipe '{}': {}".format(pipe_name, e))
server = AsyncioTelnetServer(reader=self._remote_pipe,
@@ -859,18 +840,17 @@ class VMwareVM(BaseNode):
binary=True,
echo=True)
try:
self._telnet_server = yield from asyncio.start_server(server.run, self._manager.port_manager.console_host, self.console)
self._telnet_server = await asyncio.start_server(server.run, self._manager.port_manager.console_host, self.console)
except OSError as e:
self.project.emit("log.warning", {"message": "Could not start Telnet server on socket {}:{}: {}".format(self._manager.port_manager.console_host, self.console, e)})
@asyncio.coroutine
def _stop_remote_console(self):
async def _stop_remote_console(self):
"""
Stops remote console support for this VM.
"""
if self._telnet_server:
self._telnet_server.close()
yield from self._telnet_server.wait_closed()
await self._telnet_server.wait_closed()
self._remote_pipe.close()
self._telnet_server = None
@@ -887,8 +867,7 @@ class VMwareVM(BaseNode):
super(VMwareVM, VMwareVM).console_type.__set__(self, new_console_type)
@asyncio.coroutine
def start_capture(self, adapter_number, output_file):
async def start_capture(self, adapter_number, output_file):
"""
Starts a packet capture.
@@ -913,13 +892,13 @@ class VMwareVM(BaseNode):
nio.startPacketCapture(output_file)
if self._started:
yield from self._start_ubridge_capture(adapter_number, output_file)
await self._start_ubridge_capture(adapter_number, output_file)
log.info("VMware VM '{name}' [{id}]: starting packet capture on adapter {adapter_number}".format(name=self.name,
id=self.id,
adapter_number=adapter_number))
def stop_capture(self, adapter_number):
async def stop_capture(self, adapter_number):
"""
Stops a packet capture.
@@ -940,7 +919,7 @@ class VMwareVM(BaseNode):
nio.stopPacketCapture()
if self._started:
yield from self._stop_ubridge_capture(adapter_number)
await self._stop_ubridge_capture(adapter_number)
log.info("VMware VM '{name}' [{id}]: stopping packet capture on adapter {adapter_number}".format(name=self.name,
id=self.id,