def ssh_download(
self,
remote_path,
local_path,
use_sudo=False,
quiet=False,
**kwargs
):
"""
Download a file or directory from the virtual machine
:param remote_path: The remote location
:param local_path: The local local
:param use_sudo: If True, it runs as sudo
:param quiet: Whether to hide the stdout/stderr output or not
:return: The list of downloaded files
:raise: DownloadError: If the task fails
"""
if self._vm_object:
self._wait_for_ssh_service(
kwargs['vcdriver_vm_ssh_username'],
kwargs['vcdriver_vm_ssh_password']
)
with fabric_context(
self.ip(),
kwargs['vcdriver_vm_ssh_username'],
kwargs['vcdriver_vm_ssh_password']
):
if quiet:
with hide('everything'):
result = get(
remote_path, local_path, use_sudo=use_sudo
)
else:
result = get(remote_path, local_path, use_sudo=use_sudo)
if result.failed:
raise DownloadError(
local_path=local_path,
remote_path=remote_path
)
else:
return result
评论列表
文章目录