From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Wang Subject: [PATCH 2/9] KVM test: Add the ability to send the username in remote_login() Date: Mon, 26 Apr 2010 18:03:38 +0800 Message-ID: <20100426100338.26268.15473.stgit@localhost.localdomain> References: <20100426095656.26268.50549.stgit@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: autotest@test.kernel.org, lmr@redhat.com Return-path: In-Reply-To: <20100426095656.26268.50549.stgit@localhost.localdomain> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org In order to let the serial console work, we must let the remote_login() send the username when needed. Signed-off-by: Jason Wang --- client/tests/kvm/kvm_utils.py | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index 9adbaee..1ea0852 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -452,7 +452,7 @@ def check_kvm_source_dir(source_dir): # guests. def remote_login(command, password, prompt, linesep="\n", timeout=10, - prompt_assist = None): + prompt_assist = None, username = None): """ Log into a remote host (guest) using SSH or Telnet. Run the given command using kvm_spawn and provide answers to the questions asked. If timeout @@ -471,6 +471,8 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10, password prompt, the shell prompt, etc) @prarm prompt_assist: An assistant string sent before the pattern matching in order to get the prompt for some kinds of shell_client. + @param username: The user name used to log into the session + @return Return the kvm_spawn object on success and None on failure. """ sub = kvm_subprocess.kvm_shell_session(command, @@ -505,9 +507,13 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10, sub.close() return None elif match == 2: # "login:" - logging.debug("Got unexpected login prompt") - sub.close() - return None + if username is None: + logging.debug("Got unexpected login prompt") + sub.close() + return None + else: + sub.sendline(username) + continue elif match == 3: # "Connection closed" logging.debug("Got 'Connection closed'") sub.close()