8.1.5.1.1. cobbler.settings.migrations package
8.1.5.1.1.1. Submodules
8.1.5.1.1.2. cobbler.settings.migrations.V2_8_5 module
Migration from V2.x.x to V2.8.5
- cobbler.settings.migrations.V2_8_5.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to the V2.8.5 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
8.1.5.1.1.3. cobbler.settings.migrations.V3_0_0 module
Migration from V2.8.5 to V3.0.0
- cobbler.settings.migrations.V3_0_0.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to the V3.0.0 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
8.1.5.1.1.4. cobbler.settings.migrations.V3_0_1 module
Migration from V3.0.0 to V3.0.1
- cobbler.settings.migrations.V3_0_1.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to the V3.0.1 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
8.1.5.1.1.5. cobbler.settings.migrations.V3_1_0 module
Migration from V3.0.1 to V3.1.0
- cobbler.settings.migrations.V3_1_0.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to the V3.1.0 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
8.1.5.1.1.6. cobbler.settings.migrations.V3_1_1 module
Migration from V3.1.0 to V3.1.1
- cobbler.settings.migrations.V3_1_1.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to the V3.1.1 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
8.1.5.1.1.7. cobbler.settings.migrations.V3_1_2 module
Migration from V3.1.1 to V3.1.2
- cobbler.settings.migrations.V3_1_2.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to the V3.1.2 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
8.1.5.1.1.8. cobbler.settings.migrations.V3_2_0 module
Migration from V3.1.2 to V3.2.0
- cobbler.settings.migrations.V3_2_0.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to the V3.2.0 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
8.1.5.1.1.9. cobbler.settings.migrations.V3_2_1 module
Migration from V3.2.0 to V3.2.1
- cobbler.settings.migrations.V3_2_1.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to the V3.2.1 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
8.1.5.1.1.10. cobbler.settings.migrations.V3_3_0 module
Migration from V3.2.1 to V3.3.0
- cobbler.settings.migrations.V3_3_0.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to version V3.3.0 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
- cobbler.settings.migrations.V3_3_0.migrate_cobbler_collections(collections_dir: str) None [source]
Manipulate the main Cobbler stored collections and migrate deprecated settings to work with newer Cobbler versions.
- Parameters
collections_dir – The directory of Cobbler where the collections files are.
8.1.5.1.1.11. cobbler.settings.migrations.V3_3_1 module
Migration from V3.3.0 to V3.3.1
- cobbler.settings.migrations.V3_3_1.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to version V3.3.1 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
8.1.5.1.1.12. cobbler.settings.migrations.V3_3_2 module
Migration from V3.3.1 to V3.3.2
- cobbler.settings.migrations.V3_3_2.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to version V3.3.1 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
8.1.5.1.1.13. cobbler.settings.migrations.V3_3_3 module
Migration from V3.3.2 to V3.3.3
- cobbler.settings.migrations.V3_3_3.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to version V3.3.1 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
8.1.5.1.1.14. cobbler.settings.migrations.V3_3_4 module
Migration from V3.3.3 to V3.3.4
- cobbler.settings.migrations.V3_3_4.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to version V3.3.4 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
8.1.5.1.1.15. cobbler.settings.migrations.V3_3_5 module
Migration from V3.3.4 to V3.3.5
- cobbler.settings.migrations.V3_3_5.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to version V3.3.4 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
8.1.5.1.1.16. cobbler.settings.migrations.V3_4_0 module
Migration from V3.3.3 to V3.4.0
- cobbler.settings.migrations.V3_4_0.migrate(settings: Dict[str, Any]) Dict[str, Any] [source]
Migration of the settings
settings
to version V3.4.0 settings- Parameters
settings – The settings dict to migrate
- Returns
The migrated dict
- cobbler.settings.migrations.V3_4_0.migrate_cobbler_collections(collections_dir: str) None [source]
Manipulate the main Cobbler stored collections and migrate deprecated settings to work with newer Cobbler versions.
- Parameters
collections_dir – The directory of Cobbler where the collections files are.
8.1.5.1.1.17. cobbler.settings.migrations.helper module
Helper module which contains shared logic for adjusting the settings.
- class cobbler.settings.migrations.helper.Setting(location: Union[str, List[str]], value: Any)[source]
Bases:
object
Specifies a setting object
- cobbler.settings.migrations.helper.backup_dir(dir_path: str) None [source]
Copies the directory tree and adds a suffix “.backup.XXXXXXXXX” to it.
- Parameters
dir_path – The full path to the directory which should be backed up.
- Raises
FileNotFoundError – In case the path specified was not existing.
- cobbler.settings.migrations.helper.key_add(new: Setting, settings: Dict[str, Any]) None [source]
Add a new settings key.
- Parameters
new – The new setting to add.
settings – [description]
- cobbler.settings.migrations.helper.key_delete(delete: str, settings: Dict[str, Any]) None [source]
Deletes a given setting
- Parameters
delete – The name of the setting to be deleted.
settings – The settings dict where the key should be deleted.
- cobbler.settings.migrations.helper.key_drop_if_default(settings: Dict[str, Any], defaults: Dict[str, Any]) Dict[str, Any] [source]
Drop all keys which values are identical to the default ones.
- Parameters
settings – The current settings read from an external source
defaults – The full settings with default values
- cobbler.settings.migrations.helper.key_get(key: str, settings: Dict[str, Any]) Setting [source]
Get a key from the settings
- Parameters
key – The key to get in the form “a.b.c”
settings – The dict to operate on.
- Returns
The desired key from the settings dict
- cobbler.settings.migrations.helper.key_move(move: Setting, new_location: List[str], settings: Dict[str, Any]) None [source]
Delete the old setting and create a new key at
new_location
- Parameters
move – The name of the old key which should be moved.
new_location – The location of the new key
settings – The dict to operate on.
8.1.5.1.1.18. Module contents
The name of the migration file is the target version. One migration should update from version x to x + 1, where X is any Cobbler version and the migration updates to any next version (e.g. 3.2.1 to 3.3.0). The validation of the current version is in the file with the name of the version.
- class cobbler.settings.migrations.CobblerVersion(major: int = 0, minor: int = 0, patch: int = 0)[source]
Bases:
object
Specifies a Cobbler Version
- cobbler.settings.migrations.auto_migrate(yaml_dict: Dict[str, Any], settings_path: Path, ignore_keys: Optional[List[str]] = None) Dict[str, Any] [source]
Auto migration to the most recent version.
- Parameters
yaml_dict – The settings dict to migrate.
ignore_keys – The list of ignore keys to exclude from auto migration.
settings_path – The path of the settings dict.
- Returns
The migrated dict.
- cobbler.settings.migrations.discover_migrations(path: str = '/home/docs/checkouts/readthedocs.org/user_builds/cobbler/checkouts/latest/cobbler/settings/migrations') None [source]
- Discovers the migration module for each Cobbler 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
- Parameters
path – The path of the migration modules, defaults to migrations_path
- cobbler.settings.migrations.filter_settings_to_validate(settings: Dict[str, Any], ignore_keys: Optional[List[str]] = None) Tuple[Dict[str, Any], Dict[str, Any]] [source]
Separate settings to validate from the ones to exclude from validation according to “ignore_keys” parameter and “extra_settings_list” setting value.
- Parameters
settings – The settings dict to validate.
ignore_keys – The list of ignore keys to exclude from validation.
- Return data
The filtered settings to validate
- Return data_to_exclude
The settings that were excluded from the validation
- cobbler.settings.migrations.get_installed_version(filepath: Union[str, Path] = '/etc/cobbler/version') CobblerVersion [source]
Retrieve the current Cobbler version. Normally it can be read from /etc/cobbler/version
- Parameters
filepath – The filepath of the version file, defaults to “/etc/cobbler/version”
- cobbler.settings.migrations.get_schema(version: CobblerVersion) Schema [source]
Returns a schema to a given Cobbler version
- Parameters
version – The Cobbler version object
- Returns
The schema of the Cobbler version
- cobbler.settings.migrations.get_settings_file_version(yaml_dict: Dict[str, Any], ignore_keys: Optional[List[str]] = None) CobblerVersion [source]
Return the correspondig version of the given settings dict.
- Parameters
yaml_dict – The settings dict to get the version from.
ignore_keys – The list of ignore keys to exclude from validation.
- Returns
The discovered Cobbler Version or
EMPTY_VERSION
- cobbler.settings.migrations.migrate(yaml_dict: Dict[str, Any], settings_path: Path, old: CobblerVersion = CobblerVersion(major=0, minor=0, patch=0), new: CobblerVersion = CobblerVersion(major=0, minor=0, patch=0), ignore_keys: Optional[List[str]] = None) Dict[str, Any] [source]
Migration to a specific version. If no old and new version is supplied it will call
auto_migrate()
.- Parameters
yaml_dict – The settings dict to migrate.
settings_path – The path of the settings dict.
old – The version to migrate from, defaults to EMPTY_VERSION.
new – The version to migrate to, defaults to EMPTY_VERSION.
ignore_keys – The list of settings ot be excluded from migration.
- Raises
ValueError – Raised if attempting to downgraade.
- Returns
The migrated dict.
- cobbler.settings.migrations.normalize(settings: Dict[str, Any], ignore_keys: Optional[List[str]] = None) Dict[str, Any] [source]
If data in
settings
is valid the validated data is returned.- Parameters
settings – The settings dict to validate.
ignore_keys – The list of settings ot be excluded from normalization.
- Returns
The validated dict.
- cobbler.settings.migrations.validate(settings: Dict[str, Any], settings_path: Path, ignore_keys: Optional[List[str]] = None) bool [source]
Wrapper function for the validate() methods of the individual migration modules.
- Parameters
settings – The settings dict to validate.
settings_path – TODO: not used at the moment
ignore_keys – The list of settings ot be excluded from validation.
- Returns
True if settings are valid, otherwise False.