예제 #1
0
    def GetArtifacts(self):
        """Selects the Artifacts to acquire.

    This tries to return as many Artifacts as possible even if some collection
    raised an exception.

    Returns:
      list(DiskArtifact): the artifacts corresponding to copy.

    Raises:
      errors.RecipeException: when no disk is to be collected.
    """
        artifacts = []
        disks_to_collect = []
        if getattr(self._options, 'select_disks', None):
            all_disks = self._ListDisks(all_devices=True)
            if getattr(self._options, 'no_zenity', False):
                disks_to_collect = cli.AskDiskList(all_disks)
            else:
                disks_to_collect = gui.AskDiskList(all_disks)
        elif getattr(self._options, 'disk', None):
            disks_to_collect = self._ListDisks(names=self._options.disk)
        else:
            disks_to_collect = self._ListDisks()

        if not disks_to_collect:
            raise errors.RecipeException('No disk to collect')

        disk_list_artifact = self._GetListDisksArtifact()
        artifacts.append(disk_list_artifact)

        for disk in disks_to_collect:

            hashlog_artifact = base.FileArtifact(disk.hashlog_filename)
            hashlog_artifact.remote_path = 'Disks/{0:s}'.format(
                hashlog_artifact.name)

            # It is necessary for the DiskArtifact to be appended before the
            # hashlog, as the hashlog is generated when dcfldd completes.
            disk_info_artifact = self._GetDiskInfoArtifact(disk)
            if disk_info_artifact:
                artifacts.append(disk_info_artifact)
            artifacts.append(disk)
            artifacts.append(hashlog_artifact)
        return artifacts
예제 #2
0
파일: disk.py 프로젝트: cclauss/GiftStick
    def GetArtifacts(self):
        """Selects the Artifacts to acquire.

    This tries to return as many Artifacts as possible even if some collection
    raised an exception.

    Returns:
      list(DiskArtifact): the artifacts corresponding to copy.

    Raises:
      errors.RecipeException: when no disk is to be collected.
    """
        artifacts = []
        disks_to_collect = []
        if getattr(self._options, 'select_disks', None):
            all_disks = self._ListDisks(all_devices=True)
            disks_to_collect = gui.AskDiskList(all_disks)
        elif getattr(self._options, 'disk', None):
            disks_to_collect = self._ListDisks(names=self._options.disk)
        else:
            disks_to_collect = self._ListDisks()

        if not disks_to_collect:
            raise errors.RecipeException('No disk to collect')

        lsblk_artifact = base.StringArtifact('Disks/lsblk.txt',
                                             json.dumps(self._GetLsblkDict()))
        for disk in disks_to_collect:
            udevadm_artifact = base.StringArtifact(
                'Disks/{0:s}.udevadm.txt'.format(disk.name),
                disk.GetUdevadmProperty('udevadm_text_output'))

            hashlog_artifact = base.FileArtifact(disk.hashlog_filename)
            hashlog_artifact.remote_path = 'Disks/{0:s}'.format(
                hashlog_artifact.name)

            # It is necessary for the DiskArtifact to be appended before the
            # hashlog, as the hashlog is generated when dcfldd completes.
            artifacts.append(udevadm_artifact)
            artifacts.append(lsblk_artifact)
            artifacts.append(disk)
            artifacts.append(hashlog_artifact)
        return artifacts