cobbler_tftp.settings.migrations package
Submodules
cobbler_tftp.settings.migrations.v1_0 module
Module for the validation, normalization and migration of the schema version “1.0”.
- cobbler_tftp.settings.migrations.v1_0.migrate(settings_dict: Dict[str, float | bool | str | Path | Dict[str, int | str | Path]]) Dict[str, float | bool | str | Path | Dict[str, int | str | Path]]
Migrate settings dict from previous to current version.
- Parameters:
settings_dict – The dictionary to migrate
- Returns:
The settings dict
- cobbler_tftp.settings.migrations.v1_0.normalize(settings_dict: Dict[str, float | bool | str | Path | Dict[str, int | str | Path]]) Dict[str, float | bool | str | Path | Dict[str, int | str | Path]]
If data in
settings_dictis valid, the validated data is returned.- Parameters:
settings_dict – The dictionary of configuration parameters to validate
- Returns:
the validated dict
- Rtype dict:
- cobbler_tftp.settings.migrations.v1_0.validate(settings_dict: Dict[str, float | bool | str | Path | Dict[str, int | str | Path]]) bool
Validate the given dictionary of configuration parameters to the reference
schema.- Parameters:
settings_dict – The dictionary of configuration parameters to validate
- Return bool:
True/False depending on whether the dicts match or not
cobbler_tftp.settings.migrations.whitelist__init__ module
cobbler_tftp.settings.migrations.whitelist_v1_0 module
Module contents
Schemas for cobbler-tftp settings for validating the parsed settings.
The name of the migration contains the target version. One migration should be able to update from version x to version x+1, where x is any cobbler-tftp version. The validation logic of the current version is located in the version’s migration file.
- class cobbler_tftp.settings.migrations.CobblerTftpSchemaVersion(major: int = 0, minor: int = 0)
Bases:
objectSpecifies the version of cobbler-tftp.
- cobbler_tftp.settings.migrations.auto_migrate(settings_dict: Dict[str, float | bool | str | Path | Dict[str, int | str | Path]], settings_path: Path) Dict[str, float | bool | str | Path | Dict[str, int | str | Path]]
Auto migration to the most recent version.
- Parameters:
settings_dict – The dictionary of configuration parameters
settings_path – the path of the migration
- Returns:
The migrated settings as dict
- cobbler_tftp.settings.migrations.discover_migrations() None
Discovers all available migrations and loads valid ones.
Discovers the migration module for each cobbler-tftp version and loads it if it is valid according to certain conditions:
the module must contain the following methods:
validate(),normalize(),migrate()those version must have a certain signature
- cobbler_tftp.settings.migrations.get_current_schema_version() CobblerTftpSchemaVersion
Get the highest available schema version.
- Returns:
The highest
CobblerTftpSchemaVersion.
- cobbler_tftp.settings.migrations.get_schema(version: CobblerTftpSchemaVersion) Schema
Return a schema for a given cobbler-tftp version.
- Parameters:
version – The cobbler-tftp version object
- Returns:
The schema of the cobbler-tftp version
- cobbler_tftp.settings.migrations.get_schema_version(settings_dict: Dict[str, float | bool | str | Path | Dict[str, int | str | Path]]) CobblerTftpSchemaVersion
Retrieve current cobbler-tftp settings schema version from the settings dict.
- Parameters:
settings_dict – The dictionary of settings parameters
- cobbler_tftp.settings.migrations.migrate(settings_dict: Dict[str, float | bool | str | Path | Dict[str, int | str | Path]], settings_path: Path, old: CobblerTftpSchemaVersion = CobblerTFTPVersion(major=0, minor=0), new: CobblerTftpSchemaVersion = CobblerTFTPVersion(major=0, minor=0)) Dict[str, float | bool | str | Path | Dict[str, int | str | Path]]
Migrate to a specific version. If no old and new version is supplied it will call
auto_migrate().- Parameters:
settings_dict – The dict of settings parameters to migrate
settings_path – The path of the settings dict
old – The version to migrate from, defaults to
EMPTY_VERSIONnew – The version to migrate to, defaults to
EMPTY_VERSION
- Raises:
ValueError – Raised if attempting to downgrade
- Returns:
The migrated dict
- cobbler_tftp.settings.migrations.normalize(settings_dict: Dict[str, float | bool | str | Path | Dict[str, int | str | Path]]) Dict[str, float | bool | str | Path | Dict[str, int | str | Path]]
If data in
settings_dictis valid the normalized data is returned.- Parameters:
settings_dict – The settings dict to validate
- Returns:
The validated dict
- cobbler_tftp.settings.migrations.validate(settings_dict: Dict[str, float | bool | str | Path | Dict[str, int | str | Path]]) bool
Tail-call for the methods of the individual migration modules.
- Parameters:
settings_dict – The settings dict to validate.
- Returns:
True if settings are valid, otherwise False.