diff mbox

[KVM-AUTOTEST,2/6] KVM test: support Netcat as a remote shell client

Message ID 836c405266cd58509071052cc25072d52e84f9a7.1249835043.git.mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Aug. 9, 2009, 4:33 p.m. UTC
This is useful for Windows guests that will use the homemade remote shell server.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_utils.py |   17 +++++++++++++++++
 client/tests/kvm/kvm_vm.py    |    3 +++
 2 files changed, 20 insertions(+), 0 deletions(-)
diff mbox

Patch

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_"