9.1.5. cobbler.settings package

9.1.5.1. Subpackages

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

Returns

“setting”

static collection_types() str[source]

return the collection plural name

from_dict(new_values)[source]

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

Warning

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

Parameters

new_values – The dictionary with settings to replace.

Returns

Returns the settings instance this method was called from.

is_valid() bool[source]

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

Returns

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

save(filepath='/etc/cobbler/settings.yaml')[source]

Saves the settings to the disk.

to_dict() dict[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

Returns

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.

Returns

The multiline string with the kernel options.

cobbler.settings.autodetect_bind_chroot()[source]

Autodetect bind chroot configuration

cobbler.settings.migrate(yaml_dict: dict, settings_path: pathlib.Path) dict[source]

Migrates the current settings

Parameters
  • yaml_dict – The settings dict

  • settings_path – The settings path

Returns

The migrated settings

cobbler.settings.parse_bind_config(configpath: str)[source]

Parse the Bind9 configuration file and adjust the Cobbler default settings according to the readings.

Parameters

configpath – The path in the filesystem where the file can be read.

cobbler.settings.read_settings_file(filepath='/etc/cobbler/settings.yaml') Dict[Hashable, Any][source]

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

Parameters

filepath – The path to the settings file.

Raises
  • SchemaMissingKeyError – In case keys are minssing.

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

  • SchemaError – In case the schema is wrong.

Returns

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='/ect/cobbler/settings.yaml') Dict[Hashable, Any][source]

Reads settings files from filepath and all paths in include (which is read from the settings file) and saves the content in a dictionary. Any key may be overwritten in a later loaded settings file. The last loaded file wins.

Parameters

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

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

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

Returns

The aggregated dict of all settings.

cobbler.settings.update_settings_file(data: dict, filepath='/etc/cobbler/settings.yaml') 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().

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

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

Returns

True if the action succeeded. Otherwise return False.

cobbler.settings.validate_settings(settings_content: dict) dict[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. :raises SchemaError: In case the data given is invalid. :return: The Settings of Cobbler which can be safely used inside this instance.