From patchwork Tue May 11 09:04:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 98654 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4B8xMn9015971 for ; Tue, 11 May 2010 08:59:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757626Ab0EKI7U (ORCPT ); Tue, 11 May 2010 04:59:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56646 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757501Ab0EKI7R (ORCPT ); Tue, 11 May 2010 04:59:17 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4B8xGOg019008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 11 May 2010 04:59:16 -0400 Received: from localhost.localdomain ([10.66.91.25]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4B8xDm0031838; Tue, 11 May 2010 04:59:14 -0400 Subject: [PATCH v2 07/10] KVM test: Introduce local_login() To: lmr@redhat.com, autotest@test.kernel.org From: Jason Wang Cc: kvm@vger.kernel.org Date: Tue, 11 May 2010 17:04:07 +0800 Message-ID: <20100511090407.19914.58580.stgit@localhost.localdomain> In-Reply-To: <20100511083338.19914.7719.stgit@localhost.localdomain> References: <20100511083338.19914.7719.stgit@localhost.localdomain> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 11 May 2010 08:59:22 +0000 (UTC) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index cfebfc1..b7151c5 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -815,7 +815,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, username, password, prompt, + linesep, timeout, assist) + 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.