The elbevalidate module

Utility to validate the contents of a created image. The image is not booted but only mounted safely through libguestfs.

Example usage:

with Image.from_file('sda.img') as image:
    for partition in image.partitions:
        print(partition)

    with image.files() as root:
        print(root.joinpath('etc', 'hostname').read_text())
class elbevalidate.BlockDevice

The abstract interface for block devices.

abstract blkid() dict

Device attributes as detected by blkid.

For common tags, see libblkid(3).

abstract files() ContextManager[Path]

Access to the files as found inside the block device.

abstract property size: int

Size in bytes.

class elbevalidate.Image(gfs)

A full system image, containing a PartitionTable with Partition.

blkid() dict

Device attributes as detected by blkid.

For common tags, see libblkid(3).

files() Generator[Path, None, None]

Access to the files as found inside the block device.

classmethod from_file(image) Generator[Image, None, None]

Construct an Image from a local file.

property partitions: PartitionTable

Partitions contained in this image.

property size: int

Size in bytes.

class elbevalidate.Partition(_parent: BlockDevice, number: int, type: str, start: int, _size: int)

A single partition

blkid() dict

Device attributes as detected by blkid.

For common tags, see libblkid(3).

files() Generator[Path, None, None]

Access to the files as found inside the block device.

number: int

Number of the partition, starting at 1

property size: int

Size in bytes.

start: int

Start offset of the partition in the Image, in bytes.

type: str

Type of the partition. One of

class elbevalidate.PartitionTable(label: PartitionLabel, sector_size: int, _partitions: list[Partition])

List of Partition inside an Image.

len(table)

Number of partitions.

table[index]

Partition at index.

partition in table

Iterate over partitions.

label: PartitionLabel

Type of the partition table.

sector_size: int

Size of each sector in bytes.

elbevalidate.statvfs(path: Path)

An equivalent of os.statvfs() working with elbevalidate.path.Path.

class elbevalidate.path.Path(*pathsegments, device, guestfs, root=None)

Reference to a path inside a elbevalidate.BlockDevice.

For documentation see pathlib.

exists()
is_block_device()
is_char_device()
is_dir()
is_fifo()
is_file()
is_mount()
is_socket()
iterdir()
lstat()
open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)
owner()
read_bytes()
read_text(encoding=None, errors=None)
stat()
class elbevalidate.constants.GPTPartitionType
EFI_SYSTEM_PARTITION = 'C12A7328-F81F-11D2-BA4B-00A0C93EC93B'
LINUX_FILESYSTEM = '0FC63DAF-8483-4772-8E79-3D69D8477DE4'
class elbevalidate.constants.PartitionLabel
DOS = 'msdos'
GPT = 'gpt'