def wait_for_serial_login(self, timeout=LOGIN_WAIT_TIMEOUT, internal_timeout=LOGIN_TIMEOUT, restart_network=False, username=None, password=None): """ Make multiple attempts to log into the guest via serial console. :param timeout: Time (seconds) to keep trying to log in. :param internal_timeout: Timeout to pass to serial_login(). :param restart_network: Whether try to restart guest's network. :return: A ShellSession object. """ error_messages = [] logging.debug( "Attempting to log into '%s' via serial console " "(timeout %ds)", self.name, timeout) end_time = time.time() + timeout while time.time() < end_time: try: session = self.serial_login(internal_timeout) if restart_network: try: utils_net.restart_guest_network(session) except Exception: pass return session except remote.LoginError, e: self.verify_alive() e = str(e) if e not in error_messages: logging.debug(e) error_messages.append(e) time.sleep(2)
def wait_for_serial_login(self, timeout=LOGIN_WAIT_TIMEOUT, internal_timeout=LOGIN_TIMEOUT, restart_network=False, username=None, password=None): """ Make multiple attempts to log into the guest via serial console. :param timeout: Time (seconds) to keep trying to log in. :param internal_timeout: Timeout to pass to serial_login(). :param restart_network: Whether try to restart guest's network. :return: A ShellSession object. """ error_messages = [] logging.debug("Attempting to log into '%s' via serial console " "(timeout %ds)", self.name, timeout) end_time = time.time() + timeout while time.time() < end_time: try: session = self.serial_login(internal_timeout) if restart_network: os_type = self.params.get("os_type") try: logging.debug("Attempting to restart guest network") utils_net.restart_guest_network(session, os_type=os_type) except Exception: pass return session except remote.LoginError, e: self.verify_alive() e = str(e) if e not in error_messages: logging.debug(e) error_messages.append(e) time.sleep(2)