7.1.9.1.1. cobbler.settings.migrations package

7.1.9.1.1.1. Submodules

7.1.9.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

cobbler.settings.migrations.V2_8_5.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V2_8_5.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.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

cobbler.settings.migrations.V3_0_0.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_0_0.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.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

cobbler.settings.migrations.V3_0_1.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_0_1.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.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

cobbler.settings.migrations.V3_1_0.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_1_0.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.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

cobbler.settings.migrations.V3_1_1.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_1_1.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.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

cobbler.settings.migrations.V3_1_2.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_1_2.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.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

cobbler.settings.migrations.V3_2_0.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_2_0.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.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

cobbler.settings.migrations.V3_2_1.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_2_1.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.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.

cobbler.settings.migrations.V3_3_0.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_3_0.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference V3.3.0 schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.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

cobbler.settings.migrations.V3_3_1.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_3_1.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference V3.3.1 schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.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

cobbler.settings.migrations.V3_3_2.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_3_2.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference V3.3.1 schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.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

cobbler.settings.migrations.V3_3_3.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_3_3.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference V3.3.1 schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.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

cobbler.settings.migrations.V3_3_4.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_3_4.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference V3.3.1 schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.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

cobbler.settings.migrations.V3_3_5.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_3_5.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference V3.3.1 schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.1.1.16. cobbler.settings.migrations.V3_3_6 module

Migration from V3.3.5 to V3.3.6

cobbler.settings.migrations.V3_3_6.migrate(settings: Dict[str, Any]) Dict[str, Any][source]

Migration of the settings settings to version V3.3.6 settings

Parameters:

settings – The settings dict to migrate

Returns:

The migrated dict

cobbler.settings.migrations.V3_3_6.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_3_6.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference V3.3.6 schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.1.1.17. cobbler.settings.migrations.V3_3_7 module

Migration from V3.3.6 to V3.3.7

cobbler.settings.migrations.V3_3_7.migrate(settings: Dict[str, Any]) Dict[str, Any][source]

Migration of the settings settings to version V3.3.7 settings

Parameters:

settings – The settings dict to migrate

Returns:

The migrated dict

cobbler.settings.migrations.V3_3_7.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V3_3_7.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference V3.3.6 schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.1.1.18. cobbler.settings.migrations.V4_0_0 module

Migration from V3.3.3 to V4.0.0

exception cobbler.settings.migrations.V4_0_0.AmbiguousDataSourceError[source]

Bases: RuntimeError

Raised when more than one of the file/sqlite/mongodb data sources appears to hold real Cobbler collection data at once, making it unsafe to guess which one is authoritative.

cobbler.settings.migrations.V4_0_0.determine_and_migrate_collections_data(settings: Dict[str, Any], iso_template_dir: str, boot_loader_conf_template_dir: str, jinja2_includedir: str, autoinstall_snippets_dir: str, autoinstall_templates_dir: str, default_template_type: str) None[source]

Determine which single backend (file/sqlite/mongodb) actually holds the install’s collection data, and migrate it. Refuses to run if more than one backend shows real data present, since it would be unsafe to guess which one is authoritative. If the declared serializer is serializers.mongodb, a working connection is required - this is a hard requirement, not a best-effort skip.

Parameters:

settings – The settings dict being migrated (already contains “modules”).

Raises:

RuntimeError – If multiple data sources are present, or if the declared MongoDB serializer can’t actually be reached.

cobbler.settings.migrations.V4_0_0.migrate(settings: Dict[str, Any]) Dict[str, Any][source]

Migration of the settings settings to version V4.0.0 settings

Parameters:

settings – The settings dict to migrate

Returns:

The migrated dict

cobbler.settings.migrations.V4_0_0.migrate_cobbler_autoinstall_templates(collections_dir: str, autoinstall_templates_dir: str, default_template_type: str, settings: Dict[str, Any]) None[source]

Create dedicated Template collection records for legacy autoinstall path references - both per-item (profile/system/image) and the global settings["autoinstall"] default, which items with an inherited/unset autoinstall resolve to (V4.0.0 replaced the flat path string with a reference to a Template item in both places) - and rewrite each reference to the new Template’s uid.

A legacy reference to a file that no longer exists under autoinstall_templates_dir is dropped (with a warning) instead of causing the whole referencing item to fail to load later.

Parameters:
  • collections_dir – The directory of Cobbler where the collections files are.

  • autoinstall_templates_dir – The directory autoinstall template paths are relative to.

  • default_template_type – The template engine to assign to synthesized Template records.

  • settings – The settings dict, whose “autoinstall” default is migrated in place if present.

cobbler.settings.migrations.V4_0_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.

cobbler.settings.migrations.V4_0_0.migrate_cobbler_iso_and_bootloader_templates(collections_dir: str, iso_template_dir: str, boot_loader_conf_template_dir: str, autoinstall_templates_dir: str, default_template_type: str) None[source]

