Disk Types¶
Whilst Astdiskd is responsible for detecting what disks are attached to the system, it is the responsibility of each individual data component to determine if a disk is relevant to Astoria.
Disks are sorted into one of a few relevant types:
Usercode
Metadata
Update
No Action
Disk Identification¶
A disk can only have one type, the value of which must be a member of astoria.common.disks.DiskType
.
Given the mount path for a disk, the type of the disk can be found using astoria.common.disks.DiskTypeCalculator
.
The path is compared against a astoria.common.disks.constraints.Constraint
for each type. The type that is returned will be the first type for which the constraint matches.
As a disk must always have a type, the last constraint in the list is DiskType.NOACTION, which is matched using a astoria.common.disks.constraints.TrueConstraint
.
Constraints¶
A constraint is a class that implements astoria.common.disks.constraints.Constraint
. Given a path, a constaint will determine if the path matches the constraint or not.
Some constraints, such as astoria.common.disks.constraints.AndConstraint
take other constraints as parameters in the constructor. This allows us to combine constraints programmatically.
A full list of available constraints, along with their uses is listed in Constraint Definitions.
Disk Type Classes¶
- class astoria.common.disks.DiskType(value)[source]¶
Type of disk.
- METADATA = 'METADATA'¶
- NOACTION = 'NOACTION'¶
- USERCODE = 'USERCODE'¶
- class astoria.common.disks.DiskTypeCalculator(default_usercode_entrypoint)[source]¶
Helper class to calculate the DiskType of a given disk drive.
Warning
A disk must only rely on itself and not other disks to determine it the type of the disk.
Constraint Definitions¶
- class astoria.common.disks.constraints.FilePresentConstraint(filename)[source]¶
Ensure that a file is present on the disk.
This constraint will check that the path exists and contains the given file.
- class astoria.common.disks.constraints.NumberOfFilesConstraint(n)[source]¶
Ensure that a certain number of files are present.
This can be used to ensure that there are no spurious files on the disk.
- class astoria.common.disks.constraints.OrConstraint(a, b)[source]¶
Ensure that either of the given constraints match.
- __init__(a, b)[source]¶
Initialise the constraint class.
- Parameters:
a (
Constraint
) – The first constraintb (
Constraint
) – The second constraint
- class astoria.common.disks.constraints.AndConstraint(a, b)[source]¶
Ensure that both of the constraints match.
- __init__(a, b)[source]¶
Initialise the constraint class.
- Parameters:
a (
Constraint
) – The first constraintb (
Constraint
) – The second constraint
- class astoria.common.disks.constraints.NotConstraint(a)[source]¶
Ensure that the constraint does not match.
- __init__(a)[source]¶
Initialise the constraint class.
- Parameters:
a (
Constraint
) – The constraint to negate