diff mbox

[7/9] KVM test: Introduce the local_login()

Message ID 20100426100418.26268.43253.stgit@localhost.localdomain (mailing list archive)
State New, archived
Headers show

Commit Message

Jason Wang April 26, 2010, 10:04 a.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 0cdf925..a22893b 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -814,7 +814,32 @@  class VM:
                                                             "command", ""))
         return session
 
+    def local_login(self, timeout=240):
+        """
+        Log into the guest via serial console
+        If timeout expires while waiting for output from the guest (e.g. a
+        password prompt or a shell prompt) -- fail.
+        """
+
+        serial_mode = self.params.get("serial_mode")
+        username = self.params.get("username", "")
+        password = self.params.get("password", "")
+        prompt = self.params.get("shell_prompt", "[\#\$]")
+        linesep = eval("'%s'" % self.params.get("shell_linesep", r"\n"))
 
+        if serial_mode != "session":
+            logging.debug("serial_mode is not session")
+            return None
+        else:
+            command = "nc -U %s"  % self.serial_file_name
+            assist = self.params.get("prompt_assist")
+            session = kvm_utils.remote_login(command, password, prompt, linesep,
+                                             timeout, "", username)
+            if session:
+                session.set_status_test_command(self.params.get("status_test_"
+                                                                "command", ""))
+            return session
+            
     def copy_files_to(self, local_path, remote_path, nic_index=0, timeout=300):
         """
         Transfer files to the guest.