Example #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
Example #2
0
    def ParseArguments(self, args):
        """Parses the arguments.

    Args:
      args (list): list of arguments.
    Returns:
      argparse.Namespace: parsed command line arguments.
    Raises:
      BadConfigOption: if the arguments are not specified properly.
    """
        parser = self._CreateParser()
        options = parser.parse_args(args)

        self._ParseRecipes(options)
        self._gcs_settings = self._ParseGCSJSON(options)
        self._ParseLoggingArguments(options)

        if options.select_disks and 'disk' not in options.acquire:
            raise errors.BadConfigOption(
                ('--select_disks needs the disk recipe ('
                 'current recipes : {0:s})').format(', '.join(
                     options.acquire)))

        if not options.no_zenity:
            # force no_zenity to True if zenity is not installed
            zenity_path = hostinfo.Which('zenity')
            if not zenity_path:
                options.no_zenity = True

        return options
Example #3
0
    def _GetLsblkDict(self):
        """Calls lsblk.

    Returns:
      dict: the output of the lsblk command.
    """
        lsblk_path = hostinfo.Which('lsblk')
        lsblk_output = subprocess.check_output(
            [lsblk_path, '-J', '--bytes', '-o', '+UUID,FSTYPE,SERIAL'])
        return json.loads(lsblk_output)
Example #4
0
  def _GenerateDDCommand(self):
    """Builds the DD command to run on the disk.

    Returns:
      list: the argument list for the dd command
    """
    dd_binary = hostinfo.Which(self._DD_BINARY)
    if not dd_binary:
      raise errors.RecipeException(
          'Could not find \'{0:s}\''.format(self._DD_BINARY))
    command = [
        dd_binary, 'if={0:s}'.format(self._path),
        'hashlog={0:s}'.format(self.hashlog_filename)]
    command.extend(self._DD_OPTIONS)
    return command