@@ -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()