From patchwork Sun Aug 9 16:33:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 40267 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n79GVYqx000535 for ; Sun, 9 Aug 2009 16:31:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751966AbZHIQba (ORCPT ); Sun, 9 Aug 2009 12:31:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751957AbZHIQb3 (ORCPT ); Sun, 9 Aug 2009 12:31:29 -0400 Received: from mx2.redhat.com ([66.187.237.31]:35273 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751888AbZHIQbW (ORCPT ); Sun, 9 Aug 2009 12:31:22 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n79GVNhT021920; Sun, 9 Aug 2009 12:31:23 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n79GVMwo030020; Sun, 9 Aug 2009 12:31:22 -0400 Received: from localhost.localdomain (dhcp-1-31.tlv.redhat.com [10.35.1.31]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n79GVGYE020666; Sun, 9 Aug 2009 12:31:21 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 2/6] KVM test: support Netcat as a remote shell client Date: Sun, 9 Aug 2009 19:33:54 +0300 Message-Id: <836c405266cd58509071052cc25072d52e84f9a7.1249835043.git.mgoldish@redhat.com> In-Reply-To: References: <1249835638-18153-1-git-send-email-mgoldish@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This is useful for Windows guests that will use the homemade remote shell server. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_utils.py | 17 +++++++++++++++++ client/tests/kvm/kvm_vm.py | 3 +++ 2 files changed, 20 insertions(+), 0 deletions(-) diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index d1c9781..4c4753b 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -562,6 +562,23 @@ def telnet(host, port, username, password, prompt, timeout=10): return remote_login(command, password, prompt, "\r\n", timeout) +def netcat(host, port, username, password, prompt, timeout=10): + """ + Log into a remote host (guest) using Netcat. + + @param host: Hostname or IP address + @param username: Username (if required) + @param password: Password (if required) + @param prompt: Shell prompt (regular expression) + @timeout: Time in seconds that we will wait before giving up on logging + into the host. + + @return: kvm_spawn object on success and None on failure. + """ + command = "nc %s %s" % (host, port) + return remote_login(command, password, prompt, "\n", timeout) + + # The following are utility functions related to ports. def is_sshd_running(host, port, timeout=10.0): diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index 4a862bd..7bc3d75 100644 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -727,6 +727,9 @@ class VM: elif client == "telnet": session = kvm_utils.telnet(address, port, username, password, prompt, timeout) + elif client == "nc": + session = kvm_utils.netcat(address, port, username, password, + prompt, timeout) if session: session.set_status_test_command(self.params.get("status_test_"