Exemplo n.º 1
0
 def reboot():
     power_state = "reboot"
     if halt:
         self.halt()
         power_state = "on"
     server_interface.power_host(host=self, state=power_state)
     self.record("GOOD", None, "reboot.start", "hard reset")
     if wait:
         warning_msg = ('Machine failed to respond to hard reset '
                        'attempt (%s/%s)')
         for attempt in xrange(num_attempts-1):
             try:
                 self.wait_for_restart(timeout, log_failure=False,
                                       old_boot_id=old_boot_id,
                                       **wait_for_restart_kwargs)
             except error.AutoservShutdownError:
                 logging.warning(warning_msg, attempt+1,
                                 num_attempts)
                 # re-send the hard reset command
                 server_interface.power_host(host=self,
                                             state=power_state)
             else:
                 break
         else:
             # Run on num_attempts=1 or last retry
             try:
                 self.wait_for_restart(timeout,
                                       old_boot_id=old_boot_id,
                                       **wait_for_restart_kwargs)
             except error.AutoservShutdownError:
                 logging.warning(warning_msg, num_attempts,
                                 num_attempts)
                 msg = "Host did not shutdown"
                 raise error.AutoservShutdownError(msg)
    def wait_for_restart(self, timeout=DEFAULT_REBOOT_TIMEOUT,
                         down_timeout=WAIT_DOWN_REBOOT_TIMEOUT,
                         down_warning=WAIT_DOWN_REBOOT_WARNING,
                         log_failure=True, old_boot_id=None, **dargs):
        """Wait for the host to come back from a reboot.

        This is a generic implementation based entirely on wait_up and
        wait_down.

        @param timeout: Max seconds to wait for reboot to start.
        @param down_timeout: Max seconds to wait for host to go down.
        @param down_warning: Seconds to wait before warning host hasn't gone
            down.
        @param log_failure: bool(Log when host does not go down.)
        @param old_boot_id: Result of self.get_boot_id() before restart.
        @param **dargs: Extra arguments to reboot_followup.

        @raises AutoservRebootError if host does not come back up.
        """
        if not self.wait_down(timeout=down_timeout,
                              warning_timer=down_warning,
                              old_boot_id=old_boot_id):
            if log_failure:
                self.record("ABORT", None, "reboot.verify", "shut down failed")
            raise error.AutoservShutdownError("Host did not shut down")
        if self.wait_up(timeout):
            self.record("GOOD", None, "reboot.verify")
            self.reboot_followup(**dargs)
        else:
            self.record("ABORT", None, "reboot.verify",
                        "Host did not return from reboot")
            raise error.AutoservRebootError("Host did not return from reboot")
Exemplo n.º 3
0
 def reboot():
     if halt:
         self.halt()
     if not self.run_conmux(conmux_command):
         self.record("ABORT", None, "reboot.start",
                     "hard reset unavailable")
         raise error.AutoservUnsupportedError('Hard reset unavailable')
     self.record("GOOD", None, "reboot.start", "hard reset")
     if wait:
         warning_msg = (
             'Serial console failed to respond to hard reset '
             'attempt (%s/%s)')
         for attempt in xrange(num_attempts - 1):
             try:
                 self.wait_for_restart(timeout,
                                       log_failure=False,
                                       old_boot_id=old_boot_id,
                                       **wait_for_restart_kwargs)
             except error.AutoservShutdownError:
                 logging.warning(warning_msg, attempt + 1, num_attempts)
                 # re-send the hard reset command
                 self.run_conmux(conmux_command)
             else:
                 break
         else:
             # Run on num_attempts=1 or last retry
             try:
                 self.wait_for_restart(timeout,
                                       old_boot_id=old_boot_id,
                                       **wait_for_restart_kwargs)
             except error.AutoservShutdownError:
                 logging.warning(warning_msg, num_attempts,
                                 num_attempts)
                 msg = "Host did not shutdown"
                 raise error.AutoservShutdownError(msg)
Exemplo n.º 4
0
    def wait_for_restart(self, timeout=DEFAULT_REBOOT_TIMEOUT,
                         log_failure=True, old_boot_id=None, **dargs):
        """ Wait for the host to come back from a reboot. This is a generic
        implementation based entirely on wait_up and wait_down. """
        if not self.wait_down(timeout=self.WAIT_DOWN_REBOOT_TIMEOUT,
                              warning_timer=self.WAIT_DOWN_REBOOT_WARNING,
                              old_boot_id=old_boot_id):
            if log_failure:
                self.record("ABORT", None, "reboot.verify", "shut down failed")
            raise error.AutoservShutdownError("Host did not shut down")

        self.wait_up(timeout)
        time.sleep(2)    # this is needed for complete reliability
        if self.wait_up(timeout):
            self.record("GOOD", None, "reboot.verify")
            self.reboot_followup(**dargs)
        else:
            self.record("ABORT", None, "reboot.verify",
                        "Host did not return from reboot")
            raise error.AutoservRebootError("Host did not return from reboot")
Exemplo n.º 5
0
    def wait_for_restart(self,
                         timeout=DEFAULT_REBOOT_TIMEOUT,
                         down_timeout=WAIT_DOWN_REBOOT_TIMEOUT,
                         down_warning=WAIT_DOWN_REBOOT_WARNING,
                         log_failure=True,
                         old_boot_id=None,
                         **dargs):
        """ Wait for the host to come back from a reboot. This is a generic
        implementation based entirely on wait_up and wait_down. """
        key_string = 'Reboot.%s' % dargs.get('board')

        total_reboot_timer = autotest_stats.Timer(
            '%s.total' % key_string,
            metadata=self._construct_host_metadata('reboot_total'))
        wait_down_timer = autotest_stats.Timer(
            '%s.wait_down' % key_string,
            metadata=self._construct_host_metadata('reboot_down'))

        total_reboot_timer.start()
        wait_down_timer.start()
        if not self.wait_down(timeout=down_timeout,
                              warning_timer=down_warning,
                              old_boot_id=old_boot_id):
            if log_failure:
                self.record("ABORT", None, "reboot.verify", "shut down failed")
            raise error.AutoservShutdownError("Host did not shut down")
        wait_down_timer.stop()
        wait_up_timer = autotest_stats.Timer(
            '%s.wait_up' % key_string,
            metadata=self._construct_host_metadata('reboot_up'))
        wait_up_timer.start()
        if self.wait_up(timeout):
            self.record("GOOD", None, "reboot.verify")
            self.reboot_followup(**dargs)
            wait_up_timer.stop()
            total_reboot_timer.stop()
        else:
            self.record("ABORT", None, "reboot.verify",
                        "Host did not return from reboot")
            raise error.AutoservRebootError("Host did not return from reboot")