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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is useful for Windows guests that will use the homemade remote shell server.

Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx>
---
 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_"
-- 
1.5.4.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux