提交 243eb38f 编写于 作者: L Lucas Meneghel Rodrigues 提交者: Cleber Rosa

avocado.core.remoter.Remote: Support multiple instances

Since we have a fairly limited used of fabric in the vm
and remote plugins (one single host per test), we did not
notice an important limitation of the remoter code: It does
not support multiple instances of it, due to the fabric env
singleton nature. Having to connect to more than one system
with different authentication settings will cause failures
due to the fact that fabric was using old authentication
settings.

So let's use fabric execute function to make safer run
and send/receive file methods.
Signed-off-by: NLucas Meneghel Rodrigues <lookkas@gmail.com>
上级 9738ef31
......@@ -109,6 +109,11 @@ class Remote(object):
:rtype: :class:`avocado.utils.process.CmdResult`.
:raise fabric.exceptions.CommandTimeout: When timeout exhausted.
"""
return_dict = fabric.tasks.execute(self._run, command, ignore_status,
timeout, hosts=[self.hostname])
return return_dict[self.hostname]
def _run(self, command, ignore_status=False, timeout=60):
result = process.CmdResult()
start_time = time.time()
end_time = time.time() + (timeout or 0) # Support timeout=None
......@@ -173,6 +178,12 @@ class Remote(object):
self.run('mkdir -p %s' % remote_path)
def send_files(self, local_path, remote_path):
result_dict = fabric.tasks.execute(self._send_files, local_path,
remote_path, hosts=[self.hostname])
return result_dict[self.hostname]
@staticmethod
def _send_files(local_path, remote_path):
"""
Send files to remote.
......@@ -187,6 +198,12 @@ class Remote(object):
return True
def receive_files(self, local_path, remote_path):
result_dict = fabric.tasks.execute(self._receive_files, local_path,
remote_path, hosts=[self.hostname])
return result_dict[self.hostname]
@staticmethod
def _receive_files(self, local_path, remote_path):
"""
receive remote files.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册