From 243eb38fd93ea203a2babe425b69225b8cc96fc4 Mon Sep 17 00:00:00 2001 From: Lucas Meneghel Rodrigues Date: Thu, 28 Jan 2016 19:32:23 -0200 Subject: [PATCH] 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: Lucas Meneghel Rodrigues --- avocado/core/remoter.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/avocado/core/remoter.py b/avocado/core/remoter.py index 035df8b3..4680d622 100644 --- a/avocado/core/remoter.py +++ b/avocado/core/remoter.py @@ -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. -- GitLab