Beispiel #1
0
  def Parse(self, result):
    """Parse the WMI packages output."""
    result = result.ToDict()
    winvolume = rdf_client_fs.WindowsVolume(
        drive_letter=result.get("DeviceID"), drive_type=result.get("DriveType"))

    try:
      size = int(result.get("Size"))
    except (ValueError, TypeError):
      size = None

    try:
      free_space = int(result.get("FreeSpace"))
    except (ValueError, TypeError):
      free_space = None

    # Since we don't get the sector sizes from WMI, we just set them at 1 byte
    volume = rdf_client_fs.Volume(
        windowsvolume=winvolume,
        name=result.get("VolumeName"),
        file_system_type=result.get("FileSystem"),
        serial_number=result.get("VolumeSerialNumber"),
        sectors_per_allocation_unit=1,
        bytes_per_sector=1,
        total_allocation_units=size,
        actual_available_allocation_units=free_space)

    yield volume
Beispiel #2
0
class WindowsVolumeClientMock(ListDirectoryClientMock):
    """A mock of client filesystem volumes."""
    windows_d = rdf_client_fs.WindowsVolume(drive_letter="D:")
    windows_c = rdf_client_fs.WindowsVolume(drive_letter="C:")
    path_results = [
        rdf_client_fs.Volume(windowsvolume=windows_d,
                             bytes_per_sector=4096,
                             sectors_per_allocation_unit=1,
                             actual_available_allocation_units=50,
                             total_allocation_units=100),
        rdf_client_fs.Volume(windowsvolume=windows_c,
                             bytes_per_sector=4096,
                             sectors_per_allocation_unit=1,
                             actual_available_allocation_units=10,
                             total_allocation_units=100)
    ]

    def WmiQuery(self, query):
        if query.query == u"SELECT * FROM Win32_LogicalDisk":
            return client_fixture.WMI_SAMPLE
        else:
            return None