def ssh_upload(
self,
remote_path,
local_path,
use_sudo=False,
quiet=False,
**kwargs
):
"""
Upload a file or directory to 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 uploaded files
:raise: UploadError: 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 = put(
local_path, remote_path, use_sudo=use_sudo
)
else:
result = put(local_path, remote_path, use_sudo=use_sudo)
if result.failed:
raise UploadError(
local_path=local_path,
remote_path=remote_path
)
else:
return result
评论列表
文章目录