提交 689433d0 编写于 作者: L Lucas Meneghel Rodrigues 提交者: Cleber Rosa

avocado.core.remoter: Update fabric env before running operations

Fabric is not thread safe, but we can get away with executing
threads that don't have a lot of concurrency (that is, not a
lot of commands are happening at the same time). Let's try to
ensure the new command is being executed with proper
authentication parameters.
Signed-off-by: NLucas Meneghel Rodrigues <lookkas@gmail.com>
上级 c06aea0f
......@@ -142,6 +142,22 @@ def receive_files(local_path, remote_path):
return True
def _update_fabric_env(method):
"""
Update fabric env with the appropriate parameters.
:param method: Remote method to wrap.
:return: Wrapped method.
"""
def wrapper(*args, **kwargs):
fabric.api.env.update(host_string=args[0].hostname,
user=args[0].username,
key_filename=args[0].key_filename,
port=args[0].port)
return method(*args, **kwargs)
return wrapper
class Remote(object):
"""
......@@ -190,6 +206,7 @@ class Remote(object):
reject_unknown_hosts=reject_unknown_hosts,
disable_known_hosts=disable_known_hosts)
@_update_fabric_env
def run(self, command, ignore_status=False, quiet=True, timeout=60):
"""
Run a command on the remote host.
......@@ -274,6 +291,7 @@ class Remote(object):
"""
self.run('mkdir -p %s' % remote_path)
@_update_fabric_env
def send_files(self, local_path, remote_path):
"""
Send files to remote host.
......@@ -285,6 +303,7 @@ class Remote(object):
remote_path, hosts=[self.hostname])
return result_dict[self.hostname]
@_update_fabric_env
def receive_files(self, local_path, remote_path):
"""
Receive files from the remote host.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册