コード例 #1
0
ファイル: remote.py プロジェクト: vi-patel/autotest
 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)
コード例 #2
0
ファイル: serial.py プロジェクト: wkf31156/autotest
 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)
コード例 #3
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. """
        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")