Create dedicated Template collection records for the legacy iso_template_dir/boot_loader_conf_template_dir directories, which V4.0.0 replaced with Template records looked up by tag (e.g. iso_buildiso, grub_menu). Known legacy filenames are tagged with their well-known tag plus “active” (so they take effect over the shipped built-in default - a template with only the kind-tag and neither “active” nor “default” is never selected by any of the lookups in cobbler/actions/buildiso/__init__.py or cobbler/tftpgen.py). Unrecognized files are still migrated (content preserved) but left untagged.

Files are physically copied into a subdirectory of autoinstall_templates_dir, since that is the only directory Template’s FILE-schema content resolves against.

Parameters:
  • collections_dir – The directory of Cobbler where the collections files are.

  • iso_template_dir – The legacy directory containing ISO build templates.

  • boot_loader_conf_template_dir – The legacy directory containing boot-loader config generation templates.

  • autoinstall_templates_dir – The directory Template file paths are relative to.

  • default_template_type – The template engine for unrecognized/custom files.

cobbler.settings.migrations.V4_0_0.migrate_cobbler_item_options(collections_dir: str) None[source]

Reshape flat legacy item fields that were moved into nested “Option” sub-objects in V4.0.0 (e.g. power_address -> power.address), and drop the per-item mgmt_classes/mgmt_parameters fields, which no longer exist on any item class.

Parameters:

collections_dir – The directory of Cobbler where the collections files are.

cobbler.settings.migrations.V4_0_0.migrate_cobbler_json_files(collection_folder: Path) None[source]

Rename all JSON files from name-based files to uid-based files.

Parameters:

collection_folder – The directory of Cobbler where the collections files are.

cobbler.settings.migrations.V4_0_0.migrate_cobbler_network_interfaces(collection_folder: Path) None[source]

Move all network interfaces from embedded system files to the dedicated collection.

Parameters:

collection_folder – The directory of Cobbler where the collections files are.

cobbler.settings.migrations.V4_0_0.migrate_cobbler_snippets_and_jinja_includes(collections_dir: str, jinja2_includedir: str, autoinstall_snippets_dir: str, autoinstall_templates_dir: str, default_template_type: str) None[source]

Create dedicated, name-addressable Template collection records for every file under the legacy jinja2_includedir/autoinstall_snippets_dir directories. V4.0.0 resolves both Jinja2 {% include "x" %} and Cheetah SNIPPET::x directives via find_template(name="x") rather than a filesystem search path.

Files are physically copied into a subdirectory of autoinstall_templates_dir. Any SNIPPET::<old-path>/{% include "<old-path>" %} reference embedded in other already-migrated template content is intentionally NOT rewritten (that would mean parsing/rewriting arbitrary template syntax across two different template languages, too risky for this migration to attempt automatically) - a warning is logged listing every renamed path so an admin can update references manually.

Parameters:
  • collections_dir – The directory of Cobbler where the collections files are.

  • jinja2_includedir – The legacy directory Jinja2 templates could include from.

  • autoinstall_snippets_dir – The legacy directory holding reusable autoinstall snippets.

  • autoinstall_templates_dir – The directory Template file paths are relative to.

  • default_template_type – The template engine to assign to the migrated records.

cobbler.settings.migrations.V4_0_0.migrate_cobbler_uid_references(collections_dir: str) None[source]

Rewrite cross-item reference fields that stored the referenced item’s name in V3.3.7 to use its uid instead, matching the V4.0.0 item model where items are looked up by uid rather than name.

Parameters:

collections_dir – The directory of Cobbler where the collections files are.

cobbler.settings.migrations.V4_0_0.normalize(settings: Dict[str, Any]) Dict[str, Any][source]

If data in settings is valid the validated data is returned.

Parameters:

settings – The settings dict to validate.

Returns:

The validated dict.

cobbler.settings.migrations.V4_0_0.validate(settings: Dict[str, Any]) bool[source]

Checks that a given settings dict is valid according to the reference V4.0.0 schema schema.

Parameters:

settings – The settings dict to validate.

Returns:

True if valid settings dict otherwise False.

7.1.9.1.1.19. cobbler.settings.migrations.helper module

Helper module which contains shared logic for adjusting the settings.

class cobbler.settings.migrations.helper.Setting(location: str | List[str], value: Any)[source]

Bases: object

Specifies a setting object

property key_name: str

Returns the location.

static split_str_location(location: str) List[str][source]

Split the given location at “.” Necessary for nesting in our settings file

Parameters:

location – Can be “manage.dhcp_v4” or “restart.dhcp_v4” for example.

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.

cobbler.settings.migrations.helper.key_rename(old_name: Setting, new_name: str, settings: Dict[str, Any]) None[source]

Wrapper for key_move()

Parameters:
  • old_name – The old name

  • new_name – The new name

  • settings

cobbler.settings.migrations.helper.key_set_value(new: Setting, settings: Dict[str, Any]) None[source]

Change the value of a setting.

Parameters:
  • new – A Settings object with the new information.

  • settings – The settings dict.

7.1.9.1.1.20. 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: List[str] | None = 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: List[str] | None = 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() CobblerVersion[source]

Retrieve the current Cobbler version from cobbler._version.

Returns:

The installed CobblerVersion, or EMPTY_VERSION on failure.

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: List[str] | None = 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: List[str] | None = 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: List[str] | None = 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: List[str] | None = 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.