On Sun, 2009-05-24 at 18:46 +0300, Michael Goldish wrote: > 1. Make the 'login:' regular expression stricter so it doesn't match > 'Last login: ...' messages. > 2. Make the 'password:' regular expression stricter. > 3. Handle 'Connection refused' messages. Looks good to me > Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx> > --- > client/tests/kvm_runtest_2/kvm_utils.py | 13 +++++++++---- > 1 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/client/tests/kvm_runtest_2/kvm_utils.py b/client/tests/kvm_runtest_2/kvm_utils.py > index be8ad95..5736cf6 100644 > --- a/client/tests/kvm_runtest_2/kvm_utils.py > +++ b/client/tests/kvm_runtest_2/kvm_utils.py > @@ -413,7 +413,8 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10): > > while True: > (match, text) = sub.read_until_last_line_matches( > - ["[Aa]re you sure", "[Pp]assword:", "[Ll]ogin:", "[Cc]onnection.*closed", prompt], > + [r"[Aa]re you sure", r"[Pp]assword:\s*$", r"^\s*[Ll]ogin:\s*$", > + r"[Cc]onnection.*closed", r"[Cc]onnection.*refused", prompt], > timeout=timeout, internal_timeout=0.5) > if match == 0: # "Are you sure you want to continue connecting" > kvm_log.debug("Got 'Are you sure...'; sending 'yes'") > @@ -437,11 +438,15 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10): > kvm_log.debug("Got 'Connection closed'") > sub.close() > return None > - elif match == 4: # prompt > + elif match == 4: # "Connection refused" > + kvm_log.debug("Got 'Connection refused'") > + sub.close() > + return None > + elif match == 5: # prompt > kvm_log.debug("Got shell prompt -- logged in") > return sub > else: # match == None > - kvm_log.debug("Timeout or process terminated") > + kvm_log.debug("Timeout elapsed or process terminated") > sub.close() > return None > > @@ -470,7 +475,7 @@ def remote_scp(command, password, timeout=300, login_timeout=10): > > while True: > (match, text) = sub.read_until_last_line_matches( > - ["[Aa]re you sure", "[Pp]assword:", "lost connection"], > + [r"[Aa]re you sure", r"[Pp]assword:\s*$", r"lost connection"], > timeout=_timeout, internal_timeout=0.5) > if match == 0: # "Are you sure you want to continue connecting" > kvm_log.debug("Got 'Are you sure...'; sending 'yes'") -- Lucas Meneghel Rodrigues Software Engineer (QE) Red Hat - Emerging Technologies -- 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