7. cobbler package

7.1. Subpackages

7.2. Submodules

7.3. cobbler.api module

This module represents the Cobbler Python API. It is used by the XML-RPC API and can be used by external consumers.

Changelog:

Schema: From -> To

Current Schema: Please refer to the documentation visible of the individual methods.

V4.0.0 (unreleased)
  • Added:
    • Create, Read, Update & Delete methods for the NetworkInterface class

    • clean_items_cache

    • new_item

    • deserialize_item

    • input_string_or_list_no_inherit

    • input_string_or_list

    • input_string_or_dict

    • input_string_or_dict_no_inherit

    • input_boolean

    • input_int

  • Changed:
    • new_*: Accepts kwargs as a last argument now (so a dict) that makes it possible to seed an object

  • Removed:
    • Unused reporter module

V3.3.4 (unreleased)
  • No changes

V3.3.3
  • Added:
    • get_item_resolved_value

    • set_item_resolved_value

  • Changed:
    • dump_vars: Added boolean parameter remove_dicts as a new last argument

V3.3.2
  • No changes

V3.3.1
  • Changes:
    • add_system: Parameter check_for_duplicate_netinfo was removed

    • build_iso: Replaced default None arguments with typed arguments

    • create_grub_images: Renamed to mkloaders

V3.3.0
  • Added:
    • menus

    • copy_menu

    • remove_menu

    • rename_menu

    • new_menu

    • add_menu

    • find_menu

    • get_menus_since

    • sync_systems

    • sync_dns

    • get_valid_obj_boot_loaders

    • create_grub_images

  • Changed:
    • Constructor: Added settingsfile_location and execute_settings_automigration as parameters

    • find_items: Accept an empty str for what if the argument name is given.

    • dump_vars: Parameter format was renamed to formatted_output

    • generate_gpxe: Renamed to generate_ipxe; The second parameter is now image and accepts the name of one.

    • sync: Accepts a new parameter called what which is a List[str] that signals what should be synced. An empty list signals a full sync.

    • sync_dhcp: Parameter verbose was removed

  • Removed:
    • The logger arugment was removed from all methods

    • dlcontent

V3.2.2
  • No changes

V3.2.1
  • Added primitive type annotations for all parameters of all methods

V3.2.0
  • No changes

V3.1.2
  • No changes

V3.1.1
  • No changes

V3.1.0
  • No changes

V3.0.1
  • No changes

V3.0.0
  • Added:
    • power_system: Replaces power_on, power_off, reboot, power_status

  • Changed:
    • import_tree: kickstart_file is now called autoinstall_file

  • Removed:
    • update

    • clear

    • deserialize_raw

    • deserialize_item_raw

    • power_on - Replaced by power_system

    • power_off - Replaced by power_system

    • reboot - Replaced by power_system

    • power_status - Replaced by power_system

V2.8.5
  • Inital tracking of changes.

class cobbler.api.CobblerAPI(is_cobblerd: bool = False, settingsfile_location: str = '/etc/cobbler/settings.yaml', execute_settings_automigration: bool = False)[source]

Bases: object

Python API module for Cobbler. See source for cobbler.py, or pydoc, for example usage. Cli apps and daemons should import api.py, and no other Cobbler code.

acl_config(adduser: str | None = None, addgroup: str | None = None, removeuser: str | None = None, removegroup: str | None = None) None[source]

Configures users/groups to run the Cobbler CLI as non-root. Pass in only one option at a time. Powers cobbler aclconfig.

Parameters:
  • adduser

  • addgroup

  • removeuser

  • removegroup

