8.1.5. cobbler.settings package Subpackages Module contents

Cobbler app-wide settings

class cobbler.settings.Settings[source]

Bases: object

This class contains all app-wide settings of Cobbler. It should only exist once in a Cobbler instance.

static collection_type() str[source]

This is a hardcoded string which represents the collection type.



static collection_types() str[source]

return the collection plural name

from_dict(new_values: Dict[str, Any]) Optional[Settings][source]

Modify this object to load values in dictionary. If the handed dict would lead to an invalid object it is silently discarded.


If the dict from the args has not all settings included Cobbler may behave unexpectedly.


new_values – The dictionary with settings to replace.


Returns the settings instance this method was called from.

is_valid() bool[source]

Silently drops all errors and returns True when everything is valid.


If this settings object is valid this returns true. Otherwise false.

save(filepath: str = '/etc/cobbler/settings.yaml', ignore_keys: Optional[List[str]] = None) None[source]

Saves the settings to the disk. :param filepath: This sets the path of the settingsfile to write. :param ignore_keys: The list of ignore keys to exclude from migration.

to_dict(resolved: bool = False) Dict[str, Any][source]

Return an easily serializable representation of the config.

Deprecated since version 3.2.1: Use obj.__dict__ directly please. Will be removed with 3.3.0


resolved – Present for the compatibility with the Cobbler collections.


The dict with all user settings combined with settings which are left to the default.

to_string() str[source]

Returns the kernel options as a string.


The multiline string with the kernel options.

cobbler.settings.migrate(yaml_dict: Dict[str, Any], settings_path: Path, ignore_keys: Optional[List[str]] = None) Dict[str, Any][source]

Migrates the current settings

  • yaml_dict – The settings dict

  • settings_path – The settings path

  • ignore_keys – The list of ignore keys to exclude from migration.


The migrated settings

cobbler.settings.read_settings_file(filepath: str = '/etc/cobbler/settings.yaml', ignore_keys: Optional[List[str]] = None) Dict[str, Any][source]

Utilizes read_yaml_file(). If the read settings file is invalid in the context of Cobbler we will return an empty dictionary.

  • filepath – The path to the settings file.

  • ignore_keys – The list of ignore keys to exclude from validation.

  • SchemaMissingKeyError – In case keys are minssing.

  • SchemaWrongKeyError – In case keys are not listed in the schema.

  • SchemaError – In case the schema is wrong.


A dictionary with the settings. As a word of caution: This may not represent a correct settings object, it will only contain a correct YAML representation.

cobbler.settings.read_yaml_file(filepath: str = '/etc/cobbler/settings.yaml') Dict[str, Any][source]

Reads settings files from filepath and saves the content in a dictionary.


filepath – Settings file path, defaults to “/ect/cobbler/settings.yaml”

  • FileNotFoundError – In case file does not exist or is a directory.

  • yaml.YAMLError – In case the file is not a valid YAML file.


The aggregated dict of all settings.

cobbler.settings.update_settings_file(data: Dict[str, Any], filepath: str = '/etc/cobbler/settings.yaml', ignore_keys: Optional[List[str]] = None) bool[source]

Write data handed to this function into the settings file of Cobbler. This function overwrites the existing content. It will only write valid settings. If you are trying to save invalid data this will raise a SchemaException described in cobbler.settings.validate().

  • data – The data to put into the settings file.

  • filepath – This sets the path of the settingsfile to write.

  • ignore_keys – The list of ignore keys to exclude from validation.


True if the action succeeded. Otherwise return False.

cobbler.settings.validate_settings(settings_content: Dict[str, Any], ignore_keys: Optional[List[str]] = None) Dict[str, Any][source]

This function performs logical validation of our loaded YAML files. This function will: - Perform type validation on all values of all keys. - Provide defaults for optional settings. :param settings_content: The dictionary content from the YAML file. :param ignore_keys: The list of ignore keys to exclude from validation. :raises SchemaError: In case the data given is invalid. :return: The Settings of Cobbler which can be safely used inside this instance.