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

        power.Shutdown(30, 'Because I said so.')
        call.assert_called_with('%s\\shutdown.exe -s -t 30 '
                                '-c "Because I said so."' %
                                power.constants.WINPE_SYSTEM32)

        # Use hosts paths
        wpe.return_value = False

        power.Shutdown(30, 'Because I said so.')
        call.assert_called_with('%s\\shutdown.exe -s -t 30 '
                                '-c "Because I said so."' %
                                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 testShutdown(self, call):
     power.Shutdown(30, 'Because I said so.')
     call.assert_called_with('C:\\Windows\\System32\\shutdown.exe -s -t 30 '
                             '-c "Because I said so." -f')