add_distro(ref: Distro, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Add a distribution to Cobbler.

Parameters:
  • ref – The identifier for the object to add to a collection.

  • check_for_duplicate_names – If the name should be unique or can be present multiple times.

  • save – If the item should be persisted.

  • with_triggers – If triggers should be run when the object is added.

  • with_sync – In case a Cobbler Sync should be executed after the action.

add_distro_group(ref: DistroGroup, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Add a distro group to Cobbler.

Parameters:
  • ref – The identifier for the object to add to a collection.

  • check_for_duplicate_names – If the name should be unique or can be present multiple times.

  • save – If the item should be persisted.

  • with_triggers – If triggers should be run when the object is added.

  • with_sync – In case a Cobbler Sync should be executed after the action.

add_image(ref: Image, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Add an image to Cobbler.

Parameters:
  • ref – The identifier for the object to add to a collection.

  • check_for_duplicate_names – If the name should be unique or can be present multiple times.

  • save – If the item should be persisted.

  • with_triggers – If triggers should be run when the object is added.

  • with_sync – In case a Cobbler Sync should be executed after the action.

add_item(what: str, ref: BaseItem, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Add an abstract item to a collection of its specific items. This is not meant for external use. Please reefer to one of the specific methods add_<type>.

Parameters:
  • what – The item type.

  • ref – The identifier for the object to add to a collection.

  • check_for_duplicate_names – If the name should be unique or can be present multiple times.

  • save – If the item should be persisted.

  • with_triggers – If triggers should be run when the object is added.

  • with_sync – In case a Cobbler Sync should be executed after the action.

add_menu(ref: Menu, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Add a submenu to Cobbler.

Parameters:
  • ref – The identifier for the object to add to a collection.

  • check_for_duplicate_names – If the name should be unique or can be present multiple times.

  • save – If the item should be persisted.

  • with_triggers – If triggers should be run when the object is added.

  • with_sync – In case a Cobbler Sync should be executed after the action.

add_network_interface(ref: NetworkInterface, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Add a Network Interface to Cobbler.

Parameters:
  • ref – The identifier for the object to add to a collection.

  • check_for_duplicate_names – If the name should be unique or can be present multiple times.

  • save – If the item should be persisted.

  • with_triggers – If triggers should be run when the object is added.

  • with_sync – In case a Cobbler Sync should be executed after the action.

add_profile(ref: Profile, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Add a profile to Cobbler.

Parameters:
  • ref – The identifier for the object to add to a collection.

  • check_for_duplicate_names – If the name should be unique or can be present multiple times.

  • save – If the item should be persisted.

  • with_triggers – If triggers should be run when the object is added.

  • with_sync – In case a Cobbler Sync should be executed after the action.

add_profile_group(ref: ProfileGroup, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Add a profile group to Cobbler.

Parameters:
  • ref – The identifier for the object to add to a collection.

  • check_for_duplicate_names – If the name should be unique or can be present multiple times.

  • save – If the item should be persisted.

  • with_triggers – If triggers should be run when the object is added.

  • with_sync – In case a Cobbler Sync should be executed after the action.

add_remove_items(items: List[TransactionTuple]) None[source]

Add or remove multiple items. 1. Checks for external modifications using mtime 2. Processes deletions first (deepest dependencies first) 3. Processes additions and modifications 4. Rebuilds the PXE configuration

Parameters:

items – The list of items.

add_repo(ref: Repo, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Add a repository to Cobbler.

Parameters:
  • ref – The identifier for the object to add to a collection.

  • check_for_duplicate_names – If the name should be unique or can be present multiple times.

  • save – If the item should be persisted.

  • with_triggers – If triggers should be run when the object is added.

  • with_sync – In case a Cobbler Sync should be executed after the action.

add_system(ref: System, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Add a system to Cobbler.

Parameters:
  • ref – The identifier for the object to add to a collection.

  • check_for_duplicate_names – If the name should be unique or can be present multiple times.

  • save – If the item should be persisted.

  • with_triggers – If triggers should be run when the object is added.

  • with_sync – In case a Cobbler Sync should be executed after the action.

add_system_group(ref: SystemGroup, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Add a system group to Cobbler.

Parameters:
  • ref – The identifier for the object to add to a collection.

  • check_for_duplicate_names – If the name should be unique or can be present multiple times.

  • save – If the item should be persisted.

  • with_triggers – If triggers should be run when the object is added.

  • with_sync – In case a Cobbler Sync should be executed after the action.

add_template(ref: Template, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Add a Template to Cobbler.

Parameters:
  • ref – The identifier for the object to add to a collection.

  • check_for_duplicate_names – If the name should be unique or can be present multiple times.

  • save – If the item should be persisted.

  • with_triggers – If triggers should be run when the object is added.

  • with_sync – In case a Cobbler Sync should be executed after the action.

authenticate(user: str, password: str) bool[source]

(Remote) access control. This depends on the chosen authentication module. Cobbler internal use only.

Parameters:
  • user – The username to check for authentication.

  • password – The password to check for authentication.

Returns:

Whether the action succeeded or not.

authorize(user: str, resource: str, arg1: str | None = None, arg2: Any = None) int[source]

(Remote) access control. This depends on the chosen authorization module. Cobbler internal use only.

Parameters:
  • user – The username to check for authorization.

  • resource – The type of resource which should be checked for access from the supplied user.

  • arg1 – The actual resource to check for authorization.

  • arg2 – Not known what this parameter does exactly.

Returns:

The return code of the action.

auto_add_repos() None[source]

Import any repos this server knows about and mirror them. Run cobbler reposync to apply the changes. Credit: Seth Vidal.

:raises ImportError

build_iso(iso: str = 'autoinst.iso', profiles: List[str] | None = None, systems: List[str] | None = None, buildisodir: str = '', distro_name: str | None = None, standalone: bool = False, airgapped: bool = False, source: str = '', exclude_dns: bool = False, exclude_systems: bool = False, xorrisofs_opts: str = '', esp: str | None = None) None[source]

Build an iso image which may be network bootable or not.

Parameters:
  • iso – The name of the ISO. Defaults to autoinst.iso.

  • profiles – Use these profiles only

  • systems – Use these systems only

  • buildisodir – This overwrites the directory from the settings in which the iso is built in.

  • distro_name – Use this distro architecture. If not used, autodetected from profiles or systems.

  • standalone – This means that no network connection is needed to install the generated iso.

  • airgapped – This option implies standalone=True.

  • source – If the iso should be offline available this is the path to the sources of the image.

  • exclude_dns – Whether the repositories have to be locally available or the internet is reachable.

  • exclude_systems – Whether system entries should be skipped or generated.

  • xorrisofs_optsxorrisofs options to include additionally.

  • esp – location of the ESP partition, e.g. for secure boot.

check() List[str][source]

See if all preqs for network booting are valid. This returns a list of strings containing instructions on things to correct. An empty list means there is nothing to correct, but that still doesn’t mean there are configuration errors. This is mainly useful for human admins, who may, for instance, forget to properly set up their TFTP servers for PXE, etc.

Returns:

A list of things to address.

clean_items_cache(obj: Settings | Dict[str, Any])[source]

Items cache invalidation in case of settings or singatures changes. Cobbler internal use only.

clear_logs(system: System) None[source]

Clears console and anamon logs for system

Parameters:

system – The system to clear logs of.

copy_distro(ref: Distro, newname: str) None[source]

This method copies a distro which is just different in the name of the object.

Parameters:
  • ref – The object itself which gets copied.

  • newname – The new name of the newly created object.

copy_distro_group(ref: DistroGroup, newname: str) None[source]

This method copies a distro group which is just different in the name of the object.

Parameters:
  • ref – The object itself which gets copied.

  • newname – The new name of the newly created object.

copy_image(ref: Image, newname: str) None[source]

This method copies an image which is just different in the name of the object.

Parameters:
  • ref – The object itself which gets copied.

  • newname – The new name of the newly created object.

copy_item(what: str, ref: BaseItem, newname: str) None[source]

General copy method which is called by the specific methods.

Parameters:
  • what – The collection type which gets copied.

  • ref – The object itself which gets copied.

  • newname – The new name of the newly created object.

copy_menu(ref: Menu, newname: str) None[source]

This method copies a file which is just different in the name of the object.

Parameters:
  • ref – The object itself which gets copied.

  • newname – The new name of the newly created object.

copy_network_interface(ref: NetworkInterface, newname: str) None[source]

This method copies a network interface which is just different in the name of the object.

Parameters:
  • ref – The object itself which gets copied.

  • newname – The new name of the newly created object.

copy_profile(ref: Profile, newname: str) None[source]

This method copies a profile which is just different in the name of the object.

Parameters:
  • ref – The object itself which gets copied.

  • newname – The new name of the newly created object.

copy_profile_group(ref: ProfileGroup, newname: str) None[source]

This method copies a profile group which is just different in the name of the object.

Parameters:
  • ref – The object itself which gets copied.

  • newname – The new name of the newly created object.

copy_repo(ref: Repo, newname: str) None[source]

This method copies a repository which is just different in the name of the object.

Parameters:
  • ref – The object itself which gets copied.

  • newname – The new name of the newly created object.

copy_system(ref: System, newname: str) None[source]

This method copies a system which is just different in the name of the object.

Parameters:
  • ref – The object itself which gets copied.

  • newname – The new name of the newly created object.

copy_system_group(ref: SystemGroup, newname: str) None[source]

This method copies a system group which is just different in the name of the object.

Parameters:
  • ref – The object itself which gets copied.

  • newname – The new name of the newly created object.

copy_template(ref: Template, newname: str) None[source]

This method copies a template which is just different in the name of the object.

Parameters:
  • ref – The object itself which gets copied.

  • newname – The new name of the newly created object.

deserialize() None[source]

Load cobbler_collections from disk. Cobbler internal use only.

deserialize_item(obj: BaseItem) Dict[str, Any][source]

Load cobbler item from disk. Cobbler internal use only.

distro_groups() DistroGroups[source]

Return the current list of distro groups

distros() Distros[source]

Return the current list of distributions

dump_vars(obj: BootableItem, formatted_output: bool = False, remove_dicts: bool = False) Dict[str, Any] | str[source]

Dump all known variables related to that object.

Parameters:
  • obj – The object for which the variables should be dumped.

  • formatted_output – If True the values will align in one column and be pretty printed for cli example.

  • remove_dicts – If True the dictionaries will be put into str form.

Returns:

A dictionary with all the information which could be collected.

find_distro(return_list: bool = False, no_errors: bool = False, **kwargs: FIND_KWARGS) List[distro.Distro] | distro.Distro | None[source]

Find a distribution via a name or keys specified in the **kwargs.

Parameters:
  • return_list – If only the first result or all results should be returned.

  • no_errors – Silence some errors which would raise if this turned to False.

  • kwargs – Key-value pairs which help in finding the desired objects.

Returns:

A single object or a list of all search results.

find_distro_group(return_list: bool = False, no_errors: bool = False, **kwargs: FIND_KWARGS) List[distro_group.DistroGroup] | distro_group.DistroGroup | None[source]

Find a distro group via a name or keys specified in the **kwargs.

Parameters:
  • return_list – If only the first result or all results should be returned.

  • no_errors – Silence some errors which would raise if this turned to False.

  • kwargs – Key-value pairs which help in finding the desired objects.

Returns:

A single object or a list of all search results.

find_image(return_list: bool = False, no_errors: bool = False, **kwargs: FIND_KWARGS) List[image_module.Image] | image_module.Image | None[source]

Find an image via a name or keys specified in the **kwargs.

Parameters:
  • name – The name to search for.

  • return_list – If only the first result or all results should be returned.

  • no_errors – Silence some errors which would raise if this turned to False.

  • kwargs – Key-value pairs which help in finding the desired objects.

Returns:

A single object or a list of all search results.

find_items(what: str = '', criteria: Dict[Any, Any] | None = None, return_list: bool = True, no_errors: bool = False) BootableItem | List[BootableItem] | None[source]

This is the abstract base method for finding object int the api. It should not be used by external resources. Please refer to the specific implementations of this method called find_<object type>.

Parameters:
  • what – The object type of the item to search for.

  • criteria – The dictionary with the key-value pairs to find objects with.

  • return_list – If only the first result or all results should be returned.

  • no_errors – Silence some errors which would raise if this turned to False.

Returns:

The list of items witch match the search criteria.

find_menu(return_list: bool = False, no_errors: bool = False, **kwargs: FIND_KWARGS) List[menu.Menu] | menu.Menu | None[source]

Find a menu via a name or keys specified in the **kwargs.

Parameters:
  • return_list – If only the first result or all results should be returned.

  • no_errors – Silence some errors which would raise if this turned to False.

  • kwargs – Key-value pairs which help in finding the desired objects.

Returns:

A single object or a list of all search results.

find_network_interface(return_list: bool = False, no_errors: bool = False, **kwargs: FIND_KWARGS) List[network_interface.NetworkInterface] | network_interface.NetworkInterface | None[source]

Find a network interface via a name or keys specified in the **kwargs.

Parameters:
  • return_list – If only the first result or all results should be returned.

  • no_errors – Silence some errors which would raise if this turned to False.

  • kwargs – Additional key-value pairs which may help in finding the desired objects.

Returns:

A single object or a list of all search results.

find_profile(return_list: bool = False, no_errors: bool = False, **kwargs: FIND_KWARGS) List[profile_module.Profile] | profile_module.Profile | None[source]

Find a profile via a name or keys specified in the **kwargs.

Parameters:
  • return_list – If only the first result or all results should be returned.

  • no_errors – Silence some errors which would raise if this turned to False.

  • kwargs – Key-value pairs which help in finding the desired objects.

Returns:

A single object or a list of all search results.

find_profile_group(return_list: bool = False, no_errors: bool = False, **kwargs: FIND_KWARGS) List[profile_group.ProfileGroup] | profile_group.ProfileGroup | None[source]

Find a profile group via a name or keys specified in the **kwargs.

Parameters:
  • return_list – If only the first result or all results should be returned.

  • no_errors – Silence some errors which would raise if this turned to False.

  • kwargs – Key-value pairs which help in finding the desired objects.

Returns:

A single object or a list of all search results.

find_repo(return_list: bool = False, no_errors: bool = False, **kwargs: FIND_KWARGS) List[repo.Repo] | repo.Repo | None[source]

Find a repository via a name or keys specified in the **kwargs.

Parameters:
  • return_list – If only the first result or all results should be returned.

  • no_errors – Silence some errors which would raise if this turned to False.

  • kwargs – Key-value pairs which help in finding the desired objects.

Returns:

A single object or a list of all search results.

find_system(return_list: bool = False, no_errors: bool = False, **kwargs: FIND_KWARGS) List[system_module.System] | system_module.System | None[source]

Find a system via a name or keys specified in the **kwargs.

Parameters:
  • return_list – If only the first result or all results should be returned.

  • no_errors – Silence some errors which would raise if this turned to False.

  • kwargs – Key-value pairs which help in finding the desired objects.

Returns:

A single object or a list of all search results.

find_system_group(return_list: bool = False, no_errors: bool = False, **kwargs: FIND_KWARGS) List[system_group.SystemGroup] | system_group.SystemGroup | None[source]

Find a system group via a name or keys specified in the **kwargs.

Parameters:
  • return_list – If only the first result or all results should be returned.

  • no_errors – Silence some errors which would raise if this turned to False.

  • kwargs – Key-value pairs which help in finding the desired objects.

Returns:

A single object or a list of all search results.

find_template(return_list: bool = False, no_errors: bool = False, **kwargs: FIND_KWARGS) List[template.Template] | template.Template | None[source]

Find a network interface via a name or keys specified in the **kwargs.

Parameters:
  • return_list – If only the first result or all results should be returned.

  • no_errors – Silence some errors which would raise if this turned to False.

  • kwargs – Additional key-value pairs which may help in finding the desired objects.

Returns:

A single object or a list of all search results.

generate_autoinstall(obj: BootableItem, autoinstall_template: Template, autoinstaller_subfile: str = '') str[source]

Generate the auto-installation file and return it.

Parameters:
  • obj – The profile to generate the file for.

  • autoinstall_template – TODO

  • autoinstaller_subfile – TODO

Returns:

The str representation of the file.

generate_bootcfg(profile: str = '', system: str = '') str[source]

Generate a boot configuration. The system wins over the profile.

Parameters:
  • profile – The profile to return the configuration for.

  • system – The system to return the configuration for.

Returns:

The generated configuration file.

generate_ipxe(profile: str, image: str, system: str) str[source]

Generate the ipxe configuration files. The system wins over the profile. Profile and System win over Image.

Parameters:
  • profile – The profile to return the configuration for.

  • image – The image to return the configuration for.

  • system – The system to return the configuration for.

Returns:

The generated configuration file.

generate_pxe_file(filename: str | None, system: System, profile: Profile, distro: Distro, arch: Archs, image: Image | None = None, metadata: Dict[str, Any] | None = None, bootloader_format: BootLoader = BootLoader.PXE)[source]

See also

write_pxe_file()

generate_script(profile: str | None, system: str | None, name: str) str[source]

Generate an autoinstall script for the specified profile or system. The system wins over the profile.

Parameters:
  • profile – The profile name to generate the script for.

  • system – The system name to generate the script for.

  • name – The name of the script which should be generated. Must only contain alphanumeric characters, dots and underscores.

Returns:

The generated script or an error message.

get_config_data(hostname: str) str[source]

Encodes configuration data for Koan as a JSON.

Parameters:

hostname – The hostname ot encode the configuration data for.

Returns:

A string with JSON data.

get_distro_groups_since(mtime: float, collapse: bool = False) List[DistroGroup][source]

Return distro groups modified since a certain time (in seconds since Epoch)

Parameters:
  • mtime – The timestamp which marks the gate if an object is included or not.

  • collapse – If True then this specifies that a list of dicts should be returned instead of a list of objects.

Returns:

The list of distro groups which are newer then the given timestamp.

get_distros_since(mtime: float, collapse: bool = False) List[Distro][source]

Returns distros modified since a certain time (in seconds since Epoch)

Parameters:
  • mtime – The timestamp which marks the gate if an object is included or not.

  • collapse – collapse=True specifies returning a dict instead of objects.

Returns:

The list of distros which are newer then the given timestamp.

get_images_since(mtime: float, collapse: bool = False) List[Image][source]

Return images modified since a certain time (in seconds since Epoch)

Parameters:
  • mtime – The timestamp which marks the gate if an object is included or not.

  • collapse – If True then this specifies that a list of dicts should be returned instead of a list of objects.

Returns:

The list of images which are newer then the given timestamp.

get_item(what: str, name: str) BootableItem | None[source]

Get a general item.

Parameters:
  • what – The item type to retrieve from the internal database.

  • name – The name of the item to retrieve.

Returns:

An item of the desired type.

get_item_resolved_value(item_uuid: str, attribute_path: List[str]) Any[source]

This method helps non Python API consumers to retrieve the final data of a field with inheritance.

This does not help with network interfaces because they don’t have a UUID at the moment and thus can’t be queried via their UUID.

Parameters:
  • item_uuid – The UUID of the item that should be retrieved.

  • attribute_path – The attribute that should be retrieved.

Raises:
  • ValueError – In case a value given was either malformed or the desired item did not exist.

  • TypeError – In case the type of the method arguments do have the wrong type.

  • AttributeError – In case the attribute specified is not available on the given item (type).

Returns:

The attribute value. Since this might be of type NetworkInterface we cannot yet set this explicitly.

get_items(what: str) Collection[BaseItem][source]

Get all items of a collection.

Parameters:

what – The collection to query.

Returns:

The items which were queried. May return no items.

get_menus_since(mtime: float, collapse: bool = False) List[Menu][source]

Return files modified since a certain time (in seconds since Epoch)

Parameters:
  • mtime – The timestamp which marks the gate if an object is included or not.

  • collapse – If True then this specifies that a list of dicts should be returned instead of a list of objects.

Returns:

The list of files which are newer then the given timestamp.

get_module_by_name(module_name: str) ModuleType | None[source]

Returns a loaded Cobbler module named ‘name’, if one exists, else None. Cobbler internal use only.

Parameters:

module_name

Returns:

get_module_from_file(section: str, name: str, fallback: str | None = None) ModuleType[source]

Looks in /etc/cobbler/settings.yaml for a section called ‘section’ and a key called ‘name’, and then returns the module that corresponds to the value of that key. Cobbler internal use only.

Parameters:
  • section – The section to look at.

  • name – The name of the module to retrieve

  • fallback – The default module in case the requested one is not found.

Returns:

The requested Python Module.

get_module_name_from_file(section: str, name: str, fallback: str | None = None) str[source]

Looks up a module the same as get_module_from_file but returns the module name rather than the module itself.

Parameters:
  • section

  • name

  • fallback

Returns:

get_modules_in_category(category: str) List[ModuleType][source]

Returns all modules in a given category, for instance “serializer”, or “cli”. Cobbler internal use only.

Parameters:

category – The category to check.

Returns:

The list of modules.

get_network_interfaces_since(mtime: float, collapse: bool = False) List[NetworkInterface][source]

Return network interfaces modified since a certain time (in seconds since Epoch)

Parameters:
  • mtime – The timestamp which marks the gate if an object is included or not.

  • collapse – If True then this specifies that a list of dicts should be returned instead of a list of objects.

Returns:

The list of files which are newer then the given timestamp.

get_profile_groups_since(mtime: float, collapse: bool = False) List[ProfileGroup][source]

Return profile groups modified since a certain time (in seconds since Epoch)

Parameters:
  • mtime – The timestamp which marks the gate if an object is included or not.

  • collapse – If True then this specifies that a list of dicts should be returned instead of a list of objects.

Returns:

The list of profile groups which are newer then the given timestamp.

get_profiles_since(mtime: float, collapse: bool = False) List[Profile][source]

Returns profiles modified since a certain time (in seconds since Epoch)

Parameters:
  • mtime – The timestamp which marks the gate if an object is included or not.

  • collapse – If True then this specifies that a list of dicts should be returned instead of a list of objects.

Returns:

The list of profiles which are newer then the given timestamp.

get_repo_config_for_profile(obj: BaseItem) str[source]

Get the repository configuration for the specified profile

Parameters:

obj – The profile to return the configuration for.

Returns:

The repository configuration as a string.

get_repo_config_for_system(obj: BaseItem) str[source]

Get the repository configuration for the specified system.

Parameters:

obj – The system to return the configuration for.

Returns:

The repository configuration as a string.

get_repos_since(mtime: float, collapse: bool = False) List[Repo][source]

Return repositories modified since a certain time (in seconds since Epoch)

Parameters:
  • mtime – The timestamp which marks the gate if an object is included or not.

  • collapse – If True then this specifies that a list of dicts should be returned instead of a list of objects.

Returns:

The list of repositories which are newer then the given timestamp.

static get_signatures() Dict[str, Any][source]

This returns the local signature cache.

Returns:

The dict containing all signatures.

get_sync(verbose: bool = False) CobblerSync[source]

Get a Cobbler Sync object which may be executed through the call of obj.run().

Parameters:

verbose – If the action should be just logged as needed or (if True) as much verbose as possible.

Returns:

An instance of the CobblerSync class to execute the sync with.

get_system_groups_since(mtime: float, collapse: bool = False) List[SystemGroup][source]

Return system groups modified since a certain time (in seconds since Epoch)

Parameters:
  • mtime – The timestamp which marks the gate if an object is included or not.

  • collapse – If True then this specifies that a list of dicts should be returned instead of a list of objects.

Returns:

The list of system groups which are newer then the given timestamp.

get_systems_since(mtime: float, collapse: bool = False) List[System][source]

Return systems modified since a certain time (in seconds since Epoch)

Parameters:
  • mtime – The timestamp which marks the gate if an object is included or not.

  • collapse – If True then this specifies that a list of dicts should be returned instead of a list of objects.

Returns:

The list of systems which are newer then the given timestamp.

get_template_file_for_profile(obj: BootableItem, path: str) str[source]

Get the template for the specified profile.

Parameters:
  • obj – The object which is related to that template.

  • path – The path to the template.

Returns:

The template as in its string representation.

get_template_file_for_system(obj: BootableItem, path: str) str[source]

Get the template for the specified system.

Parameters:
  • obj – The object which is related to that template.

  • path – The path to the template.

Returns:

The template as in its string representation.

get_templates_since(mtime: float, collapse: bool = False) List[Template][source]

Return templates modified since a certain time (in seconds since Epoch)

Parameters:
  • mtime – The timestamp which marks the gate if an object is included or not.

  • collapse – If True then this specifies that a list of dicts should be returned instead of a list of objects.

Returns:

The list of files which are newer then the given timestamp.

get_tftp_file(path: str, offset: int, size: int) Tuple[bytes, int][source]

Generate and return a file for a TFTP client.

Parameters:
  • path – Path to file

  • offset – Offset of the requested chunk in the file

  • size – Size of the requested chunk in the file

Returns:

The requested chunk and the length of the whole file

get_valid_obj_boot_loaders(obj: Distro | Image) List[BootLoader][source]

Return the list of valid bootloaders for the object

Parameters:

obj – The object for which the bootloaders should be looked up.

Returns:

Get a list of all valid bootloaders.

Hardlink all files where this is possible to improve performance.

Returns:

The return code of the subprocess call which actually hardlinks the files.

images() Images[source]

Return the current list of images

import_tree(mirror_url: str, mirror_name: str, network_root: str | None = None, autoinstall_file: str | None = None, rsync_flags: str | None = None, arch: str | None = None, breed: str | None = None, os_version: str | None = None) bool[source]

Automatically import a directory tree full of distribution files.

Parameters:
  • mirror_url – Can be a string that represents a path, a user@host syntax for SSH, or an rsync:// address. If mirror_url is a filesystem path and mirroring is not desired, set network_root to something like “nfs://path/to/mirror_url/root”

  • mirror_name – The name of the mirror.

  • network_root – the remote path (nfs/http/ftp) for the distro files

  • autoinstall_file – user-specified response file, which will override the default

  • rsync_flags – Additional flags that will be passed to the rsync call that will sync everything to the Cobbler webroot.

  • arch – user-specified architecture

  • breed – user-specified breed

  • os_version – user-specified OS version

static input_boolean(value: str | bool | int) bool[source]

See also

input_boolean()

static input_int(value: str | int | float) int[source]

See also

input_int()

static input_string_or_dict(options: str | List[Any] | Dict[Any, Any], allow_multiples: bool = True) str | Dict[Any, Any][source]
static input_string_or_dict_no_inherit(options: str | List[Any] | Dict[Any, Any], allow_multiples: bool = True) Dict[Any, Any][source]
input_string_or_list(options: str | List[Any] | None) List[Any] | str[source]
input_string_or_list_no_inherit(options: str | List[Any] | None) List[Any][source]
is_autoinstall_in_use(autoinstall: str)[source]

Check if the auto-installation template is referenced by at least one Profile or System.

Parameters:

ai – The name of the template.

Returns:

True if this is the case, otherwise False.

is_selinux_enabled() bool[source]

Returns whether selinux is enabled on the Cobbler server. We check this just once at Cobbler API init time, because a restart is required to change this; this does /not/ check enforce/permissive, nor does it need to.

is_selinux_supported() bool[source]

Returns whether or not the OS is sufficient enough to run with SELinux enabled (currently EL 5 or later).

Returns:

False per default. If Distro is Redhat and Version >= 5 then it returns true.

last_modified_time() float[source]

Returns the time of the last modification to Cobbler, made by any API instance, regardless of the serializer type.

Returns:

0 if there is no file where the information required for this method is saved.

log(msg: str, args: str | List[str | None] | Dict[str, Any] | None = None, debug: bool = False) None[source]

Logs a message with the already initiated logger of this object.

Parameters:
  • msg – The message to log.

  • args – Optional message which gets appended to the main msg with a ‘;’.

  • debug – Weather the logged message is a debug message (true) or info (false).

Deprecated since version 3.3.0: We should use the standard logger.

menus() Menus[source]

Return the current list of menus

mkloaders() None[source]

Create the GRUB installer images via this API call. It utilizes grub2-mkimage behind the curtain.

network_interfaces() NetworkInterfaces[source]

Return the current list of network interfaces

new_distro(is_subobject: bool = False, **kwargs: Any) Distro[source]

Returns a new empty distro object. This distro is not automatically persisted. Persistance is achieved via save().

Parameters:

is_subobject – If the object is a subobject of an already existing object or not.

Returns:

An empty Distro object.

new_distro_group(is_subobject: bool = False, **kwargs: Any) DistroGroup[source]

Returns a new empty distro group object. This distro group is not automatically persisted. Persistence is achieved via save().

Parameters:

is_subobject – If the object is a subobject of an already existing object or not.

Returns:

An empty DistroGroup object.

new_image(is_subobject: bool = False, **kwargs: Any) Image[source]

Returns a new empty image object. This image is not automatically persisted. Persistence is achieved via save().

Parameters:

is_subobject – If the object created is a subobject or not.

Returns:

An empty image object.

new_item(what: str = '', is_subobject: bool = False, **kwargs: Any) BootableItem[source]

Creates a new (unconfigured) object. The object is not persisted.

Parameters:
  • what – Specifies the type of object. Valid item types can be seen at ItemTypes().

  • is_subobject – If the object is a subobject of an already existing object or not.

Returns:

The newly created object.

new_menu(is_subobject: bool = False, **kwargs: Any) Menu[source]

Returns a new empty menu object. This file is not automatically persisted. Persistence is achieved via save().

Parameters:

is_subobject – If the object created is a subobject or not.

Returns:

An empty Menu object.

new_network_interface(**kwargs: Any) NetworkInterface[source]

Returns a new empty network interface object. This file is not automatically persisted. Persistence is achieved via save().

Returns:

An empty Network Interface object.

new_profile(is_subobject: bool = False, **kwargs: Any) Profile[source]

Returns a new empty profile object. This profile is not automatically persisted. Persistence is achieved via save().

Parameters:

is_subobject – If the object created is a subobject or not.

Returns:

An empty Profile object.

new_profile_group(is_subobject: bool = False, **kwargs: Any) ProfileGroup[source]

Returns a new empty profile group object. This profile group is not automatically persisted. Persistence is achieved via save().

Parameters:

is_subobject – If the object is a subobject of an already existing object or not.

Returns:

An empty ProfileGroup object.

new_repo(is_subobject: bool = False, **kwargs: Any) Repo[source]

Returns a new empty repo object. This repository is not automatically persisted. Persistence is achieved via save().

Parameters:

is_subobject – If the object created is a subobject or not.

Returns:

An empty repo object.

new_system(is_subobject: bool = False, **kwargs: Any) System[source]

Returns a new empty system object. This system is not automatically persisted. Persistence is achieved via save().

Parameters:

is_subobject – If the object created is a subobject or not.

Returns:

An empty System object.

new_system_group(is_subobject: bool = False, **kwargs: Any) SystemGroup[source]

Returns a new empty system group object. This system group is not automatically persisted. Persistence is achieved via save().

Parameters:

is_subobject – If the object is a subobject of an already existing object or not.

Returns:

An empty SystemGroup object.

new_template(**kwargs: Any) Template[source]

Returns a new empty template object. This file is not automatically persisted. Persistence is achieved via save().

Returns:

An empty Template object.

power_system(system: System, power_operation: str, user: str | None = None, password: str | None = None) bool | None[source]

Power on / power off / get power status /reboot a system.

Parameters:
  • system – Cobbler system

  • power_operation – power operation. Valid values: on, off, reboot, status

  • user – power management user

  • password – power management password

Returns:

bool if operation was successful

profile_groups() ProfileGroups[source]

Return the current list of profile groups

profiles() Profiles[source]

Return the current list of profiles

remove_distro(ref: Distro | str, recursive: bool = False, delete: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Remove a distribution from Cobbler.

Parameters:
  • ref – The internal unique handle for the item.

  • recursive – If the item should recursively should delete dependencies on itself.

  • delete – Additional condition that controls if with_triggers and with_sync should be executed.

  • with_triggers – Whether you would like to have the removal triggers executed or not.

  • with_sync – In case a Cobbler Sync should be executed after the action.

remove_distro_group(ref: DistroGroup | str, recursive: bool = False, delete: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Remove a distro group from Cobbler.

Parameters:
  • ref – The internal unique handle for the item.

  • recursive – If the item should recursively should delete dependencies on itself.

  • delete – Additional condition that controls if with_triggers and with_sync should be executed.

  • with_triggers – Whether you would like to have the removal triggers executed or not.

  • with_sync – In case a Cobbler Sync should be executed after the action.

remove_image(ref: Image | str, recursive: bool = False, delete: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Remove a image from Cobbler.

Parameters:
  • ref – The internal unique handle for the item.

  • recursive – If the item should recursively should delete dependencies on itself.

  • delete – Additional condition that controls if with_triggers and with_sync should be executed.

  • with_triggers – Whether you would like to have the removal triggers executed or not.

  • with_sync – In case a Cobbler Sync should be executed after the action.

remove_item(what: str, ref: BaseItem | str, recursive: bool = False, delete: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Remove a general item. This method should not be used by an external api. Please use the specific remove_<itemtype> methods.

Parameters:
  • what – The type of the item.

  • ref – The internal unique handle for the item.

  • recursive – If the item should recursively should delete dependencies on itself.

  • delete – Additional condition that controls if with_triggers and with_sync should be executed.

  • with_triggers – Whether you would like to have the removal triggers executed or not.

  • with_sync – In case a Cobbler Sync should be executed after the action.

remove_menu(ref: Menu | str, recursive: bool = False, delete: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Remove a menu from Cobbler.

Parameters:
  • ref – The internal unique handle for the item.

  • recursive – If the item should recursively should delete dependencies on itself.

  • delete – Additional condition that controls if with_triggers and with_sync should be executed.

  • with_triggers – Whether you would like to have the removal triggers executed or not.

  • with_sync – In case a Cobbler Sync should be executed after the action.

remove_network_interface(ref: NetworkInterface | str, recursive: bool = False, delete: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Remove a network interface from Cobbler.

Parameters:
  • ref – The internal unique handle for the item.

  • recursive – If the item should recursively should delete dependencies on itself.

  • delete – Additional condition that controls if with_triggers and with_sync should be executed.

  • with_triggers – Whether you would like to have the removal triggers executed or not.

  • with_sync – In case a Cobbler Sync should be executed after the action.

remove_profile(ref: Profile | str, recursive: bool = False, delete: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Remove a profile from Cobbler.

Parameters:
  • ref – The internal unique handle for the item.

  • recursive – If the item should recursively should delete dependencies on itself.

  • delete – Additional condition that controls if with_triggers and with_sync should be executed.

  • with_triggers – Whether you would like to have the removal triggers executed or not.

  • with_sync – In case a Cobbler Sync should be executed after the action.

remove_profile_group(ref: ProfileGroup | str, recursive: bool = False, delete: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Remove a profile group from Cobbler.

Parameters:
  • ref – The internal unique handle for the item.

  • recursive – If the item should recursively should delete dependencies on itself.

  • delete – Additional condition that controls if with_triggers and with_sync should be executed.

  • with_triggers – Whether you would like to have the removal triggers executed or not.

  • with_sync – In case a Cobbler Sync should be executed after the action.

remove_repo(ref: Repo | str, recursive: bool = False, delete: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Remove a repository from Cobbler.

Parameters:
  • ref – The internal unique handle for the item.

  • recursive – If the item should recursively should delete dependencies on itself.

  • delete – Additional condition that controls if with_triggers and with_sync should be executed.

  • with_triggers – Whether you would like to have the removal triggers executed or not.

  • with_sync – In case a Cobbler Sync should be executed after the action.

remove_system(ref: System | str, recursive: bool = False, delete: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Remove a system from Cobbler.

Parameters:
  • ref – The internal unique handle for the item.

  • recursive – If the item should recursively should delete dependencies on itself.

  • delete – Additional condition that controls if with_triggers and with_sync should be executed.

  • with_triggers – Whether you would like to have the removal triggers executed or not.

  • with_sync – In case a Cobbler Sync should be executed after the action.

remove_system_group(ref: SystemGroup | str, recursive: bool = False, delete: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Remove a system group from Cobbler.

Parameters:
  • ref – The internal unique handle for the item.

  • recursive – If the item should recursively should delete dependencies on itself.

  • delete – Additional condition that controls if with_triggers and with_sync should be executed.

  • with_triggers – Whether you would like to have the removal triggers executed or not.

  • with_sync – In case a Cobbler Sync should be executed after the action.

remove_template(ref: Template | str, recursive: bool = False, delete: bool = True, with_triggers: bool = True, with_sync: bool = True) None[source]

Remove a template from Cobbler.

Parameters:
  • ref – The internal unique handle for the item.

  • recursive – If the item should recursively should delete dependencies on itself.

  • delete – Additional condition that controls if with_triggers and with_sync should be executed.

  • with_triggers – Whether you would like to have the removal triggers executed or not.

  • with_sync – In case a Cobbler Sync should be executed after the action.

rename_distro(ref: Distro, newname: str) None[source]

Rename a distro to a new name.

Parameters:
  • ref – The internal unique handle for the item.

  • newname – The new name for the item.

rename_distro_group(ref: DistroGroup, newname: str) None[source]

Rename a distro group to a new name.

Parameters:
  • ref – The internal unique handle for the item.

  • newname – The new name for the item.

rename_image(ref: Image, newname: str) None[source]

Rename an image to a new name.

Parameters:
  • ref – The internal unique handle for the item.

  • newname – The new name for the item.

rename_item(what: str, ref: BaseItem, newname: str) None[source]

Remove a general item. This method should not be used by an external api. Please use the specific rename_<itemtype> methods.

Parameters:
  • what – The type of object which should be renamed.

  • ref – The internal unique handle for the item.

  • newname – The new name for the item.

rename_menu(ref: Menu, newname: str) None[source]

Rename a menu to a new name.

Parameters:
  • ref – The internal unique handle for the item.

  • newname – The new name for the item.

rename_network_interface(ref: NetworkInterface, newname: str) None[source]

Rename a network interface to a new name.

Parameters:
  • ref – The internal unique handle for the item.

  • newname – The new name for the item.

rename_profile(ref: Profile, newname: str) None[source]

Rename a profile to a new name.

Parameters:
  • ref – The internal unique handle for the item.

  • newname – The new name for the item.

rename_profile_group(ref: ProfileGroup, newname: str) None[source]

Rename a profile group to a new name.

Parameters:
  • ref – The internal unique handle for the item.

  • newname – The new name for the item.

rename_repo(ref: Repo, newname: str) None[source]

Rename a repository to a new name.

Parameters:
  • ref – The internal unique handle for the item.

  • newname – The new name for the item.

rename_system(ref: System, newname: str) None[source]

Rename a system to a new name.

Parameters:
  • ref – The internal unique handle for the item.

  • newname – The new name for the item.

rename_system_group(ref: SystemGroup, newname: str) None[source]

Rename a system group to a new name.

Parameters:
  • ref – The internal unique handle for the item.

  • newname – The new name for the item.

rename_template(ref: Template, newname: str) None[source]

Rename a template to a new name.

Parameters:
  • ref – The internal unique handle for the item.

  • newname – The new name for the item.

replicate(cobbler_master: str | None = None, port: str = '80', distro_patterns: str = '', profile_patterns: str = '', system_patterns: str = '', repo_patterns: str = '', image_patterns: str = '', prune: bool = False, omit_data: bool = False, sync_all: bool = False, use_ssl: bool = False) None[source]

Pull down data/configs from a remote Cobbler server that is a master to this server.

Parameters:
  • cobbler_master – The hostname/URL of the other Cobbler server

  • port – The port to use for the replication task.

  • distro_patterns – The pattern of distros which should be synced.

  • profile_patterns – The pattern of profiles which should be synced.

  • system_patterns – The pattern of systems which should be synced.

  • repo_patterns – The pattern of repositories which should be synced.

  • image_patterns – The pattern of images which should be synced.

  • prune – Whether the object not on the master should be removed or not.

  • omit_data – If the data downloaded by the current Cobbler server should be rsynced to the destination server.

  • sync_all – This parameter behaves similarly to a dry run argument. If True then everything will executed, if False then only some things are synced.

  • use_ssl – Whether SSL should be used (True) or not (False).

repos() Repos[source]

Return the current list of repos

reposync(name: str | None = None, tries: int = 1, nofail: bool = False) None[source]

Take the contents of /var/lib/cobbler/repos and update them – or create the initial copy if no contents exist yet.

Parameters:
  • name – The name of the repository to run reposync for.

  • tries – How many tries should be executed before the action fails.

  • nofail – If True then the action will fail, otherwise the action will just be skipped. This respects the tries parameter.

serialize() None[source]

Save the cobbler_collections to disk. Cobbler internal use only.

set_item_resolved_value(item_uuid: str, attribute_path: List[str], value: Any) None[source]

This method helps non Python API consumers to use the Python property setters without having access to the raw data of the object. In case you pass a dictionary the method tries to deduplicate it.

This does not help with network interfaces because they don’t have a UUID at the moment and thus can’t be queried via their UUID.

Warning

This function may throw any exception that is thrown by a setter of a Python property defined in Cobbler.

Parameters:
  • item_uuid – The UUID of the item that should be retrieved.

  • attribute_path – The attribute that should be retrieved.

  • value – The new value to set.

Raises:
  • ValueError – In case a value given was either malformed or the desired item did not exist.

  • TypeError – In case the type of the method arguments do have the wrong type.

  • AttributeError – In case the attribute specified is not available on the given item (type).

settings() Settings[source]

Return the application configuration

signature_reload() None[source]

Reload all signatures from disk.

signature_update() None[source]

Update all signatures from the URL specified in the settings.

status(mode: str) Dict[Any, Any] | str[source]

Get the status of the current Cobbler instance.

Parameters:

mode – “text” or anything else. Meaning whether the output is thought for the terminal or not.

Returns:

The current status of Cobbler.

sync(verbose: bool = False, what: List[str] | None = None) None[source]

Take the values currently written to the configuration files in /etc, and /var, and build out the information tree found in /tftpboot. Any operations done in the API that have not been saved with serialize() will NOT be synchronized with this command.

Parameters:
  • verbose – If the action should be just logged as needed or (if True) as much verbose as possible.

  • what – List of strings what services to sync (e.g. dhcp and/or dns). Empty list for full sync.

sync_dhcp() None[source]

Only build out the DHCP configuration.

sync_dns() None[source]

Only build out the DNS configuration.

sync_systems(systems: List[str], verbose: bool = False) None[source]

Take the values currently written to the configuration files in /etc, and /var, and build out the information tree found in /tftpboot. Any operations done in the API that have not been saved with serialize() will NOT be synchronized with this command.

Parameters:
  • systems – List of specified systems that needs to be synced

  • verbose – If the action should be just logged as needed or (if True) as much verbose as possible.

system_groups() SystemGroups[source]

Return the current list of system groups

systems() Systems[source]

Return the current list of systems

templates() Templates[source]

Return the current list of templates

templates_refresh_content(objects: List[Template] | None = None) None[source]

Method to refresh the in-memory content of zero or more templates inside Cobbler.

Parameters:

objects – With the default value None, all templates are refreshed. Otherwhise each template inside the list is refreshed. An empty list refreshes no templates.

version(extended: bool = False) float | Dict[str, str | List[Any]][source]

What version is Cobbler?

If extended == False, returns a float for backwards compatibility If extended == True, returns a dict:

gitstamp – the last git commit hash gitdate – the last git commit date on the builder machine builddate – the time of the build version – something like “1.3.2” version_tuple – something like [ 1, 3, 2 ]

Parameters:

extended – False returns a float, True a Dictionary.

7.4. cobbler.cexceptions module

Custom exceptions for Cobbler

exception cobbler.cexceptions.CX(value: Any, *args: Iterable[str])[source]

Bases: CobblerException

This is a general exception which gets thrown often inside Cobbler.

exception cobbler.cexceptions.CobblerException(value: Any, *args: Iterable[str])[source]

Bases: Exception

This is the default Cobbler exception where all other exceptions are inheriting from.

7.5. cobbler.configgen module

configgen.py: Generate configuration data.

module for generating configuration manifest using autoinstall_meta data and templates for a given system (hostname)

class cobbler.configgen.ConfigGen(cobbler_api: CobblerAPI, hostname: str)[source]

Bases: object

Generate configuration data for Cobbler’s management resource “repos”. Mainly used by Koan to configure systems.

gen_config_data() Dict[Any, Any][source]

Generate configuration data for repos.

Returns:

A dict which has all config data in it.

gen_config_data_for_koan() str[source]

Encode configuration data. Return json object for Koan.

Returns:

A json string for koan.

get_cobbler_resource(resource_key: str) List[Any] | str | Dict[Any, Any][source]

Wrapper around Cobbler blender method

Parameters:

resource_key – Not known what this actually is doing.

Returns:

The blendered data. In some cases this is a str, in others it is a list or it might be a dict. In case the key is not found it will return an empty string.

resolve_resource_var(string_data: ResourceAction | str) str[source]

Substitute variables in strings with data from the autoinstall_meta dictionary of the system.

Parameters:

string_data – The template which will then be substituted by the variables in this class.

Returns:

A str with the substituted data. If the host_vars are not of type dict then this will return an empty str.

Raises:

KeyError – When the autoinstall_meta variable does not contain the required Keys in the dict.

7.6. cobbler.decorator module

This module provides decorators that are required for Cobbler to work as expected.

class cobbler.decorator.InheritableDictProperty(fget=None, fset=None, fdel=None, doc=None)[source]

Bases: InheritableProperty

This property is supposed to provide a way to identify properties in code that can be set to inherit.

class cobbler.decorator.InheritableProperty(fget=None, fset=None, fdel=None, doc=None)[source]

Bases: LazyProperty

This property is supposed to provide a way to identify properties in code that can be set to inherit.

inheritable = True
class cobbler.decorator.LazyProperty(fget=None, fset=None, fdel=None, doc=None)[source]

Bases: property

This property is supposed to provide a way to override the lazy-read value getter.

7.7. cobbler.download_manager module

Cobbler DownloadManager

class cobbler.download_manager.DownloadManager[source]

Bases: object

Class to provide an easy way to download files from the web inside Cobbler. Mainly present to provide support for system-wide proxies.

urlread(url: str, proxies: Any = None, cert: str | Tuple[str, str] | None = None) Response[source]

Read the content of a given URL and pass the requests. Response object to the caller.

Parameters:
  • url – The URL the request.

  • proxies – Override the default Cobbler proxies.

  • cert – Override the default Cobbler certs.

Returns:

The Python requests.Response object.

7.8. cobbler.enums module

This module is responsible for containing all enums we use in Cobbler. It should not be dependent upon any other module except the Python standard library.

class cobbler.enums.Archs(value)[source]

Bases: ConvertableEnum

This enum describes all system architectures which Cobbler is able to provision.

AARCH64 = 'aarch64'
ARM = 'arm'
I386 = 'i386'
IA64 = 'ia64'
PPC = 'ppc'
PPC64 = 'ppc64'
PPC64EL = 'ppc64el'
PPC64LE = 'ppc64le'
S390 = 's390'
S390X = 's390x'
X86_64 = 'x86_64'
class cobbler.enums.AutoinstallValidationError(value)[source]

Bases: ConvertableEnum

This enum represents the template validation error codes that are well-known to Cobbler.

KICKSTART = 2
NONE = 0
TEMPLATING = 1
class cobbler.enums.AutoinstallerType(value)[source]

Bases: ConvertableEnum

This enum represents the currently allowed types that may request a file with the “autoinstallation” endpoints.

AGAMA = 'agama'
AUTOYAST = 'autoyast'
CLOUDINIT = 'cloud-init'
KICKSTART = 'kickstart'
LEGACY = 'legacy'
PRESEED = 'preseed'
WINDOWS = 'windows'
XEN = 'xen'
class cobbler.enums.BaudRates(value)[source]

Bases: Enum

This enum describes all baud rates which are commonly used.

B0 = 0
B110 = 110
B115200 = 115200
B1200 = 1200
B128000 = 128000
B14400 = 14400
B19200 = 19200
B2400 = 2400
B256000 = 256000
B300 = 300
B38400 = 38400
B4800 = 4800
B57600 = 57600
B600 = 600
B9600 = 9600
DISABLED = -1
class cobbler.enums.BootLoader(value)[source]

Bases: ConvertableEnum

This enum represents all supported boot loaders inside Cobbler.

GRUB = 'grub'
INHERITED = '<<inherit>>'
IPXE = 'ipxe'
PXE = 'pxe'
class cobbler.enums.CloudInitFileTypes(value)[source]

Bases: ConvertableEnum

TODO

META_DATA = 'meta-data'
NETWORK_CONFIG = 'network-config'
USER_DATA = 'user-data'
VENDOR_DATA = 'vendor-data'
class cobbler.enums.ConvertableEnum(value)[source]

Bases: Enum

Abstract class to convert the enum via our convert method.

classmethod to_enum(value: str | CONVERTABLEENUM) CONVERTABLEENUM[source]

This method converts the chosen str to the corresponding enum type.

Parameters:

value – str which contains the to be converted value.

Returns:

The enum value.

Raises:
  • TypeError – In case value was not of type str.

  • ValueError – In case value was not in the range of valid values.

class cobbler.enums.DHCP(value)[source]

Bases: Enum

This enum represents all DHCP versions that Cobbler supports.

V4 = 4
V6 = 6
class cobbler.enums.EventStatus(value)[source]

Bases: ConvertableEnum

This enums describes the status an event can have. The cycle is the following:

“Running” –> “Complete” or “Failed”

COMPLETE = 'complete'

Shows that an event did complete as desired

FAILED = 'failed'

Shows that an event did not complete as expected

INFO = 'notification'

Default Event status

RUNNING = 'running'

Shows that an event is currently being processed by the server

class cobbler.enums.ImageTypes(value)[source]

Bases: ConvertableEnum

This enum represents all image types which Cobbler can manage.

DIRECT = 'direct'
ISO = 'iso'
MEMDISK = 'memdisk'
VIRT_CLONE = 'virt-clone'
class cobbler.enums.ItemTypes(value)[source]

Bases: ConvertableEnum

This enum represents all valid item types in Cobbler. If a new item type is created it must be added into this enum. Abstract base item types don’t have to be added here.

DISTRO = 'distro'

See Distro()

DISTRO_GROUP = 'distro_group'

See DistroGroup()

IMAGE = 'image'

See Image()

MENU = 'menu'

See Menu()

NETWORK_INTERFACE = 'network_interface'

See NetworkInterface()

PROFILE = 'profile'

See Profile()

PROFILE_GROUP = 'profile_group'

See ProfileGroup()

REPO = 'repo'

See Repo()

SYSTEM = 'system'

See System()

SYSTEM_GROUP = 'system_group'

See SystemGroup()

TEMPLATE = 'template'

See Template()

class cobbler.enums.MirrorType(value)[source]

Bases: ConvertableEnum

This enum represents all mirror types which Cobbler can manage.

BASEURL = 'baseurl'
MIRRORLIST = 'mirrorlist'
NONE = 'none'
class cobbler.enums.NetworkInterfaceType(value)[source]

Bases: Enum

This enum represents all interface types Cobbler is able to set up on a target host.

BMC = 'bmc'
BOND = 'bond'
BONDED_BRIDGE_SLAVE = 'bonded_bridge_slave'
BOND_SLAVE = 'bond_slave'
BRIDGE = 'bridge'
BRIDGE_SLAVE = 'bridge_slave'
INFINIBAND = 'infiniband'
NA = 'na'
class cobbler.enums.RepoArchs(value)[source]

Bases: ConvertableEnum

This enum describes all repository architectures Cobbler is able to serve in case the content of the repository is serving the same architecture.

AARCH64 = 'aarch64'
ARM = 'arm'
I386 = 'i386'
IA64 = 'ia64'
NOARCH = 'noarch'
NONE = 'none'
PPC = 'ppc'
PPC64 = 'ppc64'
PPC64EL = 'ppc64el'
PPC64LE = 'ppc64le'
S390 = 's390'
SRC = 'src'
X86_64 = 'x86_64'
class cobbler.enums.RepoBreeds(value)[source]

Bases: ConvertableEnum

This enum describes all repository breeds Cobbler is able to manage.

APT = 'apt'
NONE = 'none'
RHN = 'rhn'
RSYNC = 'rsync'
WGET = 'wget'
YUM = 'yum'
class cobbler.enums.ResourceAction(value)[source]

Bases: ConvertableEnum

This enum represents all actions a resource may execute.

CREATE = 'create'
REMOVE = 'remove'
class cobbler.enums.TemplateSchema(value)[source]

Bases: ConvertableEnum

This enum represents all supported template sources that Cobbler can read.

ENVIRONMENT = 'environment'
FILE = 'file'
IMPORTLIB = 'importlib'
class cobbler.enums.TemplateTag(value)[source]

Bases: ConvertableEnum

This enum represents all the well-known tags that represent special templates that are needed so Cobbler can manage the target daemons.

ACTIVE = 'active'
BOOTCFG = 'bootcfg'
DEFAULT = 'default'
DHCPV4 = 'dhcpv4'
DHCPV6 = 'dhcpv6'
DNSMASQ = 'dnsmasq'
GENDERS = 'genders'
GRUB = 'grub'
GRUB_MENU = 'grub_menu'
GRUB_SUBMENU = 'grub_submenu'
IPXE = 'ipxe'
IPXE_MENU = 'ipxe_menu'
IPXE_SUBMENU = 'ipxe_submenu'
ISO_BOOTINFO = 'iso_bootinfo'
ISO_BUILDISO = 'iso_buildiso'
ISO_GRUB_MENUENTRY = 'iso_grub_menuentry'
ISO_ISOLINUX_MENUENTRY = 'iso_isolinux_menuentry'
NAMED_PRIMARY = 'named_primary'
NAMED_SECONDARY = 'named_secondary'
NAMED_ZONE_DEFAULT = 'named_zone_default'
NAMED_ZONE_SPECIFC = 'named_zone_specifc'
NDJBDNS = 'ndjbdns'
PXE = 'pxe'
PXE_MENU = 'pxe_menu'
PXE_SUBMENU = 'pxe_submenu'
REPORTING_BUILD_EMAIL = 'reporting_build_email'
RSYNC = 'rsync'
WINDOWS_ANSWERFILE = 'windows_answerfile'
WINDOWS_POST_INST_CMD = 'windows_post_inst_cmd'
WINDOWS_STARTNET = 'windows_startnet'
class cobbler.enums.TlsRequireCert(value)[source]

Bases: ConvertableEnum

This enum represents all TLS validation server cert types which Cobbler can manage.

ALLOW = 'allow'
DEMAND = 'demand'
HARD = 'hard'
NEVER = 'never'
class cobbler.enums.VirtDiskDrivers(value)[source]

Bases: ConvertableEnum

This enum represents all virtual disk driver Cobbler can handle.

INHERITED = '<<inherit>>'
QCOW2 = 'qcow2'
QED = 'qed'
RAW = 'raw'
VDI = 'vdi'
VDMK = 'vdmk'
class cobbler.enums.VirtType(value)[source]

Bases: ConvertableEnum

This enum represents all known types of virtualization Cobbler is able to handle via Koan.

AUTO = 'auto'
INHERITED = '<<inherit>>'
KVM = 'kvm'
OPENVZ = 'openvz'
QEMU = 'qemu'
VMWARE = 'vmware'
VMWAREW = 'vmwarew'
XENFV = 'xenfv'
XENPV = 'xenpv'

7.9. cobbler.grub module

Module that contains GRUB related helper functionality.

cobbler.grub.parse_grub_remote_file(file_location: str) str | None[source]

Parses a URI which grub would try to load from the network.

Parameters:

file_location – The location which grub would try to load from the network.

Returns:

In case the URL could be parsed it is returned in the converted format. Otherwise None is returned.

Raises:
  • TypeError – In case file_location is not of type str.

  • ValueError – In case the file location does not contain a valid IPv4 or IPv6 address

7.10. cobbler.module_loader module

Module loader, adapted for Cobbler usage

class cobbler.module_loader.ModuleLoader(api: CobblerAPI, module_path: str = '')[source]

Bases: object

Class for dynamically loading Cobbler Plugins on startup

get_module_by_name(name: str) ModuleType | None[source]

Get a module by its name. The category of the module is not needed.

Parameters:

name – The name of the module.

Returns:

The module asked by the function parameter.

get_module_from_file(category: str, field: str, fallback_module_name: str | None = None) ModuleType[source]

Get Python module, based on name defined in configuration file

Parameters:
  • category – field category in configuration file

  • field – field in configuration file

  • fallback_module_name – default value used if category/field is not found in configuration file

Raises:

CX – If unable to load Python module

Returns:

A Python module.

get_module_name(category: str, field: str, fallback_module_name: str | None = None) str[source]

Get module name from the settings.

Parameters:
  • category – Field category in configuration file.

  • field – Field in configuration file

  • fallback_module_name – Default value used if category/field is not found in configuration file

Raises:
  • FileNotFoundError – If unable to find configuration file.

  • ValueError – If the category does not exist or the field is empty.

  • CX – If the field could not be read and no fallback_module_name was given.

Returns:

The name of the module.

get_modules_in_category(category: str) List[ModuleType][source]

Return all modules of a module category.

Parameters:

category – The module category.

Returns:

A list of all modules of that category. Returns an empty list if the Category does not exist.

load_modules() Tuple[Dict[str, ModuleType], Dict[str, Dict[str, ModuleType]]][source]

Load the modules from the path handed to the function into Cobbler.

Returns:

Two dictionary’s with the dynamically loaded modules.

7.11. cobbler.power_manager module

Power management library. Encapsulate the logic to run power management commands so that the Cobbler user does not have to remember different power management tools syntaxes. This makes rebooting a system for OS installation much easier.

class cobbler.power_manager.PowerManager(api: CobblerAPI)[source]

Bases: object

Handles power management in systems

get_power_status(system: System, user: str | None = None, password: str | None = None) bool | None[source]

Get power status for a system that has power management configured.

Parameters:
  • system (System) – Cobbler system

  • user – power management user

  • password – power management password

Returns:

if system is powered on

power_off(system: System, user: str | None = None, password: str | None = None) None[source]

Powers down a system that has power management configured.

Parameters:
  • system (System) – Cobbler system

  • user – power management user

  • password – power management password

power_on(system: System, user: str | None = None, password: str | None = None) None[source]

Powers up a system that has power management configured.

Parameters:
  • system (System) – Cobbler system

  • user – power management user

  • password – power management password

reboot(system: System, user: str | None = None, password: str | None = None) None[source]

Reboot a system that has power management configured.

Parameters:
  • system (System) – Cobbler system

  • user – power management user

  • password – power management password

cobbler.power_manager.get_power_command(power_type: str) str | None[source]

Get power management command path

Parameters:

power_type – power management type

Returns:

power management command path

cobbler.power_manager.get_power_types() List[str][source]

Get possible power management types.

Returns:

Possible power management types

cobbler.power_manager.validate_power_type(power_type: str) None[source]

Check if a power management type is valid.

Parameters:

power_type – Power management type.

Raises:

CX – if power management type is invalid

7.12. cobbler.remote module

This module contains all code related to the Cobbler XML-RPC API.

Changelog:

Schema: From -> To

Current Schema: Please refer to the documentation visible of the individual methods.

V4.0.0 (unreleased)
  • Added:
    • Create, Read, Update & Delete methods for the NetworkInterface class

    • set_item_resolved_value

    • input_string_or_list_no_inherit

    • input_string_or_list

    • input_string_or_dict

    • input_string_or_dict_no_inherit

    • input_boolean

    • input_int

  • Changed:
    • `get_random_mac: Change default virt_type` to kvm

  • Removed:
    • xapi_object_edit: Remove all-in-one edit method for the CLI

V3.3.4 (unreleased)
  • No changes

V3.3.3
  • Added:
    • get_item_resolved_value

    • dump_vars

V3.3.2
  • No changes

V3.3.1
  • Changed:
    • background_mkgrub: Renamed to background_mkloaders

V3.3.0
  • Added:
    • background_syncsystems

    • background_mkgrub

    • get_menu

    • find_menu

    • get_menu_handle

    • remove_menu

    • copy_menu

    • rename_menu

    • new_menu

    • modify_menu

    • save_menu

    • get_valid_distro_boot_loaders

    • get_valid_image_boot_loaders

    • get_valid_profile_boot_loaders

    • get_valid_system_boot_loaders

    • get_menus_since

    • get_menu_as_rendered

  • Changed:
    • generate_gpxe: Renamed to generate_ipxe

  • Removed:
    • background_dlcontent

    • get_distro_for_koan

    • get_profile_for_koan

    • get_system_for_koan

    • get_repo_for_koan

    • get_image_for_koan

    • get_mgmtclass_for_koan

    • get_package_for_koan

    • get_file_for_koan

    • get_file_for_koan

V3.2.2
  • No changes

V3.2.1
  • Added:
    • auto_add_repos

V3.2.0
  • No changes

V3.1.2
  • No changes

V3.1.1
  • No changes

V3.1.0
  • No changes

V3.0.1
  • No changes

V3.0.0
  • Added:
    • generate_profile_autoinstall

    • generate_system_autoinstall

    • get_valid_archs

    • read_autoinstall_template

    • write_autoinstall_template

    • remove_autoinstall_template

    • read_autoinstall_snippet

    • write_autoinstall_snippet

    • remove_autoinstall_snippet

  • Changed:
    • get_kickstart_templates: Renamed to get_autoinstall_templates

    • get_snippets: Renamed to get_autoinstall_snippets

    • is_kickstart_in_use: Renamed to is_autoinstall_in_use

    • generate_kickstart: Renamed to generate_autoinstall

  • Removed:
    • update

    • read_or_write_kickstart_template

    • read_or_write_snippet

V2.8.5
  • Inital tracking of changes.

class cobbler.remote.CobblerXMLRPCInterface(api: CobblerAPI)[source]

Bases: object

This is the interface used for all XMLRPC methods, for instance, as used by koan or CobblerWeb.

Most read-write operations require a token returned from “login”. Read operations do not.

auto_add_repos(token: str)[source]
Parameters:

token – The API-token obtained via the login() method.

background_aclsetup(options: Dict[str, Any], token: str) str[source]

Get the acl configuration from the config and set the acls in the backgroud.

Parameters:
  • options – Not known what this parameter does.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

The id of the task which was started.

background_buildiso(options: Dict[str, Any], token: str) str[source]

Generates an ISO in /var/www/cobbler/pub that can be used to install profiles without using PXE.

Parameters:
  • options – This parameter does contain the options passed from the CLI or remote API who called this.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

The id of the task which was started.

Hardlink all files as a background task.

Parameters:
  • options – Not known what this parameter does.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

The id of the task which was started.

background_import(options: Dict[str, Any], token: str) str[source]

Import an ISO image in the background.

Parameters:
  • options – Not known what this parameter does.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

The id of the task which was started.

background_load_items() str[source]

Loading items

background_mkloaders(options: Dict[str, Any], token: str) str[source]

Create the bootloaders that Cobbler uses inside its TFTP-directory and stage them in the background.

Parameters:
  • options – This parameter is unused for this background task.

  • token – The API-token obtained via the login() method.

Returns:

The id of the task which was started.

background_power_system(options: Dict[str, Any], token: str) str[source]

Power a system asynchronously in the background.

Parameters:
  • options – Not known what this parameter does.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

The id of the task which was started.

background_replicate(options: Dict[str, Any], token: str) str[source]

Replicate Cobbler in the background to another Cobbler instance.

Parameters:
  • options – Not known what this parameter does.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

The id of the task which was started.

background_reposync(options: Dict[str, Any], token: str) str[source]

Run a reposync in the background.

Parameters:
  • options – Not known what this parameter does.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

The id of the task which was started.

background_signature_reload(options: Dict[str, Any], token: str) str[source]

Run a signature reload in the background.

Parameters:
  • options – No additional parameters needed.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

The id of the task which was started.

background_signature_update(options: Dict[str, Any], token: str) str[source]

Run a signature update in the background.

Parameters:
  • options – Not known what this parameter does.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

The id of the task which was started.

background_sync(options: Dict[str, Any], token: str) str[source]

Run a full Cobbler sync in the background.

Parameters:
  • options – Possible options: verbose, dhcp, dns

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

The id of the task which was started.

background_syncsystems(options: Dict[str, Any], token: str) str[source]

Run a lite Cobbler sync in the background with only systems specified.

Parameters:
  • options – Unknown what this parameter does.

  • token – The API-token obtained via the login() method.

Returns:

The id of the task that was started.

background_templates_refresh_content(options: Dict[str, Any], token: str) str[source]

Calls cobbler.api.CobblerAPI.templates_refresh_content() with the given list of templates as a background task.

Parameters:
  • options – The dict should have a single key named objects. This key should be a list of strings with names or UIDs of template objects. A single list may contain a mix of names and UIDs.

  • token – The API-token obtained via the login() method.

background_validate_autoinstall_files(options: Dict[str, Any], token: str) str[source]

Validate all autoinstall files in the background.

Parameters:
  • options – Not known what this parameter does.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

The id of the task which was started.

check(token: str) List[str][source]

Returns a list of all the messages/warnings that are things that admin may want to correct about the configuration of the Cobbler server. This has nothing to do with “check_access” which is an auth/authz function in the XMLRPC API.

Parameters:

token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

A list of things to address.

check_access(token: str | None, resource: str, arg1: str | None = None, arg2: Any = None) int[source]

Check if the token which was provided has access.

Parameters:
  • token – The token to check access for.

  • resource – The resource for which access shall be checked.

  • arg1 – Arguments to hand to the authorization provider.

  • arg2 – Arguments to hand to the authorization provider.

Returns:

If the operation was successful return 1. If unsuccessful then return 0. Other codes may be returned if specified by the currently configured authorization module.

check_access_no_fail(token: str, resource: str, arg1: str | None = None, arg2: Any = None) int[source]

This is called by the WUI to decide whether an element is editable or not. It differs form check_access in that it is supposed to /not/ log the access checks (TBA) and does not raise exceptions.

Parameters:
  • token – The token to check access for.

  • resource – The resource for which access shall be checked.

  • arg1 – Arguments to hand to the authorization provider.

  • arg2 – Arguments to hand to the authorization provider.

Returns:

1 if the object is editable or 0 otherwise.

clear_system_logs(object_id: str, token: str) bool[source]

clears console logs of a system

Parameters:
  • object_id – The object id of the system to clear the logs of.

  • token – The API-token obtained via the login() method.

Returns:

True if the operation succeeds.

copy_distro(object_id: str, newname: str, token: str | None = None) bool[source]

Copies a distribution and renames it afterwards.

Parameters:
  • object_id – The object id of the item in question.

  • newname – The new name for the copied object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

copy_distro_group(object_id: str, newname: str, token: str | None = None) bool[source]

Copies a distro group and renames it afterwards.

Parameters:
  • object_id – The object id of the item in question.

  • newname – The new name for the copied object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

copy_image(object_id: str, newname: str, token: str | None = None) bool[source]

Copies an image and renames it afterwards.

Parameters:
  • object_id – The object id of the item in question.

  • newname – The new name for the copied object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

copy_item(what: str, object_id: str, newname: str, token: str | None = None) bool[source]

Creates a new object that matches an existing object, as specified by an id.

Parameters:
  • what – The item type which should be copied.

  • object_id – The object id of the item in question.

  • newname – The new name for the copied object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

copy_menu(object_id: str, newname: str, token: str | None = None) bool[source]

Copies a menu and rename it afterwards.

Parameters:
  • object_id – The object id of the item in question.

  • newname – The new name for the copied object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

copy_network_interface(object_id: str, newname: str, token: str | None = None) bool[source]

Copies a network interface and rename it afterwards.

Parameters:
  • object_id – The object id of the item in question.

  • newname – The new name for the copied object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

copy_profile(object_id: str, newname: str, token: str | None = None) bool[source]

Copies a profile and renames it afterwards.

Parameters:
  • object_id – The object id of the item in question.

  • newname – The new name for the copied object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

copy_profile_group(object_id: str, newname: str, token: str | None = None) bool[source]

Copies a profile group and renames it afterwards.

Parameters:
  • object_id – The object id of the item in question.

  • newname – The new name for the copied object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

copy_repo(object_id: str, newname: str, token: str | None = None) bool[source]

Copies a repository and renames it afterwards.

Parameters:
  • object_id – The object id of the item in question.

  • newname – The new name for the copied object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

copy_system(object_id: str, newname: str, token: str | None = None) bool[source]

Copies a system and renames it afterwards.

Parameters:
  • object_id – The object id of the item in question.

  • newname – The new name for the copied object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

copy_system_group(object_id: str, newname: str, token: str | None = None) bool[source]

Copies a system group and renames it afterwards.

Parameters:
  • object_id – The object id of the item in question.

  • newname – The new name for the copied object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

copy_template(object_id: str, newname: str, token: str | None = None) bool[source]

Copies a template and rename it afterwards.

Parameters:
  • object_id – The object id of the item in question.

  • newname – The new name for the copied object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

disable_netboot(name: str, token: str | None = None, **rest: Any) bool[source]

This is a feature used by the pxe_just_once support, see manpage. Sets system named “name” to no-longer PXE. Disabled by default as this requires public API access and is technically a read-write operation.

Parameters:
  • name – The name of the system to disable netboot for.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is unused.

Returns:

A boolean indicated the success of the action.

dump_vars(item_uuid: str, formatted_output: bool = False, remove_dicts: bool = True)[source]

This function dumps all variables related to an object. The difference to the above mentioned function is that it accepts the item uid instead of the Python object itself.

See also

Logically identical to dump_vars()

extended_version(token: str | None = None, **rest: Any) Dict[str, str | List[str]][source]

Returns the full dictionary of version information. See api.py for documentation.

Parameters:
  • token – The API-token obtained via the login() method.

  • rest – This is dropped in this method since it is not needed here.

Returns:

The extended version of Cobbler

find_distro(criteria: Dict[str, Any] | None = None, expand: bool = False, resolved: bool = False, token: str | None = None, **rest: Any) List[Any][source]

Find a distro matching certain criteria.

Parameters:
  • criteria – The criteria a distribution needs to match.

  • expand – Not only get the names but also the complete object in form of a dict.

  • resolved – This only has an effect when expand = True. It returns the resolved representation of the object instead of the raw data.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

All distributions which have matched the criteria.

find_distro_group(criteria: Dict[str, Any] | None = None, expand: bool = False, resolved: bool = False, token: str | None = None, **rest: Any) List[Any][source]

Find a distro group matching certain criteria.

Parameters:
  • criteria – The criteria a distro group needs to match.

  • expand – Not only get the names but also the complete object in form of a dict.

  • resolved – This only has an effect when expand = True. It returns the resolved representation of the object instead of the raw data.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

All distro groups which have matched the criteria.

find_image(criteria: Dict[str, Any] | None = None, expand: bool = False, resolved: bool = False, token: str | None = None, **rest: Any) List[Any][source]

Find an image matching certain criteria.

Parameters:
  • criteria – The criteria a distribution needs to match.

  • expand – Not only get the names but also the complete object in form of a dict.

  • resolved – This only has an effect when expand = True. It returns the resolved representation of the object instead of the raw data.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

All images which have matched the criteria.

find_items(what: str, criteria: Dict[str, Any] | None = None, sort_field: str | None = None, expand: bool = False, resolved: bool = False, token: str | None = None, **rest: Any) List[Any][source]

Works like get_items but also accepts criteria as a dict to search on.

Example: { "name" : "*.example.org" }

Wildcards work as described by ‘pydoc fnmatch’.

Parameters:
  • what – The object type to find.

  • criteria – The criteria an item needs to match.

  • sort_field – The field to sort the results after.

  • expand – Not only get the names but also the complete object in form of a dict.

  • resolved – This only has an effect when expand = True. It returns the resolved representation of the object instead of the raw data.

Returns:

A list of dicts.

find_items_paged(what: str, criteria: Dict[str, Any] | None = None, sort_field: str | None = None, page: int = 1, items_per_page: int = 25, resolved: bool = False, token: str | None = None)[source]

Returns a list of dicts as with find_items but additionally supports returning just a portion of the total list, for instance in supporting a web app that wants to show a limited amount of items per page.

Parameters:
  • what – The object type to find.

  • criteria – The criteria a distribution needs to match.

  • sort_field – The field to sort the results after.

  • page – The page to return

  • items_per_page – The number of items per page.

  • resolved – This only has an effect when expand = True. It returns the resolved representation of the object instead of the raw data.

  • token – The API-token obtained via the login() method.

Returns:

The found items.

find_menu(criteria: Dict[str, Any] | None = None, expand: bool = False, resolved: bool = False, token: str | None = None, **rest: Any) List[Any][source]

Find a menu matching certain criteria.

Parameters:
  • criteria – The criteria a distribution needs to match.

  • expand – Not only get the names but also the complete object in form of a dict.

  • resolved – This only has an effect when expand = True. It returns the resolved representation of the object instead of the raw data.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

All files which have matched the criteria.

find_network_interface(criteria: Dict[str, Any] | None = None, expand: bool = False, resolved: bool = False, token: str | None = None, **rest: Any) List[Any][source]

Find a network interface matching certain criteria.

Parameters:
  • criteria – The criteria a network interface needs to match.

  • expand – Not only get the names but also the complete object in form of a dict.

  • resolved – This only has an effect when expand = True. It returns the resolved representation of the object instead of the raw data.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

All files which have matched the criteria.

find_profile(criteria: Dict[str, Any] | None = None, expand: bool = False, resolved: bool = False, token: str | None = None, **rest: Any) List[Any][source]

Find a profile matching certain criteria.

Parameters:
  • criteria – The criteria a distribution needs to match.

  • expand – Not only get the names but also the complete object in form of a dict.

  • resolved – This only has an effect when expand = True. It returns the resolved representation of the object instead of the raw data.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

All profiles which have matched the criteria.

find_profile_group(criteria: Dict[str, Any] | None = None, expand: bool = False, resolved: bool = False, token: str | None = None, **rest: Any) List[Any][source]

Find a profile group matching certain criteria.

Parameters:
  • criteria – The criteria a profile group needs to match.

  • expand – Not only get the names but also the complete object in form of a dict.

  • resolved – This only has an effect when expand = True. It returns the resolved representation of the object instead of the raw data.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

All profile groups which have matched the criteria.

find_repo(criteria: Dict[str, Any] | None = None, expand: bool = False, resolved: bool = False, token: str | None = None, **rest: Any) List[Any][source]

Find a repository matching certain criteria.

Parameters:
  • criteria – The criteria a distribution needs to match.

  • expand – Not only get the names but also the complete object in form of a dict.

  • resolved – This only has an effect when expand = True. It returns the resolved representation of the object instead of the raw data.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

All repositories which have matched the criteria.

find_system(criteria: Dict[str, Any] | None = None, expand: bool = False, resolved: bool = False, token: str | None = None, **rest: Any) List[Any][source]

Find a system matching certain criteria.

Parameters:
  • criteria – The criteria a distribution needs to match.

  • expand – Not only get the names but also the complete object in form of a dict.

  • resolved – This only has an effect when expand = True. It returns the resolved representation of the object instead of the raw data.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

All systems which have matched the criteria.

find_system_by_dns_name(dns_name: str) Dict[str, Any][source]

This is used by the puppet external nodes feature.

Parameters:

dns_name – The dns name of the system. This should be the fqdn and not only the hostname.

Returns:

All system information or an empty dict.

find_system_group(criteria: Dict[str, Any] | None = None, expand: bool = False, resolved: bool = False, token: str | None = None, **rest: Any) List[Any][source]

Find a system group matching certain criteria.

Parameters:
  • criteria – The criteria a system group needs to match.

  • expand – Not only get the names but also the complete object in form of a dict.

  • resolved – This only has an effect when expand = True. It returns the resolved representation of the object instead of the raw data.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

All system groups which have matched the criteria.

find_template(criteria: Dict[str, Any] | None = None, expand: bool = False, resolved: bool = False, token: str | None = None, **rest: Any) List[Any][source]

Find a template matching certain criteria.

Parameters:
  • criteria – The criteria a template needs to match.

  • expand – Not only get the names but also the complete object in form of a dict.

  • resolved – This only has an effect when expand = True. It returns the resolved representation of the object instead of the raw data.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

All files which have matched the criteria.

generate_autoinstall(obj_identifier: str = '', obj_type: str = 'profile', obj_field: str = 'name', autoinstaller_file: str = '', autoinstaller_subfile: str = '') str[source]

Generate the auto-installation file and return it.

Parameters:
  • obj_identifier – The identifier of the object to generate the file for.

  • obj_type – Must be either the str “profile” or “system”.

  • obj_field – Must be either the str “name” or “uid”.

  • autoinstaller_type – All currently available types can be found at cobbler.enums.AutoinstallerType. Please use the string values as an argument to this endpoint.

  • autoinstaller_file – TODO

  • autoinstaller_subfile – TODO

Returns:

The str representation of the file.

generate_bootcfg(profile: str | None = None, system: str | None = None, **rest: Any) str[source]

This generates the bootcfg for a system which is related to a certain profile.

Parameters:
  • profile – The profile which is associated to the system.

  • system – The system which the bootcfg should be generated for.

  • rest – This is dropped in this method since it is not needed here.

Returns:

The generated bootcfg.

generate_ipxe(profile: str | None = None, image: str | None = None, system: str | None = None, **rest: Any) str[source]

Generate the ipxe configuration.

Parameters:
  • profile – The profile to generate iPXE config for.

  • image – The image to generate iPXE config for.

  • system – The system to generate iPXE config for.

  • rest – This is dropped in this method since it is not needed here.

Returns:

The configuration as a str representation.

generate_script(profile: str | None = None, system: str | None = None, name: str = '') str[source]

This generates the autoinstall script for a system or profile. Profile and System cannot be both given, if they are, Profile wins.

Parameters:
  • profile – The profile name to generate the script for.

  • system – The system name to generate the script for.

  • name – Name of the generated script. Must only contain alphanumeric characters, dots and underscores.

Returns:

Some generated script.

get_authn_module_name(token: str) str[source]

Get the name of the currently used authentication module.

Parameters:

token – The API-token obtained via the login() method. Cobbler token, obtained form login()

Returns:

The name of the module.

get_blended_data(profile: str | None = None, system: str | None = None)[source]

Combine all data which is available from a profile and system together and return it.

Deprecated since version 4.0.0: Please make use of the dump_vars endpoint.

Parameters:
  • profile – The profile of the system.

  • system – The system for which the data should be rendered.

Returns:

All values which could be blended together through the inheritance chain.

get_config_data(hostname: str) str[source]

Generate configuration data for the system specified by hostname.

Parameters:

hostname – The hostname for what to get the config data of.

Returns:

The config data as a json for Koan.

get_distro(name: str, flatten: bool = False, resolved: bool = False, token: str | None = None, **rest: Any)[source]

Get a distribution.

Parameters:
  • name – The name of the distribution to get.

  • flatten – If the item should be flattened.

  • resolved – If this is True, Cobbler will resolve the values to its final form, rather than give you the objects raw value.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

  • rest – Not used with this method currently.

Returns:

The item or None.

get_distro_as_rendered(name: str, token: str | None = None, **rest: Any) List[Any] | Dict[Any, Any] | int | str | float[source]

Get distribution after passing through Cobbler’s inheritance engine.

Parameters:
  • name – distro name

  • token – authentication token

  • rest – This is dropped in this method since it is not needed here.

Returns:

Get a template rendered as a distribution.

get_distro_group(name: str, flatten: bool = False, resolved: bool = False, token: str | None = None, **rest: Any)[source]

Get a distro group.

Parameters:
  • name – The name of the distro group to get.

  • flatten – If the item should be flattened.

  • resolved – If this is True, Cobbler will resolve the values to its final form, rather than give you the objects raw value.

  • token – The API-token obtained via the login() method.

  • rest – Not used with this method currently.

Returns:

The item or None.

get_distro_group_as_rendered(name: str, token: str | None = None, **rest: Any) List[Any] | Dict[Any, Any] | int | str | float[source]

Get distro group after passing through Cobbler’s inheritance engine

Parameters:
  • name – DistroGroup name

  • token – Authentication token

  • rest – This is dropped in this method since it is not needed here.

Returns:

Get a template rendered as a file.

get_distro_group_handle(name: str)[source]

Get a handle for a distro group which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:

name – The name of the item.

Returns:

The handle of the desired object.

get_distro_groups(page: Any = None, results_per_page: Any = None, token: str | None = None, **rest: Any) List[Dict[str, Any]][source]

This returns all distro groups.

Parameters:
  • page – This parameter is not used currently.

  • results_per_page – This parameter is not used currently.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

The list of all distro groups.

get_distro_groups_since(mtime: float) List[Any] | Dict[Any, Any] | int | str | float[source]

See documentation for get_distros_since

Parameters:

mtime – The time after which all items should be included. Everything before this will be excluded.

Returns:

The list of items which were modified after mtime.

get_distro_handle(name: str)[source]

Get a handle for a distribution which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:

name – The name of the item.

Returns:

The handle of the desired object.

get_distros(page: Any = None, results_per_page: Any = None, token: str | None = None, **rest: Any) List[Dict[str, Any]][source]

This returns all distributions.

Parameters:
  • page – This parameter is not used currently.

  • results_per_page – This parameter is not used currently.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

The list with all distros.

get_distros_since(mtime: float) List[Any] | Dict[Any, Any] | int | str | float[source]

Return all of the distro objects that have been modified after mtime.

Parameters:

mtime – The time after which all items should be included. Everything before this will be excluded.

Returns:

The list of items which were modified after mtime.

get_event_log(event_id: str) str[source]

Returns the contents of a task log. Events that are not task-based do not have logs.

Parameters:

event_id – The event-id generated by Cobbler.

Returns:

The event log or a ?.

get_events(for_user: str = '') Dict[str, List[str | float]][source]

Returns a dict(key=event id) = [ statetime, name, state, [read_by_who] ]

Parameters:

for_user – (Optional) Filter events the user has not seen yet. If left unset, it will return all events.

Returns:

A dictionary with all the events (or all filtered events).

get_image(name: str, flatten: bool = False, resolved: bool = False, token: str | None = None, **rest: Any)[source]

Get an image.

Parameters:
  • name – The name of the image to get.

  • flatten – If the item should be flattened.

  • resolved – If this is True, Cobbler will resolve the values to its final form, rather than give you the objects raw value.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

  • rest – Not used with this method currently.

Returns:

The item or None.

get_image_as_rendered(name: str, token: str | None = None, **rest: Any) List[Any] | Dict[Any, Any] | int | str | float[source]

Get repository after passing through Cobbler’s inheritance engine.

Parameters:
  • name – image name

  • token – authentication token

  • rest – This is dropped in this method since it is not needed here.

Returns:

Get a template rendered as an image.

get_image_handle(name: str)[source]

Get a handle for an image which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:

name – The name of the item.

Returns:

The handle of the desired object.

get_images(page: Any = None, results_per_page: Any = None, token: str | None = None, **rest: Any) List[Dict[str, Any]][source]

This returns all images.

Parameters:
  • page – This parameter is not used currently.

  • results_per_page – This parameter is not used currently.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

The list of all images.

get_images_since(mtime: float) List[Any] | Dict[Any, Any] | int | str | float[source]

See documentation for get_distros_since

Parameters:

mtime – The time after which all items should be included. Everything before this will be excluded.

Returns:

The list of items which were modified after mtime.

get_item(what: str, name: str, flatten: bool = False, resolved: bool = False, token: str | None = None)[source]

Returns a dict describing a given object.

Parameters:
  • what – “distro”, “profile”, “system”, “image”, “repo”, etc

  • name – the object name to retrieve

  • flatten – reduce dicts to string representations (True/False)

  • resolved – If this is True, Cobbler will resolve the values to its final form, rather than give you the objects raw value.

Returns:

The item or None.

get_item_handle(what: str, name: str, token: str | None = None) str[source]

Given the name of an object (or other search parameters), return a reference (object id) that can be used with modify_* functions or save_* functions to manipulate that object.

Parameters:
  • what – The collection where the item is living in.

  • name – The name of the item.

Returns:

The handle of the desired object.

get_item_names(what: str) List[str][source]

This is just like get_items, but transmits less data.

Parameters:

what – is the name of a Cobbler object type, as described for get_item.

Returns:

Returns a list of object names (keys) for the given object type.

get_item_resolved_value(item_uuid: str, attribute: List[str]) str | int | float | List[Any] | Dict[Any, Any][source]

See also

Logically identical to get_item_resolved_value()

get_items(what: str) List[Dict[str, Any]][source]

Individual list elements are the same for get_item.

Parameters:

what – is the name of a Cobbler object type, as described for get_item.

Returns:

This returns a list of dicts.

get_menu(name: str, flatten: bool = False, resolved: bool = False, token: str | None = None, **rest: Any)[source]

Get a menu.

Parameters:
  • name – The name of the file to get.

  • flatten – If the item should be flattened.

  • resolved – If this is True, Cobbler will resolve the values to its final form, rather than give you the objects raw value.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

  • rest – Not used with this method currently.

Returns:

The item or None.

get_menu_as_rendered(name: str, token: str | None = None, **rest: Any) List[Any] | Dict[Any, Any] | int | str | float[source]

Get menu after passing through Cobbler’s inheritance engine

Parameters:
  • name – Menu name

  • token – Authentication token

  • rest – This is dropped in this method since it is not needed here.

Returns:

Get a template rendered as a file.

get_menu_handle(name: str)[source]

Get a handle for a menu which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:

name – The name of the item.

Returns:

The handle of the desired object.

get_menus(page: Any = None, results_per_page: Any = None, token: str | None = None, **rest: Any) List[Dict[str, Any]][source]

This returns all menus.

Parameters:
  • page – This parameter is not used currently.

  • results_per_page – This parameter is not used currently.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

The list of all files.

get_menus_since(mtime: float) List[Any] | Dict[Any, Any] | int | str | float[source]

See documentation for get_distros_since

Parameters:

mtime – The time after which all items should be included. Everything before this will be excluded.

Returns:

The list of items which were modified after mtime.

get_network_interface(name: str, flatten: bool = False, resolved: bool = False, token: str | None = None, **rest: Any)[source]

Get a network interface.

Parameters:
  • name – The name of the network interface to get.

  • flatten – If the item should be flattened.

  • resolved – If this is True, Cobbler will resolve the values to its final form, rather than give you the objects raw value.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

  • rest – Not used with this method currently.

Returns:

The item or None.

get_network_interface_handle(name: str)[source]

Get a handle for a network interface which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:

name – The name of the item.

Returns:

The handle of the desired object.

get_network_interfaces(page: Any = None, results_per_page: Any = None, token: str | None = None, **rest: Any) List[Dict[str, Any]][source]

This returns all network interfaces.

Parameters:
  • page – This parameter is not used currently.

  • results_per_page – This parameter is not used currently.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

The list of all files.

get_network_interfaces_since(mtime: float) List[Any] | Dict[Any, Any] | int | str | float[source]

See documentation for get_distros_since

Parameters:

mtime – The time after which all items should be included. Everything before this will be excluded.

Returns:

The list of items which were modified after mtime.

get_profile(name: str, flatten: bool = False, resolved: bool = False, token: str | None = None, **rest: Any)[source]

Get a profile.

Parameters:
  • name – The name of the profile to get.

  • flatten – If the item should be flattened.

  • resolved – If this is True, Cobbler will resolve the values to its final form, rather than give you the objects raw value.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

  • rest – Not used with this method currently.

Returns:

The item or None.

get_profile_as_rendered(name: str, token: str | None = None, **rest: Any) List[Any] | Dict[Any, Any] | int | str | float[source]

Get profile after passing through Cobbler’s inheritance engine.

Parameters:
  • name – profile name

  • token – authentication token

  • rest – This is dropped in this method since it is not needed here.

Returns:

Get a template rendered as a profile.

get_profile_group(name: str, flatten: bool = False, resolved: bool = False, token: str | None = None, **rest: Any)[source]

Get a profile group.

Parameters:
  • name – The name of the profile group to get.

  • flatten – If the item should be flattened.

  • resolved – If this is True, Cobbler will resolve the values to its final form, rather than give you the objects raw value.

  • token – The API-token obtained via the login() method.

  • rest – Not used with this method currently.

Returns:

The item or None.

get_profile_group_as_rendered(name: str, token: str | None = None, **rest: Any) List[Any] | Dict[Any, Any] | int | str | float[source]

Get profile group after passing through Cobbler’s inheritance engine

Parameters:
  • name – ProfileGroup name

  • token – Authentication token

  • rest – This is dropped in this method since it is not needed here.

Returns:

Get a template rendered as a file.

get_profile_group_handle(name: str)[source]

Get a handle for a profile group which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:

name – The name of the item.

Returns:

The handle of the desired object.

get_profile_groups(page: Any = None, results_per_page: Any = None, token: str | None = None, **rest: Any) List[Dict[str, Any]][source]

This returns all profile groups.

Parameters:
  • page – This parameter is not used currently.

  • results_per_page – This parameter is not used currently.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

The list of all profile groups.

get_profile_groups_since(mtime: float) List[Any] | Dict[Any, Any] | int | str | float[source]

See documentation for get_distros_since

Parameters:

mtime – The time after which all items should be included. Everything before this will be excluded.

Returns:

The list of items which were modified after mtime.

get_profile_handle(name: str)[source]

Get a handle for a profile which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:

name – The name of the item.

Returns:

The handle of the desired object.

get_profiles(page: Any = None, results_per_page: Any = None, token: str | None = None, **rest: Any) List[Dict[str, Any]][source]

This returns all profiles.

Parameters:
  • page – This parameter is not used currently.

  • results_per_page – This parameter is not used currently.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

The list with all profiles.

get_profiles_since(mtime: float) List[Any] | Dict[Any, Any] | int | str | float[source]

See documentation for get_distros_since

Parameters:

mtime – The time after which all items should be included. Everything before this will be excluded.

Returns:

The list of items which were modified after mtime.

get_random_mac(virt_type: str = 'kvm', token: str | None = None, **rest: Any) str[source]

Wrapper for utils.get_random_mac(). Used in the webui.

Parameters:
  • virt_type – The type of the virtual machine.

  • token – The API-token obtained via the login() method. Auth token to authenticate against the api.

  • rest – This is dropped in this method since it is not needed here.

Returns:

The random mac address which shall be used somewhere else.

get_repo(name: str, flatten: bool = False, resolved: bool = False, token: str | None = None, **rest: Any)[source]

Get a repository.

Parameters:
  • name – The name of the repository to get.

  • flatten – If the item should be flattened.

  • resolved – If this is True, Cobbler will resolve the values to its final form, rather than give you the objects raw value.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

  • rest – Not used with this method currently.

Returns:

The item or None.

get_repo_as_rendered(name: str, token: str | None = None, **rest: Any) List[Any] | Dict[Any, Any] | int | str | float[source]

Get repository after passing through Cobbler’s inheritance engine.

Parameters:
  • name – repository name

  • token – authentication token

  • rest – This is dropped in this method since it is not needed here.

Returns:

Get a template rendered as a repository.

get_repo_config_for_profile(profile_name: str, **rest: Any)[source]

Return the yum configuration a given profile should use to obtain all of it’s Cobbler associated repos.

Parameters:
  • profile_name – The name of the profile for which the repository config should be looked up.

  • rest – This is dropped in this method since it is not needed here.

Returns:

The repository configuration for the profile.

get_repo_config_for_system(system_name: str, **rest: Any)[source]

Return the yum configuration a given profile should use to obtain all of it’s Cobbler associated repos.

Parameters:
  • system_name – The name of the system for which the repository config should be looked up.

  • rest – This is dropped in this method since it is not needed here.

Returns:

The repository configuration for the system.

get_repo_handle(name: str)[source]

Get a handle for a repository which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:

name – The name of the item.

Returns:

The handle of the desired object.

get_repos(page: Any = None, results_per_page: Any = None, token: str | None = None, **rest: Any) List[Dict[str, Any]][source]

This returns all repositories.

Parameters:
  • page – This parameter is not used currently.

  • results_per_page – This parameter is not used currently.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

The list of all repositories.

get_repos_compatible_with_profile(profile: str, token: str | None = None, **rest: Any) List[Dict[Any, Any]][source]

Get repos that can be used with a given profile name.

Parameters:
  • profile – The profile to check for compatibility.

  • token – The API-token obtained via the login() method.

  • rest – This is dropped in this method since it is not needed here.

Returns:

The list of compatible repositories.

get_repos_since(mtime: float) List[Any] | Dict[Any, Any] | int | str | float[source]

See documentation for get_distros_since

Parameters:

mtime – The time after which all items should be included. Everything before this will be excluded.

Returns:

The list of items which were modified after mtime.

get_settings(token: str | None = None, **rest: Any) Dict[str, Any][source]

Return the contents of our settings file, which is a dict.

Parameters:
  • token – The API-token obtained via the login() method.

  • rest – Unused parameter.

Returns:

Get the settings which are currently in Cobbler present.

get_signatures(token: str | None = None, **rest: Any) Dict[Any, Any][source]

Return the contents of the API signatures

Parameters:
  • token – The API-token obtained via the login() method.

  • rest – This is dropped in this method since it is not needed here.

Returns:

Get the content of the currently loaded signatures file.

get_status(mode: str = 'normal', token: str | None = None, **rest: Any) Dict[Any, Any] | str[source]

Returns the same information as cobbler status While a read-only operation, this requires a token because it’s potentially a fair amount of I/O

Parameters:
  • mode – How the status should be presented.

  • token – The API-token obtained via the login() method. Auth token to authenticate against the api.

  • rest – This parameter is currently unused for this method.

Returns:

The human or machine readable status of the status of Cobbler.

get_system(name: str, flatten: bool = False, resolved: bool = False, token: str | None = None, **rest: Any)[source]

Get a system.

Parameters:
  • name – The name of the system to get.

  • flatten – If the item should be flattened.

  • resolved – If this is True, Cobbler will resolve the values to its final form, rather than give you the objects raw value.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

  • rest – Not used with this method currently.

Returns:

The item or None.

get_system_as_rendered(name: str, token: str | None = None, **rest: Any) List[Any] | Dict[Any, Any] | int | str | float[source]

Get profile after passing through Cobbler’s inheritance engine.

Parameters:
  • name – system name

  • token – authentication token

  • rest – This is dropped in this method since it is not needed here.

Returns:

Get a template rendered as a system.

get_system_group(name: str, flatten: bool = False, resolved: bool = False, token: str | None = None, **rest: Any)[source]

Get a system group.

Parameters:
  • name – The name of the system group to get.

  • flatten – If the item should be flattened.

  • resolved – If this is True, Cobbler will resolve the values to its final form, rather than give you the objects raw value.

  • token – The API-token obtained via the login() method.

  • rest – Not used with this method currently.

Returns:

The item or None.

get_system_group_as_rendered(name: str, token: str | None = None, **rest: Any) List[Any] | Dict[Any, Any] | int | str | float[source]

Get system group after passing through Cobbler’s inheritance engine

Parameters:
  • name – SystemGroup name

  • token – Authentication token

  • rest – This is dropped in this method since it is not needed here.

Returns:

Get a template rendered as a file.

get_system_group_handle(name: str)[source]

Get a handle for a system group which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:

name – The name of the item.

Returns:

The handle of the desired object.

get_system_groups(page: Any = None, results_per_page: Any = None, token: str | None = None, **rest: Any) List[Dict[str, Any]][source]

This returns all system groups.

Parameters:
  • page – This parameter is not used currently.

  • results_per_page – This parameter is not used currently.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

The list of all system groups.

get_system_groups_since(mtime: float) List[Any] | Dict[Any, Any] | int | str | float[source]

See documentation for get_distros_since

Parameters:

mtime – The time after which all items should be included. Everything before this will be excluded.

Returns:

The list of items which were modified after mtime.

get_system_handle(name: str)[source]

Get a handle for a system which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:

name – The name of the item.

Returns:

The handle of the desired object.

get_systems(page: Any = None, results_per_page: Any = None, token: str | None = None, **rest: Any) List[Dict[str, Any]][source]

This returns all Systems.

Parameters:
  • page – This parameter is not used currently.

  • results_per_page – This parameter is not used currently.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

The list of all systems.

get_systems_since(mtime: float) List[Any] | Dict[Any, Any] | int | str | float[source]

See documentation for get_distros_since

Parameters:

mtime – The time after which all items should be included. Everything before this will be excluded.

Returns:

The list of items which were modified after mtime.

get_task_status(event_id: str) List[str | float | List[str]][source]

Get the current status of the task.

Parameters:

event_id – The unique id of the task.

Returns:

The event status.

get_template(name: str, flatten: bool = False, resolved: bool = False, token: str | None = None, **rest: Any)[source]

Get a template.

Parameters:
  • name – The name of the template to get.

  • flatten – If the item should be flattened.

  • resolved – If this is True, Cobbler will resolve the values to its final form, rather than give you the objects raw value.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

  • rest – Not used with this method currently.

Returns:

The item or None.

get_template_content(uid: str, token: str | None = None) str[source]

Search for the given object and return the content of the template. Call templates_refresh_content() or background_templates_refresh_content() to refresh the content if something has changes that the in-memory representation isn’t showing.

Parameters:
  • uid – The UID of the desired template.

  • token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

The content of the autoinstallation template that is currently available in-memory.

get_template_file_for_profile(profile_name: str, path: str, **rest: Any)[source]

Return the templated file requested for this profile

Parameters:
  • profile_name – The name of the profile to get the template file for.

  • path – The path to the template which is requested.

  • rest – This is dropped in this method since it is not needed here.

Returns:

The template file as a str representation.

get_template_file_for_system(system_name: str, path: str, **rest: Any)[source]

Return the templated file requested for this system

Parameters:
  • system_name – The name of the system to get the template file for.

  • path – The path to the template which is requested.

  • rest – This is dropped in this method since it is not needed here.

Returns:

The template file as a str representation.

get_template_handle(name: str)[source]

Get a handle for a template which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:

name – The name of the item.

Returns:

The handle of the desired object.

get_templates(page: Any = None, results_per_page: Any = None, token: str | None = None, **rest: Any) List[Dict[str, Any]][source]

This returns all templates.

Parameters:
  • page – This parameter is not used currently.

  • results_per_page – This parameter is not used currently.

  • token – The API-token obtained via the login() method.

  • rest – This parameter is not used currently.

Returns:

The list of all files.

get_templates_since(mtime: float) List[Any] | Dict[Any, Any] | int | str | float[source]

See documentation for get_distros_since

Parameters:

mtime – The time after which all items should be included. Everything before this will be excluded.

Returns:

The list of items which were modified after mtime.

get_tftp_file(path: str, offset: int, size: int, token: str) Tuple[bytes, int][source]

Generate and return a file for a TFTP client.

Parameters:
  • path – Path to file

  • token – The API-token obtained via the login() method

  • offset – Offset of the requested chunk in the file

  • size – Size of the requested chunk in the file

Returns:

The requested chunk and the length of the whole file

get_user_from_token(token: str | None) str[source]

Given a token returned from login, return the username that logged in with it.

Parameters:

token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

The username if the token was valid.

Raises:
  • CX – If the token supplied to the function is invalid.

  • ValueError – In case “token” did not fulfil the requirements to be a token.

get_valid_archs(token: str | None = None) List[str][source]

Return the list of valid architectures as read in from the distro signatures data

Parameters:

token – The API-token obtained via the login() method.

Returns:

Get a list of all valid architectures.

get_valid_breeds(token: str | None = None, **rest: Any) List[str][source]

Return the list of valid breeds as read in from the distro signatures data

Parameters:
  • token – The API-token obtained via the login() method.

  • rest – This is dropped in this method since it is not needed here.

Returns:

All valid OS-Breeds which are present in Cobbler.

get_valid_distro_boot_loaders(distro_name: str | None, token: str | None = None) List[str][source]

Return the list of valid boot loaders for the distro

Parameters:
  • token – The API-token obtained via the login() method.

  • distro_name – The name of the distro for which the boot loaders should be looked up.

Returns:

Get a list of all valid boot loaders.

get_valid_image_boot_loaders(image_name: str | None, token: str | None = None) List[str][source]

Return the list of valid boot loaders for the image

Parameters:
  • token – The API-token obtained via the login() method.

  • image_name – The name of the image for which the boot loaders should be looked up.

Returns:

Get a list of all valid boot loaders.

get_valid_os_versions(token: str | None = None, **rest: Any) List[str][source]

Return the list of valid os_versions as read in from the distro signatures data

Parameters:
  • token – The API-token obtained via the login() method.

  • rest – This is dropped in this method since it is not needed here.

Returns:

Get all valid OS-Versions

get_valid_os_versions_for_breed(breed: str, token: str | None = None, **rest: Any) List[str][source]

Return the list of valid os_versions for the given breed

Parameters:
  • breed – The OS-Breed which is requested.

  • token – The API-token obtained via the login() method.

  • rest – This is dropped in this method since it is not needed here.

Returns:

All valid OS-versions for a certain breed.

get_valid_profile_boot_loaders(profile_name: str | None, token: str | None = None) List[str][source]

Return the list of valid boot loaders for the profile

Parameters:
  • token – The API-token obtained via the login() method.

  • profile_name – The name of the profile for which the boot loaders should be looked up.

Returns:

Get a list of all valid boot loaders.

get_valid_system_boot_loaders(system_name: str | None, token: str | None = None) List[str][source]

Return the list of valid boot loaders for the system

Parameters:
  • token – The API-token obtained via the login() method.

  • system_name – The name of the system for which the boot loaders should be looked up.

Returns:

Get a list of all valid boot loaders.get_valid_archs

has_item(what: str, name: str, token: str | None = None)[source]

Returns True if a given collection has an item with a given name, otherwise returns False.

Parameters:
  • what – The collection to search through.

  • name – The name of the item.

  • token – The API-token obtained via the login() method.

Returns:

True if item was found, otherwise False.

input_boolean(value: str | bool | int) bool[source]

See also

input_boolean()

input_int(value: str | int | float) int[source]

See also

input_int()

input_string_or_dict(options: str | List[Any] | Dict[Any, Any], allow_multiples: bool = True) str | Dict[Any, Any][source]
input_string_or_dict_no_inherit(options: str | List[Any] | Dict[Any, Any], allow_multiples: bool = True) Dict[Any, Any][source]
input_string_or_list(options: str | List[Any] | None) List[Any] | str[source]
input_string_or_list_no_inherit(options: str | List[Any] | None) List[Any][source]
is_autoinstall_in_use(ai: str, token: str | None = None, **rest: Any) bool[source]

Check if the auto-installation for a system is in use.

Parameters:
  • ai – The name of the system which could potentially be in autoinstall mode.

  • token – The API-token obtained via the login() method.

  • rest – This is dropped in this method since it is not needed here.

Returns:

True if this is the case, otherwise False.

last_modified_time(token: str | None = None) float[source]

Return the time of the last modification to any object. Used to verify from a calling application that no Cobbler objects have changed since last check. This method is implemented in the module api under the same name.

Parameters:

token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

0 if there is no file where the information required for this method is saved.

login(login_user: str, login_password: str) str[source]

Takes a username and password, validates it, and if successful returns a random login token which must be used on subsequent method calls. The token will time out after a set interval if not used. Re-logging in permitted.

Parameters:
  • login_user – The username which is used to authenticate at Cobbler.

  • login_password – The password which is used to authenticate at Cobbler.

Returns:

The token which can be used further on.

logout(token: str) bool[source]

Retires a token ahead of the timeout.

Parameters:

token – The API-token obtained via the login() method. Cobbler token, obtained form login()

Returns:

if operation was successful or not

modify_distro(object_id: str, attribute: List[str], arg: Any, token: str) bool[source]

Modify a single attribute of a distribution.

Parameters:
  • object_id – The id of the object which shall be modified.

  • attribute – The attribute name which shall be edited.

  • arg – The new value for the argument.

  • token – The API-token obtained via the login() method.

Returns:

True if the action was successful. Otherwise False.

modify_distro_group(object_id: str, attribute: List[str], arg: Any, token: str) bool[source]

Modify a single attribute of a distro group.

Parameters:
  • object_id – The id of the object which shall be modified.

  • attribute – The attribute name which shall be edited.

  • arg – The new value for the argument.

  • token – The API-token obtained via the login() method.

Returns:

True if the action was successful. Otherwise False.

modify_image(object_id: str, attribute: List[str], arg: Any, token: str) bool[source]

Modify a single attribute of an image.

Parameters:
  • object_id – The id of the object which shall be modified.

  • attribute – The attribute name which shall be edited.

  • arg – The new value for the argument.

  • token – The API-token obtained via the login() method.

Returns:

True if the action was successful. Otherwise False.

modify_item(what: str, object_id: str, attribute: List[str], arg: str | int | float | List[str] | Dict[str, Any], token: str) bool[source]

Adjusts the value of a given field, specified by ‘what’ on a given object id. Allows modification of certain attributes on newly created or existing distro object handle.

Parameters:
  • what – The type of object to modify.

  • object_id – The id of the object which shall be modified.

  • attribute – The attribute name which shall be edited.

  • arg – The new value for the argument.

  • token – The API-token obtained via the login() method.

Returns:

True if the action was successful. Otherwise False.

modify_menu(object_id: str, attribute: List[str], arg: Any, token: str) bool[source]

Modify a single attribute of a menu.

Parameters:
  • object_id – The id of the object which shall be modified.

  • attribute – The attribute name which shall be edited.

  • arg – The new value for the argument.

  • token – The API-token obtained via the login() method.

Returns:

True if the action was successful. Otherwise False.

modify_network_interface(object_id: str, attribute: List[str], arg: Any, token: str) bool[source]

Modify a single attribute of a network_interface.

Parameters:
  • object_id – The id of the object which shall be modified.

  • attribute – The attribute name which shall be edited.

  • arg – The new value for the argument.

  • token – The API-token obtained via the login() method.

Returns:

True if the action was successful. Otherwise False.

modify_profile(object_id: str, attribute: List[str], arg: Any, token: str) bool[source]

Modify a single attribute of a profile.

Parameters:
  • object_id – The id of the object which shall be modified.

  • attribute – The attribute name which shall be edited.

  • arg – The new value for the argument.

  • token – The API-token obtained via the login() method.

Returns:

True if the action was successful. Otherwise False.

modify_profile_group(object_id: str, attribute: List[str], arg: Any, token: str) bool[source]

Modify a single attribute of a profile group.

Parameters:
  • object_id – The id of the object which shall be modified.

  • attribute – The attribute name which shall be edited.

  • arg – The new value for the argument.

  • token – The API-token obtained via the login() method.

Returns:

True if the action was successful. Otherwise False.

modify_repo(object_id: str, attribute: List[str], arg: Any, token: str) bool[source]

Modify a single attribute of a repository.

Parameters:
  • object_id – The id of the object which shall be modified.

  • attribute – The attribute name which shall be edited.

  • arg – The new value for the argument.

  • token – The API-token obtained via the login() method.

Returns:

True if the action was successful. Otherwise False.

modify_setting(setting_name: str, value: str | bool | float | int | Dict[Any, Any] | List[Any], token: str) int[source]

Modify a single attribute of a setting.

Parameters:
  • setting_name – The name of the setting which shall be adjusted.

  • value – The new value for the setting.

  • token – The API-token obtained via the login() method.

Returns:

0 on success, 1 on error.

modify_system(object_id: str, attribute: List[str], arg: Any, token: str) bool[source]

Modify a single attribute of a system.

Parameters:
  • object_id – The id of the object which shall be modified.

  • attribute – The attribute name which shall be edited.

  • arg – The new value for the argument.

  • token – The API-token obtained via the login() method.

Returns:

True if the action was successful. Otherwise False.

modify_system_group(object_id: str, attribute: List[str], arg: Any, token: str) bool[source]

Modify a single attribute of a system group.

Parameters:
  • object_id – The id of the object which shall be modified.

  • attribute – The attribute name which shall be edited.

  • arg – The new value for the argument.

  • token – The API-token obtained via the login() method.

Returns:

True if the action was successful. Otherwise False.

modify_template(object_id: str, attribute: List[str], arg: Any, token: str) bool[source]

Modify a single attribute of a template.

Parameters:
  • object_id – The id of the object which shall be modified.

  • attribute – The attribute name which shall be edited.

  • arg – The new value for the argument.

  • token – The API-token obtained via the login() method.

Returns:

True if the action was successful. Otherwise False.

new_distro(token: str) str[source]

See new_item().

Parameters:

token – The API-token obtained via the login() method.

Returns:

The object id for the newly created object.

new_distro_group(token: str) str[source]

See new_item().

Parameters:

token – The API-token obtained via the login() method.

Returns:

The object id for the newly created object.

new_image(token: str) str[source]

See new_item().

Parameters:

token – The API-token obtained via the login() method.

Returns:

The object id for the newly created object.

new_item(what: str, token: str, is_subobject: bool = False, **kwargs: Any) str[source]

Creates a new (unconfigured) object, returning an object handle that can be used.

Creates a new (unconfigured) object, returning an object handle that can be used with modify_* methods and then finally save_* methods. The handle only exists in memory until saved.

Parameters:
  • what – specifies the type of object: distro, profile, system, repo, image or menu.

  • token – The API-token obtained via the login() method.

  • is_subobject – If the object is a subobject of an already existing object or not.

Returns:

The object id for the newly created object.

new_menu(token: str) str[source]

See new_item().

Parameters:

token – The API-token obtained via the login() method.

Returns:

The object id for the newly created object.

new_network_interface(system_uid: str, token: str) str[source]

See new_item().

Parameters:
  • token – The API-token obtained via the login() method.

  • system_uid – The UID of the system to attach the network interface to.

Returns:

The object id for the newly created object.

new_profile(token: str) str[source]

See new_item().

Parameters:

token – The API-token obtained via the login() method.

Returns:

The object id for the newly created object.

new_profile_group(token: str) str[source]

See new_item().

Parameters:

token – The API-token obtained via the login() method.

Returns:

The object id for the newly created object.

new_repo(token: str) str[source]

See new_item().

Parameters:

token – The API-token obtained via the login() method.

Returns:

The object id for the newly created object.

new_subprofile(token: str) str[source]

See new_item().

Parameters:

token – The API-token obtained via the login() method.

Returns:

The object id for the newly created object.

new_system(token: str) str[source]

See new_item().

Parameters:

token – The API-token obtained via the login() method.

Returns:

The object id for the newly created object.

new_system_group(token: str) str[source]

See new_item().

Parameters:

token – The API-token obtained via the login() method.

Returns:

The object id for the newly created object.

new_template(token: str) str[source]

See new_item().

Parameters:

token – The API-token obtained via the login() method.

Returns:

The object id for the newly created object.

ping() bool[source]

Deprecated method. Now does nothing.

Returns:

Always True

power_system(system_id: str, power: str, token: str) bool[source]

Execute power task synchronously.

Returns true if the operation succeeded or if the system is powered on (in case of status). False otherwise.

Parameters:
  • token – The API-token obtained via the login() method. The API-token obtained via the login() method. All tasks require tokens.

  • system_id – system handle

  • power – power operation (on/off/status/reboot)

register_new_system(info: Dict[str, Any], token: str | None = None, **rest: Any) int[source]

If register_new_installs is enabled in settings, this allows /usr/bin/cobbler-register (part of the koan package) to add new system records remotely if they don’t already exist. There is a cobbler_register snippet that helps with doing this automatically for new installs but it can also be used for existing installs.

See “AutoRegistration” on the Wiki.

Parameters:
  • info – The system information which is provided by the system.

  • token – The API-token obtained via the login() method.

  • rest – This is dropped in this method since it is not needed here.

Returns:

Return 0 if everything succeeded.

remove_distro(name: str, token: str, recursive: bool = True) bool[source]

Deletes a distribution from Cobbler.

Parameters:
  • name – The name of the item to remove.

  • token – The API-token obtained via the login() method.

  • recursive – If items which are depending on this one should be erased too.

Returns:

True if the action was successful.

remove_distro_group(name: str, token: str, recursive: bool = True) bool[source]

Deletes a distro group from Cobbler.

Parameters:
  • name – The name of the item to remove.

  • token – The API-token obtained via the login() method.

  • recursive – If items which are depending on this one should be erased too.

Returns:

True if the action was successful.

remove_image(name: str, token: str, recursive: bool = True) bool[source]

Deletes an image from Cobbler.

Parameters:
  • name – The name of the item to remove.

  • token – The API-token obtained via the login() method.

  • recursive – If items which are depending on this one should be erased too.

Returns:

True if the action was successful.

remove_item(what: str, name: str, token: str, recursive: bool = True) bool[source]

Deletes an item from a collection. Note that this requires the name of the distro, not an item handle.

Parameters:
  • what – The item type of the item to remove.

  • name – The name of the item to remove.

  • token – The API-token obtained via the login() method.

  • recursive – If items which are depending on this one should be erased too.

Returns:

True if the action was successful.

remove_menu(name: str, token: str, recursive: bool = True) bool[source]

Deletes a menu from Cobbler.

Parameters:
  • name – The name of the item to remove.

  • token – The API-token obtained via the login() method.

  • recursive – If items which are depending on this one should be erased too.

Returns:

True if the action was successful.

remove_network_interface(name: str, token: str, recursive: bool = True) bool[source]

Deletes a network interface from Cobbler.

Parameters:
  • name – The name of the item to remove.

  • token – The API-token obtained via the login() method.

  • recursive – If items which are depending on this one should be erased too.

Returns:

True if the action was successful.

remove_profile(name: str, token: str, recursive: bool = True) bool[source]

Deletes a profile from Cobbler.

Parameters:
  • name – The name of the item to remove.

  • token – The API-token obtained via the login() method.

  • recursive – If items which are depending on this one should be erased too.

Returns:

True if the action was successful.

remove_profile_group(name: str, token: str, recursive: bool = True) bool[source]

Deletes a profile group from Cobbler.

Parameters:
  • name – The name of the item to remove.

  • token – The API-token obtained via the login() method.

  • recursive – If items which are depending on this one should be erased too.

Returns:

True if the action was successful.

remove_repo(name: str, token: str, recursive: bool = True) bool[source]

Deletes a repository from Cobbler.

Parameters:
  • name – The name of the item to remove.

  • token – The API-token obtained via the login() method.

  • recursive – If items which are depending on this one should be erased too.

Returns:

True if the action was successful.

remove_system(name: str, token: str, recursive: bool = True) bool[source]

Deletes a system from Cobbler.

Parameters:
  • name – The name of the item to remove.

  • token – The API-token obtained via the login() method.

  • recursive – If items which are depending on this one should be erased too.

Returns:

True if the action was successful.

remove_system_group(name: str, token: str, recursive: bool = True) bool[source]

Deletes a system group from Cobbler.

Parameters:
  • name – The name of the item to remove.

  • token – The API-token obtained via the login() method.

  • recursive – If items which are depending on this one should be erased too.

Returns:

True if the action was successful.

remove_template(name: str, token: str, recursive: bool = True) bool[source]

Deletes a template from Cobbler.

Parameters:
  • name – The name of the item to remove.

  • token – The API-token obtained via the login() method.

  • recursive – If items which are depending on this one should be erased too.

Returns:

True if the action was successful.

rename_distro(object_id: str, newname: str, token: str | None = None) bool[source]

Renames a distribution specified by object_id to a new name.

Parameters:
  • object_id – The id which refers to the object.

  • newname – The new name for the object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

rename_distro_group(object_id: str, newname: str, token: str | None = None) bool[source]

Renames a distro group specified by object_id to a new name.

Parameters:
  • object_id – The id which refers to the object.

  • newname – The new name for the object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

rename_image(object_id: str, newname: str, token: str | None = None) bool[source]

Renames an image specified by object_id to a new name.

Parameters:
  • object_id – The id which refers to the object.

  • newname – The new name for the object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

rename_item(what: str, object_id: str, newname: str, token: str | None = None) bool[source]

Renames an object specified by object_id to a new name.

Parameters:
  • what – The type of object which shall be renamed to a new name.

  • object_id – The id which refers to the object.

  • newname – The new name for the object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

rename_menu(object_id: str, newname: str, token: str | None = None) bool[source]

Renames a menu specified by object_id to a new name.

Parameters:
  • object_id – The id which refers to the object.

  • newname – The new name for the object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

rename_network_interface(object_id: str, newname: str, token: str | None = None) bool[source]

Renames a network interface specified by object_id to a new name.

Parameters:
  • object_id – The id which refers to the object.

  • newname – The new name for the object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

rename_profile(object_id: str, newname: str, token: str | None = None) bool[source]

Renames a profile specified by object_id to a new name.

Parameters:
  • object_id – The id which refers to the object.

  • newname – The new name for the object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

rename_profile_group(object_id: str, newname: str, token: str | None = None) bool[source]

Renames a profile group specified by object_id to a new name.

Parameters:
  • object_id – The id which refers to the object.

  • newname – The new name for the object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

rename_repo(object_id: str, newname: str, token: str | None = None) bool[source]

Renames a repository specified by object_id to a new name.

Parameters:
  • object_id – The id which refers to the object.

  • newname – The new name for the object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

rename_system(object_id: str, newname: str, token: str | None = None) bool[source]

Renames a system specified by object_id to a new name.

Parameters:
  • object_id – The id which refers to the object.

  • newname – The new name for the object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

rename_system_group(object_id: str, newname: str, token: str | None = None) bool[source]

Renames a system group specified by object_id to a new name.

Parameters:
  • object_id – The id which refers to the object.

  • newname – The new name for the object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

rename_template(object_id: str, newname: str, token: str | None = None) bool[source]

Renames a template specified by object_id to a new name.

Parameters:
  • object_id – The id which refers to the object.

  • newname – The new name for the object.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

run_install_triggers(mode: str, objtype: str, name: str, ip: str, token: str | None = None, **rest: Any)[source]

This is a feature used to run the pre/post install triggers. See CobblerTriggers on Wiki for details

Parameters:
  • mode – The mode of the triggers. May be “pre”, “post” or “firstboot”.

  • objtype – The type of object. This should correspond to the collection type.

  • name – The name of the object.

  • ip – The ip of the objet.

  • token – The API-token obtained via the login() method.

  • rest – This is dropped in this method since it is not needed here.

Returns:

True if everything worked correctly.

save_distro(object_id: str, with_triggers: bool = True, with_sync: bool = True, editmode: str = 'bypass', token: str = '') bool[source]

Saves a newly created or modified object to disk. Calling save is required for any changes to persist.

Parameters:
  • object_id – The id of the object to save.

  • with_triggers – If triggers should be run during save. Set to False to suppress per-save triggers.

  • with_sync – If a Cobbler sync should be executed after save. Set to False to suppress per-save syncs.

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

save_distro_group(object_id: str, with_triggers: bool = True, with_sync: bool = True, editmode: str = 'bypass', token: str = '') bool[source]

Saves a newly created or modified object to disk. Calling save is required for any changes to persist.

Parameters:
  • object_id – The id of the object to save.

  • with_triggers – If triggers should be run during save. Set to False to suppress per-save triggers.

  • with_sync – If a Cobbler sync should be executed after save. Set to False to suppress per-save syncs.

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

save_image(object_id: str, with_triggers: bool = True, with_sync: bool = True, editmode: str = 'bypass', token: str = '') bool[source]

Saves a newly created or modified object to disk. Calling save is required for any changes to persist.

Parameters:
  • object_id – The id of the object to save.

  • with_triggers – If triggers should be run during save. Set to False to suppress per-save triggers.

  • with_sync – If a Cobbler sync should be executed after save. Set to False to suppress per-save syncs.

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

save_item(what: str, object_id: str, with_triggers: bool = True, with_sync: bool = True, editmode: str = 'bypass', token: str = '') bool[source]

Saves a newly created or modified object to disk. Calling save is required for any changes to persist.

Parameters:
  • what – The type of object which shall be saved. This corresponds to the collections.

  • object_id – The id of the object to save.

  • with_triggers – If triggers should be run during save. Set to False to suppress per-save triggers.

  • with_sync – If a Cobbler sync should be executed after save. Set to False to suppress per-save syncs.

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

save_menu(object_id: str, with_triggers: bool = True, with_sync: bool = True, editmode: str = 'bypass', token: str = '') bool[source]

Saves a newly created or modified object to disk. Calling save is required for any changes to persist.

Parameters:
  • object_id – The id of the object to save.

  • with_triggers – If triggers should be run during save. Set to False to suppress per-save triggers.

  • with_sync – If a Cobbler sync should be executed after save. Set to False to suppress per-save syncs.

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

save_network_interface(object_id: str, with_triggers: bool = True, with_sync: bool = True, editmode: str = 'bypass', token: str = '') bool[source]

Saves a newly created or modified object to disk. Calling save is required for any changes to persist.

Parameters:
  • object_id – The id of the object to save.

  • with_triggers – If triggers should be run during save. Set to False to suppress per-save triggers.

  • with_sync – If a Cobbler sync should be executed after save. Set to False to suppress per-save syncs.

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

save_profile(object_id: str, with_triggers: bool = True, with_sync: bool = True, editmode: str = 'bypass', token: str = '') bool[source]

Saves a newly created or modified object to disk. Calling save is required for any changes to persist.

Parameters:
  • object_id – The id of the object to save.

  • with_triggers – If triggers should be run during save. Set to False to suppress per-save triggers.

  • with_sync – If a Cobbler sync should be executed after save. Set to False to suppress per-save syncs.

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

save_profile_group(object_id: str, with_triggers: bool = True, with_sync: bool = True, editmode: str = 'bypass', token: str = '') bool[source]

Saves a newly created or modified object to disk. Calling save is required for any changes to persist.

Parameters:
  • object_id – The id of the object to save.

  • with_triggers – If triggers should be run during save. Set to False to suppress per-save triggers.

  • with_sync – If a Cobbler sync should be executed after save. Set to False to suppress per-save syncs.

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

save_repo(object_id: str, with_triggers: bool = True, with_sync: bool = True, editmode: str = 'bypass', token: str = '') bool[source]

Saves a newly created or modified object to disk. Calling save is required for any changes to persist.

Parameters:
  • object_id – The id of the object to save.

  • with_triggers – If triggers should be run during save. Set to False to suppress per-save triggers.

  • with_sync – If a Cobbler sync should be executed after save. Set to False to suppress per-save syncs.

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

save_system(object_id: str, with_triggers: bool = True, with_sync: bool = True, editmode: str = 'bypass', token: str = '') bool[source]

Saves a newly created or modified object to disk. Calling save is required for any changes to persist.

Parameters:
  • object_id – The id of the object to save.

  • with_triggers – If triggers should be run during save. Set to False to suppress per-save triggers.

  • with_sync – If a Cobbler sync should be executed after save. Set to False to suppress per-save syncs.

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

save_system_group(object_id: str, with_triggers: bool = True, with_sync: bool = True, editmode: str = 'bypass', token: str = '') bool[source]

Saves a newly created or modified object to disk. Calling save is required for any changes to persist.

Parameters:
  • object_id – The id of the object to save.

  • with_triggers – If triggers should be run during save. Set to False to suppress per-save triggers.

  • with_sync – If a Cobbler sync should be executed after save. Set to False to suppress per-save syncs.

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

save_template(object_id: str, with_triggers: bool = True, with_sync: bool = True, editmode: str = 'bypass', token: str = '') bool[source]

Saves a newly created or modified object to disk. Calling save is required for any changes to persist.

Parameters:
  • object_id – The id of the object to save.

  • with_triggers – If triggers should be run during save. Set to False to suppress per-save triggers.

  • with_sync – If a Cobbler sync should be executed after save. Set to False to suppress per-save syncs.

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

  • token – The API-token obtained via the login() method.

Returns:

True if the action succeeded.

set_item_resolved_value(item_uuid: str, attribute: List[str], value: Any, token: str | None = None) bool[source]

See also

Logically identical to set_item_resolved_value()

sync(token: str) bool[source]

Run sync code, which should complete before XMLRPC timeout. We can’t do reposync this way. Would be nice to send output over AJAX/other later.

Parameters:

token – The API-token obtained via the login() method. Cobbler token, obtained form login()

Returns:

bool if operation was successful

sync_dhcp(token: str) bool[source]

Run sync code, which should complete before XMLRPC timeout. We can’t do reposync this way. Would be nice to send output over AJAX/other later.

Parameters:

token – The API-token obtained via the login() method. Cobbler token, obtained form login()

Returns:

bool if operation was successful

templates_refresh_content(objects: List[str], token: str | None = '') bool[source]

Calls cobbler.api.CobblerAPI.templates_refresh_content() with the given list of templates.

Parameters:
  • objects – A list of strings which represent the names and/or UIDs of template objects. Missing or not found elements are skipped.

  • token – The API-token obtained via the login() method.

token_check(token: str) bool[source]

Checks to make sure a token is valid or not.

Parameters:

token – The API-token obtained via the login() method. Cobbler token, obtained form login()

Returns:

if operation was successful or not

transaction_abort(token: str) bool[source]

Aborts current transaction, all changes are discarded.

Parameters:

token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

bool if operation was successful

transaction_begin(token: str) bool[source]

Begins a new transaction for the logged-in client. Transactions allow multiple API operations (new_*, get_*, modify_*, copy_*, remove_*) to be grouped atomically. All modifications made within a transaction are isolated until committed. Other clients won’t see changes until the transaction is committed.

Parameters:

token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

bool if operation was successful

transaction_commit(token: str) bool[source]

Commits a transaction.

This performs validation and applies all accumulated transaction operations:

  1. Checks for conflicting external modifications. If any object was modified outside the transaction (mtime mismatch), the commit fails and all changes are discarded.

  2. Objects are removed in reverse dependency order (e.g. Profile - Distro)

  3. Objects are added/modified in dependency order (e.g. Distro - Profile)

  4. Rebuilds the PXE configuration once at the end

Parameters:

token – The API-token obtained via the login() method. The API-token obtained via the login() method.

Returns:

bool if operation was successful

upload_log_data(sys_name: str, file: str, size: int, offset: int, data: Binary, token: str | None = None) bool[source]

This is a logger function used by the “anamon” logging system to upload all sorts of misc data from Anaconda. As it’s a bit of a potential log-flooder, it’s off by default and needs to be enabled in our settings.

Parameters:
  • sys_name – The name of the system for which to upload log data.

  • file – The file where the log data should be put.

  • size – The size of the data which will be received.

  • offset – The offset in the file where the data will be written to.

  • data – The data that should be logged.

  • token – The API-token obtained via the login() method.

Returns:

True if everything succeeded.

version(token: str | None = None, **rest: Any)[source]

Return the Cobbler version for compatibility testing with remote applications. See api.py for documentation.

Parameters:
  • token – The API-token obtained via the login() method.

  • rest – This is dropped in this method since it is not needed here.

Returns:

The short version of Cobbler.

xmlrpc_hacks(data: List[Any] | Dict[Any, Any] | int | str | float | None) List[Any] | Dict[Any, Any] | int | str | float[source]

Convert None in XMLRPC to just ‘~’ to make extra sure a client that can’t allow_none can deal with this.

ALSO: a weird hack ensuring that when dicts with integer keys (or other types) are transmitted with string keys.

Parameters:

data – The data to prepare for the XMLRPC response.

Returns:

The converted data.

class cobbler.remote.CobblerXMLRPCServer(args: Any)[source]

Bases: ThreadingMixIn, SimpleXMLRPCServer

This is the class for the main Cobbler XMLRPC Server. This class does not directly contain all XMLRPC methods. It just starts the server.

class cobbler.remote.ProxiedXMLRPCInterface(api: CobblerAPI, proxy_class: Type[Any])[source]

Bases: object

This interface allows proxying request through another class.

class cobbler.remote.RequestHandler(request, client_address, server)[source]

Bases: SimpleXMLRPCRequestHandler

Custom request handler class for our XML-RPC server. This provides custom headers to allow usage behind proxies.

do_OPTIONS() None[source]

Set the HTTP status code for all of our reponses that we send and set the custom headers.

end_headers() None[source]

Add custom headers to all of our responses.

class cobbler.remote.TransactionItemModifications(attribute: List[str], old_value: Any, new_value: Any)[source]

Bases: NamedTuple

This tuple is providing named access to a changelog of values that can be used to updated indicies later onwards.

attribute: List[str]

Alias for field number 0

new_value: Any

Alias for field number 2

old_value: Any

Alias for field number 1

class cobbler.remote.TransactionTuple(what: str, ref: InheritableItem, to_delete: bool, mtime: float, uid: str, item_modifications: List[TransactionItemModifications])[source]

Bases: NamedTuple

This tuple is providing named access to values that are saved for a single object inside a single transaction.

item_modifications: List[TransactionItemModifications]

Alias for field number 5

mtime: float

Alias for field number 3

ref: InheritableItem

Alias for field number 1

to_delete: bool

Alias for field number 2

uid: str

Alias for field number 4

what: str

Alias for field number 0

class cobbler.remote.UnsavedItemsTuple(time: float, item: BaseItem)[source]

Bases: NamedTuple

This tuple is providing named access to values that are not yet saved to the daemon of Cobbler.

item: BaseItem

Alias for field number 1

time: float

Alias for field number 0

7.13. cobbler.serializer module

Serializer code for Cobbler

class cobbler.serializer.Serializer(api: CobblerAPI)[source]

Bases: object

Serializer interface that is used to access data in Cobbler independent of the actual data source.

deserialize(collection: Collection[ITEM], topological: bool = True) None[source]

Load a collection from disk.

Parameters:
  • collection – The Cobbler collection to know the type of the item.

  • topological – Sort collection based on each items’ depth attribute in the list of collection items. This ensures properly ordered object loading from disk with objects having parent/child relationships, i.e. profiles/subprofiles. See cobbler/items/abstract/inheritable_item.py

deserialize_item(collection_type: str, uid: str) Dict[str, Any][source]

Load a collection item from disk.

Parameters:
  • collection_type – The collection type to deserialize.

  • uid – The collection item name to deserialize.

serialize(collection: Collection[ITEM]) None[source]

Save a collection to disk

Parameters:

collection – The collection to serialize.

serialize_delete(collection: Collection[ITEM], item: ITEM) None[source]

Delete a collection item from disk

Parameters:
  • collection – The Cobbler collection to know the type of the item.

  • item – The collection item to delete.

serialize_item(collection: Collection[ITEM], item: ITEM) None[source]

Save a collection item to disk

Parameters:
  • collection – The Cobbler collection to know the type of the item.

  • item – The collection item to serialize.

7.14. cobbler.services module

Mod Python service functions for Cobbler’s public interface (aka cool stuff that works with wget/curl)

Changelog:

Schema: From -> To

Current Schema: Please refer to the documentation visible of the individual methods.

V4.0.0 (unreleased)
  • No changes

V3.3.4 (unreleased)
  • No changes

V3.3.3
  • Removed:
    • look

V3.3.2
  • No changes

V3.3.1
  • No changes

V3.3.0
  • Added:
    • settings

  • Changed:
    • gpxe: Renamed to ipxe

V3.2.2
  • No changes

V3.2.1
  • No changes

V3.2.0
  • No changes

V3.1.2
  • No changes

V3.1.1
  • No changes

V3.1.0
  • No changes

V3.0.1
  • No changes

V3.0.0
  • Added:
    • autoinstall

    • find_autoinstall

V2.8.5
  • Inital tracking of changes.

class cobbler.services.CobblerSvc(server: str = '')[source]

Bases: object

Interesting mod python functions are all keyed off the parameter mode, which defaults to index. All options are passed as parameters into the function.

autodetect(**kwargs: str | int | List[str]) str[source]

This tries to autodect the system with the given information. If more than one candidate is found an error message is returned.

Parameters:

kwargs – The keys “REMOTE_MACS”, “REMOTE_ADDR” or “interfaces”.

Returns:

The name of the possible object or an error message.

autoinstall(profile: str | None = None, system: str | None = None, file: str = '', **kwargs: Any) str[source]

Generate automatic installation files.

Parameters:
  • profile – The name of the profile to generate the autoinstall for.

  • system – The name of the system to generate the autoinstall for.

  • kwargs – This parameter is unused.

Returns:

TODO

bootcfg(profile: str | None = None, system: str | None = None, **kwargs: Any) str[source]

Generate a boot.cfg config file. Used primarily for VMware ESXi.

Parameters:
  • profile

  • system

  • kwargs – This parameter is unused.

Returns:

events(user: str = '', **kwargs: Any) str[source]

If no user is given then all events are returned. Otherwise only event associated to a user are returned.

Parameters:
  • user – Filter the events for a given user.

  • kwargs – This parameter is unused.

Returns:

A JSON object which contains all events.

find_autoinstall(system: str | None = None, profile: str | None = None, **kwargs: str | int) str[source]

Find an autoinstallation for a system or a profile. If this is not known different parameters can be passed to kwargs to find it automatically. See “autodetect”.

Parameters:
  • system – The system to find the autoinstallation for,

  • profile – The profile to find the autoinstallation for.

  • kwargs – The metadata to find the autoinstallation automatically.

Returns:

The autoinstall script or error message.

index(**kwargs: Any) str[source]

Just a placeholder method as an entry point.

Parameters:

kwargs – This parameter is unused.

Returns:

“no mode specified”

ipxe(profile: str | None = None, image: str | None = None, system: str | None = None, mac: str | None = None, **kwargs: Any)[source]

Generates an iPXE configuration.

Parameters:
  • profile – A profile.

  • image – An image.

  • system – A system.

  • mac – A MAC address.

  • kwargs – This parameter is unused.

list(what: str = 'systems', **kwargs: Any) str[source]

Return a list of objects of a desired category. Defaults to “systems”.

Parameters:
  • what – May be “systems”, “profiles”, “distros”, “images”, “repos” or “menus”

  • kwargs – This parameter is unused.

Returns:

The list of object names.

nopxe(system: str | None = None, **kwargs: Any) str[source]

Disables the network boot for the given system.

Parameters:
  • system – The system to disable netboot for.

  • kwargs – This parameter is unused.

Returns:

A boolean status if the action succeed or not.

property remote: ServerProxy

Sets up the connection to the Cobbler XMLRPC server. This is the version that does not require a login.

script(profile: str | None = None, system: str | None = None, **kwargs: Any) str[source]

Generate a script based on snippets. Useful for post or late-action scripts where it’s difficult to embed the script in the response file.

Parameters:
  • profile – The profile to generate the script for.

  • system – The system to generate the script for.

  • kwargs – This may contain a parameter with the key “query_string” which has a key “script” which may be an array. The element from position zero is taken.

Returns:

The generated script.

settings(**kwargs: Any) str[source]

Get the application configuration.

Returns:

Settings object.

template(profile: str | None = None, system: str | None = None, path: str | None = None, **kwargs: Any) str[source]

Generate a templated file for the system. Either specify a profile OR a system.

Parameters:
  • profile – The profile to provide for the generation of the template.

  • system – The system to provide for the generation of the template.

  • path – The path to the template.

  • kwargs – This parameter is unused.

Returns:

The rendered template.

trig(mode: str = '?', profile: str | None = None, system: str | None = None, REMOTE_ADDR: str | None = None, **kwargs: Any) str[source]

Hook to call install triggers. Only valid for a profile OR a system.

Parameters:
  • mode – Can be “pre”, “post” or “firstboot”. Everything else is invalid.

  • profile – The profile object to run triggers for.

  • system – The system object to run triggers for.

  • REMOTE_ADDR – The ip if the remote system/profile.

  • kwargs – This parameter is unused.

Returns:

The return code of the action.

yum(profile: str | None = None, system: str | None = None, **kwargs: Any) str[source]

Generate a repo config. Either specify a profile OR a system.

Parameters:
  • profile – The profile to provide for the generation of the template.

  • system – The system to provide for the generation of the template.

  • kwargs – This parameter is unused.

Returns:

The generated repository config.

cobbler.services.VALUE_KEY = <object object>

Empty instance. A unique marker value used instead of None to differentiate between when a key should be used for a value and when ‘None’ is a valid entry in a dictionary.

cobbler.services.application(environ: Dict[str, Any], start_response: Callable[[str, List[Any]], None]) List[bytes][source]

UWSGI entrypoint for Gunicorn

Parameters:
  • environ

  • start_response

Returns:

7.15. cobbler.tftpgen module

Generate files provided by TFTP server based on Cobbler object tree. This is the code behind ‘cobbler sync’.

class cobbler.tftpgen.TFTPGen(api: CobblerAPI)[source]

Bases: object

Generate files provided by TFTP server

build_kernel(metadata: Dict[str, Any], system: System, profile: Profile, distro: Distro, image: Image | None = None, boot_loader: str = 'pxe')[source]

Generates kernel and initrd metadata.

Parameters:
  • metadata – Pass additional parameters to the ones being collected during the method.

  • system – The system to generate the pxe-file for.

  • profile – The profile to generate the pxe-file for.

  • distro – If you don’t ship an image, this is needed. Otherwise this just supplies information needed for the templates.

  • image – If you want to be able to deploy an image, supply this parameter.

  • boot_loader – Can be any of those returned by utils.get_supported_system_boot_loaders().

build_kernel_options(system: System | None, profile: Profile | None, distro: Distro | None, image: Image | None, arch: Archs) str[source]

Builds the full kernel options line.

Parameters:
  • system – The system to generate the kernel options for.

  • profile – Although the system contains the profile please specify it explicitly here.

  • distro – Although the profile contains the distribution please specify it explicitly here.

  • image – The image to generate the kernel options for.

  • arch – The processor architecture to generate the kernel options for.

Returns:

The generated kernel line options.

copy_bootloaders(dest: str) None[source]

Copy bootloaders to the configured tftpboot directory NOTE: we support different arch’s if defined in our settings file.

copy_images() None[source]

Like copy_distros except for images.

copy_single_distro_file(d_file: str, distro_dir: str, symlink_ok: bool) None[source]

Copy a single file (kernel/initrd) to distro’s images directory

Parameters:
  • d_file – distro’s kernel/initrd absolut or remote file path value

  • distro_dir – directory (typically in {www,tftp}/images) where to copy the file

  • symlink_ok – whethere it is ok to symlink the file. Typically false in case the file is used by daemons run in chroot environments (tftpd,..)

Raises:

FileNotFoundError – Raised in case no kernel was found.

copy_single_distro_files(distro: Distro, dirtree: str, symlink_ok: bool)[source]

Copy the files needed for a single distro.

Parameters:
  • distro – The distro to copy.

  • dirtree – This is the root where the images are located. The folder “images” gets automatically appended.

  • symlink_ok – If it is okay to use a symlink to link the destination to the source.

copy_single_image_files(img: Image)[source]

Copies an image to the images directory of Cobbler.

Parameters:

img – The image to copy.

copy_static_grub_files() None[source]

Copy the embedded, hardcoded GRUB configuration to the TFTP root. This method only writes files that don’t yet exist.

generate_bootcfg(what: str, name: str) str[source]

Generate a bootcfg for a system of profile.

Parameters:
  • what – The type for what the bootcfg is generated for. Must be “profile” or “system”.

  • name – The name of the item which the bootcfg should be generated for.

Returns:

The fully rendered bootcfg as a string.

generate_ipxe(what: str, name: str) str[source]

Generate the ipxe files.

Parameters:
  • what – Either “profile” or “system”. All other item types not valid.

  • name – The name of the profile or system.

Returns:

The rendered template.

generate_pxe_menu(path: Path, metadata: Dict[str, str | Dict[str, str]]) str | None[source]

Generate the requested menu file.

Parameters:
  • path – Path to the menu file.

  • metadata – Menu items and other metadata for the generator.

generate_script(what: str, objname: str, script_name: str) str[source]

Generate a script from a autoinstall script template for a given profile or system.

Parameters:
  • what – The type for what the bootcfg is generated for. Must be “profile” or “system”.

  • objname – The name of the item which the bootcfg should be generated for.

  • script_name – The name of the template which should be rendered for the system or profile.

Returns:

The fully rendered script as a string.

generate_system_file(system: System, path: Path, metadata: Dict[str, str | Dict[str, str]]) str | None[source]

Generate a single file for a system if the file is related to the system.

Parameters:
  • system – The system to generate the file for.

  • path – The path to the file.

  • metadata – Menu items and other metadata for the generator.

Returns:

The contents of the file or None if the system does not provide this file.

generate_tftp_file(path: Path, offset: int, size: int) Tuple[bytes, int][source]

Generate and return a file for a TFTP client.

Parameters:
  • path – Normalized absolute path to the file

  • offset – Offset of the requested chunk in the file

  • size – Size of the requested chunk in the file

Returns:

The requested chunk and the length of the whole file

get_images_menu(menu: Menu | None, metadata: Dict[str, Any], arch: Archs | None) None[source]

Generates profiles metadata for pxe, ipxe and grub.

Parameters:
  • menu – The menu for which boot files are generated. (Optional)

  • metadata – Pass additional parameters to the ones being collected during the method.

  • arch – The processor architecture to generate the menu items for. (Optional)

get_menu_items(arch: Archs | None = None) Dict[str, str | Dict[str, str]][source]

Generates menu items for pxe, ipxe and grub. Grub menu items are grouped into submenus by profile.

Parameters:

arch – The processor architecture to generate the menu items for. (Optional)

Returns:

A dictionary with the pxe, ipxe and grub menu items. It has the keys from utils.get_supported_system_boot_loaders().

get_menu_level(menu: Menu | None = None, arch: Archs | None = None) Dict[str, str | Dict[str, str]][source]

Generates menu items for submenus, pxe, ipxe and grub.

Parameters:
  • menu – The menu for which boot files are generated. (Optional)

  • arch – The processor architecture to generate the menu items for. (Optional)

Returns:

A dictionary with the pxe and grub menu items. It has the keys from utils.get_supported_system_boot_loaders().

get_profiles_menu(menu: Menu | None, metadata: Dict[str, Any], arch: Archs | None)[source]

Generates profiles metadata for pxe, ipxe and grub.

Parameters:
  • menu – The menu for which boot files are generated. (Optional)

  • metadata – Pass additional parameters to the ones being collected during the method.

  • arch – The processor architecture to generate the menu items for. (Optional)

get_submenus(menu: Menu | None, metadata: Dict[Any, Any], arch: Archs | None)[source]

Generates submenus metatdata for pxe, ipxe and grub.

Parameters:
  • menu – The menu for which boot files are generated. (Optional)

  • metadata – Pass additional parameters to the ones being collected during the method.

  • arch – The processor architecture to generate the menu items for. (Optional)

make_pxe_menu() Dict[str, str | Dict[str, str]][source]

Generates pxe, ipxe and grub boot menus.

write_all_system_files(system: System, menu_items: Dict[str, str | Dict[str, str]]) None[source]

Writes all files for tftp for a given system with the menu items handed to this method. The system must have a profile attached. Otherwise this method throws an error.

Directory structure and cleanup behaviour:

TFTP Directory/
    pxelinux.cfg/
        01-aa-bb-cc-dd-ee-ff
    grub/
        system/
            aa:bb:cc:dd:ee:ff
        system_link/
            <system_name>
Parameters:
  • system – The system to generate files for.

  • menu_items – The list of labels that are used for displaying the menu entry.

This method is also responsible for removing stale boot loader artefacts when support for PXE/GRUB is disabled or management is no longer supported for the system.

write_pxe_file(filename: str | None, system: System | None, profile: Profile | None, distro: Distro | None, arch: Archs | None, image: Image | None = None, metadata: Dict[str, str | Dict[str, str]] | None = None, bootloader_format: BootLoader = BootLoader.PXE) str[source]

Write a configuration file for the bootloader(s).

More system-specific configuration may come in later, if so that would appear inside the system object in api.py Can be used for different formats, “pxe” (default) and “grub”.

Parameters:
  • filename – If present this writes the output into the giving filename. If not present this method just returns the generated configuration.

  • system – If you supply a system there are other templates used then when using only a profile/image/ distro.

  • profile – The profile to generate the pxe-file for.

  • distro – If you don’t ship an image, this is needed. Otherwise, this just supplies information needed for the templates.

  • arch – The processor architecture to generate the pxefile for.

  • image – If you want to be able to deploy an image, supply this parameter.

  • metadata – Pass additional parameters to the ones being collected during the method.

  • bootloader_format – Can be any of those returned by utils.get_supported_system_boot_loaders().

Returns:

The generated file-content for the required item.

write_templates(obj: BootableItem, write_file: bool = False, path: str | None = None) Dict[str, str][source]

A semi-generic function that will take an object with a template_files dict {source:destiation}, and generate a rendered file. The write_file option allows for generating of the rendered output without actually creating any files.

Parameters:
  • obj – The object to write the template files for.

  • write_file – If the generated template should be written to the disk.

  • path – TODO: A useless parameter?

Returns:

A dict of the destination file names (after variable substitution is done) and the data in the file.

7.16. cobbler.validate module

Cobbler module that is related to validating data for other internal Cobbler modules.

cobbler.validate.hostname(dnsname: str, allow_trailing_dot: bool = False) str[source]

Validate the DNS name.

Parameters:
  • dnsname – Hostname or FQDN

  • allow_trailing_dot – If True, allows an optional trailing dot for absolute FQDNs

Returns:

Hostname or FQDN

Raises:

TypeError – If the Hostname/FQDN is not a string or in an invalid format.

cobbler.validate.ipv4_address(addr: str) str[source]

Validate an IPv4 address.

Parameters:

addr – IPv4 address

Returns:

IPv4 address

Raises:
  • TypeError – Raised if addr is not a string.

  • AddressValueError – Raised in case addr is not a valid IPv4 address.

  • NetmaskValueError – Raised in case addr is not a valid IPv4 netmask.

cobbler.validate.ipv4_netmask(addr: str) str[source]

Validate an IPv4 netmask.

Parameters:

addr – IPv4 netmask

Returns:

IPv4 netmask

Raises:
  • TypeError – Raised if addr is not a string.

  • AddressValueError – Raised in case addr is not a valid IPv4 address.

  • NetmaskValueError – Raised in case addr is not a valid IPv4 netmask.

cobbler.validate.ipv6_address(addr: str) str[source]

Validate an IPv6 address.

Parameters:

addr – IPv6 address

Returns:

The IPv6 address.

Raises:
  • TypeError – Raised if addr is not a string.

  • AddressValueError – Raised in case addr is not a valid IPv6 address.

cobbler.validate.mac_address(mac: str, for_item: bool = True) str[source]

Validate as an Ethernet MAC address.

Parameters:
  • mac – MAC address

  • for_item – If the check should be performed for an item or not.

Returns:

MAC address

Raises:
  • ValueError – Raised in case mac has an invalid format.

  • TypeError – Raised in case mac is not a string.

cobbler.validate.name_servers(nameservers: str | List[str], for_item: bool = True) str | List[str][source]

Validate nameservers IP addresses, works for IPv4 and IPv6

Parameters:
  • nameservers – string or list of nameserver addresses

  • for_item – enable/disable special handling for Item objects

Returns:

The list of valid nameservers.

Raises:
  • TypeError – Raised if nameservers is not a string or list.

  • AddressValueError – Raised in case nameservers is not a valid address.

Validate nameservers search domains.

Allows trailing dots to specify absolute FQDNs that should not have additional search domains appended by the resolver.

Parameters:
  • search – One or more search domains to validate.

  • for_item – enable/disable special handling for Item objects

Returns:

The list of valid nameservers.

Raises:

TypeError – Raised if search is not a string or list.

cobbler.validate.validate_autoinstall_script_name(name: str) bool[source]

This validates if the name given for the script is valid in the context of the API call made. It will be handed to tftpgen.py#generate_script in the end.

Parameters:

name – The name of the script. Will end up being a filename. May have an extension but should never be a path.

Returns:

If this is a valid script name or not.

cobbler.validate.validate_autoinstall_template_file_path(api: CobblerAPI, template_schema: TemplateSchema, template_language: str, autoinstall: str) bool[source]

Validate the automatic installation template’s relative file path.

Parameters:
  • api – The api to get the base template path.

  • autoinstall – automatic installation template relative file path

Returns:

If the template is a valid path or not.

cobbler.validate.validate_boot_remote_file(value: str) bool[source]

This validates if the passed value is a valid value for remote_boot_{kernel,initrd}.

Parameters:

value – Must be a valid URI starting with http or tftp. ftp is not supported and thus invalid.

Returns:

False in any case. If value is valid, True is returned.

cobbler.validate.validate_breed(breed: str) str[source]

This is a setter for the operating system breed.

Parameters:

breed – The os-breed which shall be set.

Raises:
cobbler.validate.validate_grub_remote_file(value: str) bool[source]

This validates if the passed value is a valid value for remote_grub_{kernel,initrd}.

Parameters:

value – Must be a valid grub formatted URI starting with http or tftp. ftp is not supported and thus invalid.

Returns:

False in any case. If value is valid, True is returned.

cobbler.validate.validate_obj_name(object_name: str) bool[source]

This validates the name of an object against the Cobbler specific object name schema.

Parameters:

object_name – The object name candidate.

Returns:

True in case it matches the RE_OBJECT_NAME regex, False in all other cases.

cobbler.validate.validate_obj_type(object_type: str) bool[source]

This validates the given object type against the available object types in Cobbler.

Parameters:

object_type – The str with the object type to validate.

Returns:

True in case it is one, False in all other cases.

cobbler.validate.validate_os_version(os_version: str, breed: str) str[source]

This is a setter for the operating system version of an object.

Parameters:
  • os_version – The version which shall be set.

  • breed – The breed to validate the os_version for.

cobbler.validate.validate_repos(repos: List[str] | str, api: CobblerAPI, bypass_check: bool = False) List[str] | str[source]

This is a setter for the repository.

Parameters:
  • repos – The repositories to set for the object.

  • api – The api to find the repos.

  • bypass_check – If the newly set repos should be checked for existence.

cobbler.validate.validate_serial_baud_rate(baud_rate: int | str | BaudRates) BaudRates[source]

The baud rate is very import that the communication between the two devices can be established correctly. This is the setter for this parameter. This effectively is the speed of the connection.

Parameters:

baud_rate – The baud rate to set.

Returns:

The validated baud rate.

cobbler.validate.validate_serial_device(value: str | int) int[source]

Set the serial device for an object.

Parameters:

value – The number of the serial device.

Returns:

The validated device number

cobbler.validate.validate_template(api: CobblerAPI, value: str | Template) str[source]

This validates the input for the validate setter against the database of templates.

Parameters:
  • api – The api to find the templates.

  • value – The input to verify and sanitize.

Returns:

The name of the template (if built-in one), the object UID or

cobbler.validate.validate_uuid(possible_uuid: str) bool[source]

Validate if the handed string is a valid UUIDv4 hex representation.

Parameters:

possible_uuid – The str with the UUID.

Returns:

True in case it is one, False otherwise.

cobbler.validate.validate_virt_auto_boot(value: str | bool | int) bool | str[source]

For Virt only. Specifies whether the VM should automatically boot upon host reboot 0 tells Koan not to auto_boot virtuals.

Parameters:

value – May be True or False.

cobbler.validate.validate_virt_bridge(vbridge: str) str[source]

The default bridge for all virtual interfaces under this profile.

Parameters:

vbridge – The bridgename to set for the object.

Raises:

TypeError – In case vbridge was not of type str.

cobbler.validate.validate_virt_cpus(num: str | int) int[source]

For Virt only. Set the number of virtual CPUs to give to the virtual machine. This is fed to virtinst RAW, so Cobbler will not yelp if you try to feed it 9999 CPUs. No formatting like 9,999 please :)

Zero means that the number of cores is inherited. Negative numbers are forbidden

Parameters:

num – The number of cpu cores. If you pass the magic inherit string it will be converted to 0.

cobbler.validate.validate_virt_file_size(num: str | int | float) str | float[source]

For Virt only: Specifies the size of the virt image in gigabytes. Older versions of koan (x<0.6.3) interpret 0 as “don’t care”. Newer versions (x>=0.6.4) interpret 0 as “no disks”

Parameters:

num – is a non-negative integer (0 means default). Can also be a comma seperated list – for usage with multiple disks (not working at the moment)

cobbler.validate.validate_virt_path(path: str, for_system: bool = False) str[source]

Virtual storage location suggestion, can be overriden by koan.

Parameters:
  • path – The path to the storage.

  • for_system – If this is set to True then the value is inherited from a profile.

cobbler.validate.validate_virt_pxe_boot(value: bool) bool[source]

For Virt only. Specifies whether the VM should use PXE for booting 0 tells Koan not to PXE boot virtuals

Parameters:

value – May be True or False.

Returns:

True or False

cobbler.validate.validate_virt_ram(value: int | str) str | int[source]

For Virt only. Specifies the size of the Virt RAM in MB.

Parameters:

value – 0 tells Koan to just choose a reasonable default.

Returns:

An integer in all cases, except when value is the magic inherit string.

7.17. cobbler.yumgen module

Builds out filesystem trees/data based on the object tree. This is the code behind ‘cobbler sync’.

class cobbler.yumgen.YumGen(api: CobblerAPI)[source]

Bases: object

YumGen is responsible for generating yum repository configuration blobs for target systems in Cobbler.

This class uses the Cobbler API to access system settings and templating utilities, and produces a complete yum configuration suitable for use by clients requesting repository information. It collects relevant repository sources, renders configuration files using templates, and handles missing sources gracefully by reporting errors in the output.

get_yum_config(obj: BaseItem, is_profile: bool) str[source]

Return one large yum repo config blob suitable for use by any target system that requests it.

Parameters:
  • obj – The object to generate the yumconfig for.

  • is_profile – If the requested object is a profile. (Parameter not used currently)

Returns:

The generated yumconfig or the errors.

7.18. Module contents

This is the main Cobbler module. It contains all code related to the Cobbler server and the CLI. External applications should only make use of the cobbler.api module.