示例#1
0
    def testRestart(self, call, wpe):
        # Use WinPE paths
        wpe.return_value = True

        power.Restart(60, 'Reboot fixes everything.')
        call.assert_called_with('%s\\shutdown.exe -r -t 60 '
                                '-c "Reboot fixes everything."' %
                                power.constants.WINPE_SYSTEM32)

        # Use hosts paths
        wpe.return_value = False

        power.Restart(60, 'Reboot fixes everything.')
        call.assert_called_with('%s\\shutdown.exe -r -t 60 '
                                '-c "Reboot fixes everything."' %
                                power.constants.SYS_SYSTEM32)
示例#2
0
    def _ProcessTasks(self, tasks):
        """Process the pending tasks list.

    Args:
      tasks: The list of pending tasks.
    """
        while tasks:
            entry = tasks[0]['data']
            self._build_info.ActiveConfigPath(set_to=tasks[0]['path'])
            for element in entry:
                if element == 'policy':
                    for line in entry['policy']:
                        self._Policy(line)
                else:
                    try:
                        self._ProcessAction(element, entry[element])
                    except base.ConfigError as e:
                        raise ConfigRunnerError(e)
                    except base.actions.RestartEvent as e:
                        if e.task_list_path:
                            self._task_list_path = e.task_list_path
                        if not e.retry_on_restart:
                            self._PopTask(tasks)
                        power.Restart(e.timeout, e.message)
                        sys.exit(0)
                    except base.actions.ShutdownEvent as e:
                        if e.task_list_path:
                            self._task_list_path = e.task_list_path
                        if not e.retry_on_restart:
                            self._PopTask(tasks)
                        power.Shutdown(e.timeout, e.message)
                        sys.exit(0)
            self._PopTask(tasks)
示例#3
0
    def _ProcessTasks(self, tasks):
        """Process the pending tasks list.

    Args:
      tasks: The list of pending tasks.

    Raises:
      ConfigRunnerError: failure to confirm verify_urls
    """
        if constants.FLAGS.verify_urls:
            dl = download.Download()
            for url in constants.FLAGS.verify_urls:
                if not dl.CheckUrl(url, [200], max_retries=-1):
                    raise ConfigRunnerError('verify_urls failed for url %s' %
                                            url)

        while tasks:
            self._build_info.ActiveConfigPath(set_to=tasks[0]['path'])
            self._build_info.ConfigServer(set_to=tasks[0]['server'])
            entry = tasks[0]['data']
            for element in entry:
                if element == 'policy':
                    for line in entry['policy']:
                        self._Policy(line)
                else:
                    try:
                        self._ProcessAction(element, entry[element])
                    except base.ConfigError as e:
                        raise ConfigRunnerError(e)
                    except base.actions.RestartEvent as e:
                        if e.task_list_path:
                            self._task_list_path = e.task_list_path
                        if not e.retry_on_restart:
                            self._PopTask(tasks)
                        if e.pop_next:
                            self._PopTask(tasks)
                        power.Restart(e.timeout, str(e))
                        sys.exit(0)
                    except base.actions.ShutdownEvent as e:
                        if e.task_list_path:
                            self._task_list_path = e.task_list_path
                        if not e.retry_on_restart:
                            self._PopTask(tasks)
                        if e.pop_next:
                            self._PopTask(tasks)
                        power.Shutdown(e.timeout, str(e))
                        sys.exit(0)
            self._PopTask(tasks)
示例#4
0
 def testRestart(self, call):
     power.Restart(60, 'Reboot fixes everything.')
     call.assert_called_with('C:\\Windows\\System32\\shutdown.exe -r -t 60 '
                             '-c "Reboot fixes everything." -f')