Пример #1
0
    def GetArtifacts(self):
        """Provides a list of Artifacts to upload.

    Returns:
      list(BaseArtifact): the artifacts to copy.
    """
        artifacts_list = []
        if self._platform == 'darwin':
            # TODO: have hostinfo.Which work on darwin
            artifacts_list.append(
                base.ProcessOutputArtifact(self._SYSTEM_PROFILER_CMD,
                                           'system_info.txt'))
            artifacts_list.append(
                base.ProcessOutputArtifact(self._NETWORKSETUP_CMD,
                                           'interfaces.txt'))
        else:
            dmidecode_path = hostinfo.Which('dmidecode')
            dmidecode_cmd = [dmidecode_path, '--type=bios', '--type=system']
            artifacts_list.append(
                base.ProcessOutputArtifact(dmidecode_cmd, 'system_info.txt'))
            ip_path = hostinfo.Which('ip')
            ip_cmd = [ip_path, 'link', 'show']
            artifacts_list.append(
                base.ProcessOutputArtifact(ip_cmd, 'interfaces.txt'))
        return artifacts_list
Пример #2
0
    def GetArtifacts(self):
        """Provides a list of Artifacts to upload.

    Returns:
      list(BaseArtifact): the artifacts to copy.
    """
        if self._platform == 'darwin':
            return [
                base.ProcessOutputArtifact(self._SYSTEM_PROFILER_CMD,
                                           'system_info.txt')
            ]
        return [
            base.ProcessOutputArtifact(self._DMI_DECODE_CMD, 'system_info.txt')
        ]
Пример #3
0
    def GetArtifacts(self):
        """Provides a list of Artifacts to upload.

    Returns:
      list (BaseArtifact): the artifacts for the system's firmware.
    """
        firmware_artifact = base.ProcessOutputArtifact(self._CHIPSEC_CMD,
                                                       'Firmware/rom.bin')
        return [firmware_artifact]
Пример #4
0
    def GetArtifacts(self):
        """Provides a list of Artifacts to upload.

    Returns:
      list (BaseArtifact): the artifacts corresponding to copy.
    """
        artifact = base.ProcessOutputArtifact(self._DMI_DECODE_CMD,
                                              'system_info.txt')

        return [artifact]
Пример #5
0
  def testRunCommand(self):
    cmd = ['echo', '-n', self._TEST_OUTPUT]
    artifact = base.ProcessOutputArtifact(cmd, 'output.txt')

    self.assertEqual(artifact._command, cmd)
    self.assertEqual(artifact.name, 'output.txt')
    # Size is unknown until the command is run
    self.assertEqual(artifact.size, 0)

    artifact_content = artifact.OpenStream().read()
    self.assertEqual(artifact.size, 27)

    self.assertEqual(artifact_content, self._TEST_OUTPUT)
Пример #6
0
    def GetArtifacts(self):
        """Provides a list of Artifacts to upload.

    Returns:
      list(BaseArtifact): the artifacts for the system's firmware.
    """
        if self._platform == 'darwin':
            self._logger.info(
                'Firmware acquisition only works on Linux, skipping.')
            return []

        firmware_artifact = base.ProcessOutputArtifact(self._CHIPSEC_CMD,
                                                       'Firmware/rom.bin')
        return [firmware_artifact]
Пример #7
0
  def GetArtifacts(self):
    """Provides a list of Artifacts to upload.

    Returns:
      list(BaseArtifact): the artifacts for the system's firmware.
    """
    if self._platform == 'darwin':
      self._logger.info('Firmware acquisition only works on Linux, skipping.')
      return []

    # Firmware acquisition will fail on various platforms (ie: QEMU during e2e
    # tests, and shouldn't be a reason to mark the full upload as failed.
    # So we're setting ignore_failure to True.
    firmware_artifact = base.ProcessOutputArtifact(
        self._CHIPSEC_CMD, 'Firmware/rom.bin', ignore_failure=True)
    return [firmware_artifact]
Пример #8
0
    def GetArtifacts(self):
        """Returns a list of DirectoryArtifacts to acquire.

    Returns:
      list(DirectoryArtifacts): the artifacts to acquire.
    """
        more_to_copy = True
        path_list = []
        while more_to_copy:
            if getattr(self._options, 'no_zenity', False):
                path = cli.AskText(
                    'Specify the path to the directory you wish to copy')
                if not os.path.isdir(path):
                    print(
                        'The following path does not exist or is not a directory:'
                        '{0:s}'.format(path))
                    continue
                path_list.append(path)
                more_to_copy = cli.Confirm(
                    'Do you wish to copy another folder?')
            else:
                path = gui.AskText(
                    'Specify the path to the directory you wish to copy')
                if not os.path.isdir(path):
                    # TODO: display an GUI error message
                    continue
                path_list.append(path)
                more_to_copy = gui.Confirm(
                    'Do you wish to copy another folder?')

        if not path_list:
            raise errors.RecipeException('No directory to collect')

        artifacts = []
        # Deduplicating paths, as they would cause the code to upload the same file
        # multiple times, which might not be allowed by the uploading process.
        for directory in list(set(path_list)):

            # 'tar' will not save some metadata such as access time. We generate
            # a 'timeline' with the find(1) command to keep this information
            timeline_artifact = None
            dir_artifact = None
            if self._platform == 'darwin':
                timeline_artifact = base.ProcessOutputArtifact([
                    'find', directory, '-exec', 'stat', '-f',
                    '0|%N|%i|%p|%u|%u|%z|%a.0|%m.0|%c.0|%B.0', '-t', '%s',
                    '{}', ';'
                ], 'Directories/{0:s}.timeline'.format(FullPathToName(path)))
                dir_artifact = MacDirectoryArtifact(
                    directory,
                    method=self._options.method,
                    compress=self._options.compress)
            elif self._platform == 'linux':
                timeline_artifact = base.ProcessOutputArtifact([
                    'find', directory, '-xdev', '-printf',
                    '0|%p|%i|%M|%U|%G|%s|%A@|%T@|%C@|0\n'
                ], 'Directores/{0:s}.timeline'.format(FullPathToName(path)))

                dir_artifact = LinuxDirectoryArtifact(
                    directory,
                    method=self._options.method,
                    compress=self._options.compress)
            else:
                raise ValueError('Unsupported platform: {0:s}'.format(
                    self._platform))

            artifacts.append(timeline_artifact)
            artifacts.append(dir_artifact)

        return artifacts