9.1.5.1.1. cobbler.settings.migrations package

9.1.5.1.1.1. Submodules

9.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) dict[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) dict[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) 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.

9.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) dict[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) dict[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) 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.

9.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) dict[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) dict[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) 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.

9.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) dict[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) dict[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) 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.

9.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) dict[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) dict[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) 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.

9.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) dict[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) dict[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) 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.

9.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) dict[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) dict[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) 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.

9.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) dict[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) dict[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) 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.

9.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) dict[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.normalize(settings: dict) dict[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) 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.

9.1.5.1.1.11. cobbler.settings.migrations.helper module

Helper module which contains shared logic for adjusting the settings.

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

Bases: object

Specifies a setting object

property key_name: str

Returns the location.

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

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

Example: manage.dhcp_v4 restart.dhcp_v4

Parameters:

location

cobbler.settings.migrations.helper.key_add(new: Setting, settings: dict)[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)[source]

Deletes a given setting

Parameters:
  • delete – The name of the setting to be deleted.

  • setting – The settings dict where the the key should be deleted.

cobbler.settings.migrations.helper.key_drop_if_default(settings: dict, defaults: dict) dict[source]

Drop all keys which values are identical to the dafault 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) 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)[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

cobbler.settings.migrations.helper.key_rename(old_name: Setting, new_name: str, settings: dict)[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)[source]

Change the value of a setting.

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

  • setting – The settings dict.

9.1.5.1.1.12. 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, settings_path: Path) dict[source]

Auto migration to the most recent version.

Parameters:
  • yaml_dict – The settings dict to migrate.

  • 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/v3.3.4/cobbler/settings/migrations')[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.get_installed_version(filepath: 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) CobblerVersion[source]

Return the correspondig version of the given settings dict.

Parameters:

yaml_dict – The settings dict to get the version from.

Returns:

The discovered Cobbler Version or EMPTY_VERSION

cobbler.settings.migrations.migrate(yaml_dict: dict, settings_path: Path, old: CobblerVersion = CobblerVersion(major=0, minor=0, patch=0), new: CobblerVersion = CobblerVersion(major=0, minor=0, patch=0)) dict[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.

Raises:

ValueError – Raised if attempting to downgraade.

Returns:

The migrated dict.

cobbler.settings.migrations.normalize(settings: dict) dict[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.validate(settings: dict, settings_path: Path = '') 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

Returns:

True if settings are valid, otherwise False.