aboutsummaryrefslogtreecommitdiff
path: root/tests/acceptance/linux_ssh_mips_malta.py
diff options
context:
space:
mode:
authorCleber Rosa <crosa@redhat.com>2021-04-12 00:46:36 -0400
committerJohn Snow <jsnow@redhat.com>2021-06-01 16:21:20 -0400
commit976218cbe792c37c1af7840ca5113e37b5a51d95 (patch)
tree082b120c16002d36f92f3bd402af0e734dc81fd6 /tests/acceptance/linux_ssh_mips_malta.py
parentc028691e65b9f45e7a8ff8ffbfb9a3818478b572 (diff)
downloadqemu-976218cbe792c37c1af7840ca5113e37b5a51d95.zip
qemu-976218cbe792c37c1af7840ca5113e37b5a51d95.tar.gz
qemu-976218cbe792c37c1af7840ca5113e37b5a51d95.tar.bz2
Python: add utility function for retrieving port redirection
Slightly different versions for the same utility code are currently present on different locations. This unifies them all, giving preference to the version from virtiofs_submounts.py, because of the last tweaks added to it. While at it, this adds a "qemu.utils" module to host the utility function and a test. Signed-off-by: Cleber Rosa <crosa@redhat.com> Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Willian Rampazzo <willianr@redhat.com> Message-Id: <20210412044644.55083-4-crosa@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> [Squashed in below fix. --js] Signed-off-by: John Snow <jsnow@redhat.com> Signed-off-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20210601154546.130870-2-crosa@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'tests/acceptance/linux_ssh_mips_malta.py')
-rw-r--r--tests/acceptance/linux_ssh_mips_malta.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/tests/acceptance/linux_ssh_mips_malta.py b/tests/acceptance/linux_ssh_mips_malta.py
index 6dbd02d..052008f 100644
--- a/tests/acceptance/linux_ssh_mips_malta.py
+++ b/tests/acceptance/linux_ssh_mips_malta.py
@@ -18,6 +18,8 @@ from avocado.utils import process
from avocado.utils import archive
from avocado.utils import ssh
+from qemu.utils import get_info_usernet_hostfwd_port
+
class LinuxSSH(Test):
@@ -70,18 +72,14 @@ class LinuxSSH(Test):
def setUp(self):
super(LinuxSSH, self).setUp()
- def get_portfwd(self):
+ def ssh_connect(self, username, password):
+ self.ssh_logger = logging.getLogger('ssh')
res = self.vm.command('human-monitor-command',
command_line='info usernet')
- line = res.split('\r\n')[2]
- port = re.split(r'.*TCP.HOST_FORWARD.*127\.0\.0\.1 (\d+)\s+10\..*',
- line)[1]
+ port = get_info_usernet_hostfwd_port(res)
+ if not port:
+ self.cancel("Failed to retrieve SSH port")
self.log.debug("sshd listening on port:" + port)
- return port
-
- def ssh_connect(self, username, password):
- self.ssh_logger = logging.getLogger('ssh')
- port = self.get_portfwd()
self.ssh_session = ssh.Session(self.VM_IP, port=int(port),
user=username, password=password)
for i in range(10):