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")
    def reboot(self, timeout=5):
        """Reboot the sonic device by submitting a post to the server."""

        # TODO(beeps): crbug.com/318306
        current_boot_id = self.get_boot_id()
        try:
            self.client.reboot()
        except sonic_client_utils.SonicProxyException as e:
            raise error.AutoservRebootError(
                    'Unable to reboot through the sonic proxy: %s' % e)

        self.wait_for_restart(timeout=timeout, old_boot_id=current_boot_id)
Пример #3
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")
Пример #4
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")