9. cobbler package

9.1. Subpackages

9.2. Submodules

9.3. cobbler.api module

Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

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)[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, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True)[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.

add_file(ref, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True)[source]

Add a file 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.

add_image(ref, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True)[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.

add_item(what: str, ref, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True)[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.

add_menu(ref, check_for_duplicate_names=False, save=True, with_triggers: bool = True)[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.

add_mgmtclass(ref, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True)[source]

Add a management class 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.

add_package(ref, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True)[source]

Add a package 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.

add_profile(ref, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True)[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.

add_repo(ref, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True)[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.

add_system(ref, check_for_duplicate_names: bool = False, save: bool = True, with_triggers: bool = True)[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.

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=None, arg2=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()[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=None, systems=None, buildisodir: str = '', distro_name: str = '', standalone: bool = False, airgapped: bool = False, source: str = '', exclude_dns: bool = False, xorrisofs_opts: str = '')[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 – Used with --standalone and --airgapped to create a distro-based ISO including all associated.

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

  • xorrisofs_optsxorrisofs options to include additionally.

check() None | list[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:

None or a list of things to address.

clear_logs(system)[source]

Clears console and anamon logs for system

Parameters:

system – The system to clear logs of.

copy_distro(ref, newname: str)[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_file(ref, newname: str)[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_image(ref, newname: str)[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, newname: str)[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, newname: str)[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_mgmtclass(ref, newname: str)[source]

This method copies a management class 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_package(ref, newname: str)[source]

This method copies a package 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, newname: str)[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_repo(ref, newname: str)[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, newname: str)[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.

deserialize()[source]

Load cobbler_collections from disk. Cobbler internal use only.

distros()[source]

Return the current list of distributions

dump_vars(obj, formatted_output: bool = False, remove_dicts: bool = False)[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.

files()[source]

Return the current list of files

find_distro(name: str = '', return_list=False, no_errors=False, **kargs)[source]

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

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.

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

Returns:

A single object or a list of all search results.

find_file(name: str = '', return_list=False, no_errors=False, **kargs)[source]

Find a file via a name or keys specified in the **kargs.

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.

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

Returns:

A single object or a list of all search results.

find_image(name: str = '', return_list=False, no_errors=False, **kargs)[source]

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

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.

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

Returns:

A single object or a list of all search results.

find_items(what: str = '', criteria: dict = None, name: str = '', return_list: bool = True, no_errors: bool = False)[source]

This is the abstract base method for finding object int the api. It should not be used by external resources. Please reefer 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.

  • name – The name of the object.

  • 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(name: str = '', return_list=False, no_errors=False, **kargs)[source]

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

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.

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

Returns:

A single object or a list of all search results.

find_mgmtclass(name: str = '', return_list=False, no_errors=False, **kargs)[source]

Find a management class via a name or keys specified in the **kargs.

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.

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

Returns:

A single object or a list of all search results.

find_package(name: str = '', return_list=False, no_errors=False, **kargs)[source]

Find a package via a name or keys specified in the **kargs.

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.

  • kargs – 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(name: str = '', return_list=False, no_errors=False, **kargs)[source]

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

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.

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

Returns:

A single object or a list of all search results.

find_repo(name: str = '', return_list=False, no_errors=False, **kargs)[source]

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

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.

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

Returns:

A single object or a list of all search results.

find_system(name: str = '', return_list=False, no_errors=False, **kargs)[source]

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

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.

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

Returns:

A single object or a list of all search results.

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_script(profile: str | None, system: str | None, name: 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_distros_since(mtime: float, collapse: bool = False)[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_files_since(mtime: float, collapse: bool = False) list[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_images_since(mtime: float, collapse: bool = False) list[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)[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: str)[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. :param item_uuid: The UUID of the item that should be retrieved. :param attribute: The attribute that should be retrieved. :raises ValueError: In case a value given was either malformed or the desired item did not exist. :raises TypeError: In case the type of the method arguments do have the wrong type. :raises 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)[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=False) list[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_mgmtclasses_since(mtime: float, collapse: bool = False) list[source]

Return management classes 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 management classes which are newer then the given timestamp.

get_module_by_name(module_name: str)[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)[source]

Looks in /etc/cobbler/modules.conf 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

  • name

  • fallback

Returns:

get_module_name_from_file(section: str, name: str, fallback: str | None = None)[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)[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_packages_since(mtime: float, collapse: bool = False) list[source]

Return packages 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 packages which are newer then the given timestamp.

get_profiles_since(mtime: float, collapse: bool = False) list[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) 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) 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[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.

get_signatures() dict[source]

This returns the local signature cache.

Returns:

The dict containing all signatures.

get_sync(verbose: bool = False)[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_systems_since(mtime: float, collapse: bool = False) list[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, path) 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, path)[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_valid_obj_boot_loaders(obj) List[str][source]

Return the list of valid boot loaders for the object

Parameters:

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

Returns:

Get a list of all valid boot loaders.

Hardlink all files where this is possible to improve performance.

Returns:

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

images()[source]

Return the current list of images

import_tree(mirror_url: str, mirror_name: str, network_root=None, autoinstall_file=None, rsync_flags=None, arch=None, breed=None, os_version=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

  • autoinstall_file

  • rsync_flags

  • arch

  • breed

  • os_version

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=None, debug: bool = False)[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()[source]

Return the current list of menus

mgmtclasses()[source]

Return the current list of mgmtclasses

mkloaders()[source]

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

new_distro(is_subobject: bool = False)[source]

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

Parameters:

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

Returns:

An empty Distro object.

new_file(is_subobject: bool = False)[source]

Returns a new empty file 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 File object.

new_image(is_subobject: bool = False)[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_menu(is_subobject: bool = False)[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 File object.

new_mgmtclass(is_subobject: bool = False)[source]

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

Parameters:

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

Returns:

An empty mgmtclass object.

new_package(is_subobject: bool = False)[source]

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

Parameters:

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

Returns:

An empty Package object.

new_profile(is_subobject: bool = False)[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_repo(is_subobject: bool = False)[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)[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.

packages()[source]

Return the current list of packages

power_system(system: str, power_operation: str, user: str | None = None, password: str | None = 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

profiles()[source]

Return the current list of profiles

remove_distro(ref, recursive: bool = False, delete: bool = True, with_triggers: bool = True)[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 – Not known what this parameter does exactly.

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

remove_file(ref, recursive: bool = False, delete: bool = True, with_triggers: bool = True)[source]

Remove a file from Cobbler.

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

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

  • delete – Not known what this parameter does exactly.

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

remove_image(ref, recursive: bool = False, delete: bool = True, with_triggers: bool = True)[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 – Not known what this parameter does exactly.

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

remove_item(what: str, ref, recursive: bool = False, delete: bool = True, with_triggers: bool = True)[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 – Not known what this parameter does exactly.

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

remove_menu(ref, recursive=False, delete=True, with_triggers=True)[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 – Not known what this parameter does exactly.

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

remove_mgmtclass(ref, recursive: bool = False, delete: bool = True, with_triggers: bool = True)[source]

Remove a management class from Cobbler.

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

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

  • delete – Not known what this parameter does exactly.

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

remove_package(ref, recursive: bool = False, delete: bool = True, with_triggers: bool = True)[source]

Remove a package from Cobbler.

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

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

  • delete – Not known what this parameter does exactly.

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

remove_profile(ref, recursive: bool = False, delete: bool = True, with_triggers: bool = True)[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 – Not known what this parameter does exactly.

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

remove_repo(ref, recursive: bool = False, delete: bool = True, with_triggers: bool = True)[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 – Not known what this parameter does exactly.

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

remove_system(ref, recursive: bool = False, delete: bool = True, with_triggers: bool = True)[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 – Not known what this parameter does exactly.

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

rename_distro(ref, newname: str)[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_file(ref, newname: str)[source]

Rename a file to a new name.

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

  • newname – The new name for the item.

rename_image(ref, newname: str)[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, newname: str)[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, newname: str)[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_mgmtclass(ref, newname: str)[source]

Rename a management class to a new name.

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

  • newname – The new name for the item.

rename_package(ref, newname: str)[source]

Rename a package to a new name.

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

  • newname – The new name for the item.

rename_profile(ref, newname: str)[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_repo(ref, newname: str)[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, newname: str)[source]

Rename a system 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 = '', mgmtclass_patterns=None, package_patterns=None, file_patterns: bool = False, prune: bool = False, omit_data: bool = False, sync_all: bool = False, use_ssl: bool = False)[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.

  • mgmtclass_patterns – The pattern of management classes which should be synced.

  • package_patterns – The pattern of packages which should be synced.

  • file_patterns – The pattern of files 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).

report(report_what: str | None = None, report_name: str | None = None, report_type: str | None = None, report_fields: str | None = None, report_noheaders: bool | None = None)[source]

Report functionality for Cobbler.

Parameters:
  • report_what – The object type that should be reported.

  • report_name – The name of the object which should be possibly reported.

  • report_type – May be either “text”, “csv”, “mediawiki”, “trac” or “doku”.

  • report_fields – Specify “all” or the fields you want to be reported.

  • report_noheaders – If the column headers should be included in the output or not.

repos()[source]

Return the current list of repos

reposync(name: str | None = None, tries: int = 1, nofail: bool = False)[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()[source]

Save the cobbler_collections to disk. Cobbler internal use only.

set_item_resolved_value(item_uuid: str, attribute: str, value)[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 – 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()[source]

Return the application configuration

signature_update()[source]

Update all signatures from the URL specified in the settings.

status(mode: 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 | 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()[source]

Only build out the DHCP configuration.

sync_dns()[source]

Only build out the DNS configuration.

sync_systems(systems: List[str], verbose: bool = False)[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.

systems()[source]

Return the current list of systems

validate_autoinstall_files()[source]

Validate if any of the autoinstallation files are invalid and if yes report this.

version(extended: bool = False) float | Dict[str, str | list][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.

9.4. cobbler.autoinstall_manager module

This module contains code in order to create the automatic installation files. For example kickstarts, autoyast files or preseed files.

class cobbler.autoinstall_manager.AutoInstallationManager(api)[source]

Bases: object

Manage automatic installation templates, snippets and final files

generate_autoinstall(profile=None, system=None) str[source]

Generates the autoinstallation for a system or a profile. You may only specifify one parameter. If you specify both, the system is generated and the profile argument is ignored.

Parameters:
  • profile – The Cobbler profile you want an autoinstallation generated for.

  • system – The Cobbler system you want an autoinstallation generated for.

Returns:

The rendered template for the system or profile.

get_autoinstall_snippets() list[source]

Get a list of all autoinstallation snippets.

Returns:

The list of snippets

get_autoinstall_templates() list[source]

Get automatic OS installation templates

Returns:

A list of automatic installation templates

is_autoinstall_in_use(name: str) bool[source]

Reports the status if a given system is currently being provisioned.

Parameters:

name – The name of the system.

Returns:

Whether the system is in install mode or not.

log_autoinstall_validation_errors(errors_type: int, errors: list)[source]

Log automatic installation file errors

Parameters:
  • errors_type – validation errors type

  • errors – A list with all the errors which occurred.

read_autoinstall_snippet(file_path: str) str[source]

Reads a autoinstall snippet from underneath the configured snippet base dir.

Parameters:

file_path – The relative file path under the configured snippets base dir.

Returns:

The read snippet.

read_autoinstall_template(file_path: str) str[source]

Read an automatic OS installation template

Parameters:

file_path – automatic installation template relative file path

Returns:

automatic installation template content

remove_autoinstall_snippet(file_path: str) bool[source]

Remove the autoinstall snippet with the given path.

Parameters:

file_path – The path relative to the configured snippet root.

Returns:

A boolean indicating the success of the task.

remove_autoinstall_template(file_path: str)[source]

Remove an automatic OS installation template

Parameters:

file_path – automatic installation template relative file path

validate_autoinstall_file(obj, is_profile: bool) list[source]

Validate automatic installation file used by a system/profile.

Parameters:
  • obj – system/profile

  • is_profile – if obj is a profile

Returns:

[bool, int, list] list with validation result, errors type and list of errors

validate_autoinstall_files() bool[source]

Determine if Cobbler automatic OS installation files will be accepted by corresponding Linux distribution installers. The presence of an error does not imply that the automatic installation file is bad, only that the possibility exists. Automatic installation file validators are not available for all automatic installation file types and on all operating systems in which Cobbler may be installed.

Returns:

True if all automatic installation files are valid, otherwise false.

validate_autoinstall_snippet_file_path(snippet: str, new_snippet: bool = False) str[source]

Validate the snippet’s relative file path.

Parameters:
  • snippet – automatic installation snippet relative file path

  • new_snippet – when set to true new filenames are allowed

Returns:

Snippet if successful otherwise raises an exception.

Raises:
  • TypeError – Raised in case snippet is not a string.

  • ValueError – Raised in case snippet file is invalid.

  • OSError – Raised in case snippet file location is not found.

validate_autoinstall_template_file_path(autoinstall: str, for_item: bool = True, new_autoinstall: bool = False) str[source]

Validate the automatic installation template’s relative file path.

Parameters:
  • autoinstall – automatic installation template relative file path

  • for_item – enable/disable special handling for Item objects

  • new_autoinstall – when set to true new filenames are allowed

Returns:

automatic installation template relative file path

Raises:
  • TypeError – Raised in case autoinstall is not a string.

  • OSError – Raised in case template file not found.

  • ValueError – Raised in case template file is invalid.

write_autoinstall_snippet(file_path: str, data: str)[source]

Writes a snippet with the given content to the relative path under the snippet root directory.

Parameters:
  • file_path – The relative path under the configured snippet base dir.

  • data – The snippet code.

write_autoinstall_template(file_path: str, data: str) bool[source]

Write an automatic OS installation template

Parameters:
  • file_path – automatic installation template relative file path

  • data – automatic installation template content

9.5. cobbler.autoinstallgen module

Builds out filesystem trees/data based on the object tree. This is the code behind ‘cobbler sync’.

Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

class cobbler.autoinstallgen.AutoInstallationGen(api)[source]

Bases: object

Handles conversion of internal state to the tftpboot tree layout

addAutoYaSTScript(document, type, source)[source]

Add scripts to an existing AutoYaST XML.

Parameters:
  • document – The existing AutoYaST XML object.

  • type – The type of the script which should be added.

  • source – The source of the script. This should be ideally a string.

createAutoYaSTScript(document, script, name)[source]

This method attaches a script with a given name to an existing AutoYaST XML file.

Parameters:
  • document – The existing AutoYaST XML file.

  • script – The script to attach.

  • name – The name of the script.

Returns:

The AutoYaST file with the attached script.

generate_autoinstall(profile=None, system=None) str[source]

This is an internal method for generating an autoinstall config/script. Please use the generate_autoinstall_for_* methods. If you insist on using this mehtod please only supply a profile or a system, not both.

Parameters:
  • profile – The profile to use for generating the autoinstall config/script.

  • system – The system to use for generating the autoinstall config/script. If both arguments are given, this wins.

Returns:

The autoinstall script or configuration file as a string.

generate_autoinstall_for_profile(g) str[source]

Generate an autoinstall config or script for a profile.

Parameters:

g – The Profile to generate the script/config for.

Returns:

The generated output or an error message with a human readable description.

Raises:

CX – Raised in case the profile references a missing distro.

generate_autoinstall_for_system(sys_name) str[source]

Generate an autoinstall config or script for a system.

Parameters:

sys_name – The system name to generate an autoinstall script for.

Returns:

The generated output or an error message with a human readable description.

Raises:

CX – Raised in case the system references a missing profile.

generate_autoyast(profile=None, system=None, raw_data=None) str[source]

Generate auto installation information for SUSE distribution (AutoYaST XML file) for a specific system or general profile. Only a system OR profile can be supplied, NOT both.

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

  • system – The system to generate the AutoYaST file for.

  • raw_data – The raw data which should be included in the profile.

Returns:

The generated AutoYaST XML file.

generate_config_stanza(obj, is_profile: bool = True)[source]

Add in automatic to configure /etc/yum.repos.d on the remote system if the automatic installation file (template file) contains the magic $yum_config_stanza.

Parameters:
  • obj – The profile or system to generate a generate a config stanza for.

  • is_profile – If the object is a profile. If False it is assumed that the object is a system.

Returns:

The curl command to execute to get the configuration for a system or profile.

generate_repo_stanza(obj, is_profile: bool = True) str[source]

Automatically attaches yum repos to profiles/systems in automatic installation files (template files) that contain the magic $yum_repo_stanza variable. This includes repo objects as well as the yum repos that are part of split tree installs, whose data is stored with the distro (example: RHEL5 imports)

Parameters:
  • obj – The profile or system to generate the repo stanza for.

  • is_profile – If True then obj is a profile, otherwise obj has to be a system. Otherwise this method will silently fail.

Returns:

The string with the attached yum repos.

get_last_errors() list[source]

Returns the list of errors generated by the last template render action.

Returns:

The list of error messages which are available. This may not only contain error messages related to generating autoinstallation configuration and scripts.

9.6. cobbler.cexceptions module

Custom exceptions for Cobbler

Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

exception cobbler.cexceptions.CX(value, *args)[source]

Bases: CobblerException

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

exception cobbler.cexceptions.CobblerException(value, *args)[source]

Bases: Exception

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

9.7. cobbler.cli module

Command line interface for Cobbler.

Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

class cobbler.cli.CobblerCLI(cliargs)[source]

Bases: object

Main CLI Class which contains the logic to communicate with the Cobbler Server.

check_setup() int[source]

Detect permissions and service accessibility problems and provide nicer error messages for them.

cleanup_fault_string(fault_str: str) str[source]

Make a remote exception nicely readable by humans so it’s not evident that is a remote fault. Users should not have to understand tracebacks.

Parameters:

fault_str – The stacktrace to niceify.

Returns:

A nicer error messsage.

direct_command(action_name: str)[source]

Process non-object based commands like “sync” and “hardlink”.

Parameters:

action_name – The action to execute.

Returns:

Depending on the action.

follow_task(task_id)[source]

Parse out this task’s specific messages from the global log

Parameters:

task_id – The id of the task to follow.

get_direct_action(object_type, args) str | None[source]

If this is a general command, e.g. “cobbler hardlink”, return the action, like “hardlink”

Parameters:
  • object_type – Must be None or None is returned.

  • args – The arg from the CLI.

Returns:

The action key, “version” or None.

get_fields(object_type: str) list[source]

For a given name of an object type, return the FIELDS data structure.

Parameters:

object_type – The object to return the fields of.

Returns:

The fields or None

get_object_action(object_type, args) str | None[source]

If this is a CLI command about an object type, e.g. “cobbler distro add”, return the action, like “add”

Parameters:
  • object_type – The object type.

  • args – The args from the CLI.

Returns:

The action or None.

get_object_type(args) str | None[source]

If this is a CLI command about an object type, e.g. “cobbler distro add”, return the type, like “distro”

Parameters:

args – The args from the CLI.

Returns:

The object type or None

object_command(object_type: str, object_action: str) int[source]

Process object-based commands such as “distro add” or “profile rename”

Parameters:
  • object_type – The object type to execute an action for.

  • object_action – The action to execute.

Returns:

Depending on the object and action.

Raises:
print_help() int[source]

Prints general-top level help, e.g. “cobbler –help” or “cobbler” or “cobbler command-does-not-exist”

print_object_help(object_type) int[source]

Prints the subcommands for a given object, e.g. “cobbler distro –help”

Parameters:

object_type – The object type to print the help for.

print_task(task_id)[source]

Pretty print a task executed on the server. This prints to stdout.

Parameters:

task_id – The id of the task to be pretty printed.

run(args) int[source]

Process the command line and do what the user asks.

Parameters:

args – The args of the CLI

start_task(name: str, options: dict) str[source]

Start an asynchronous task in the background.

Parameters:
  • name – “background_” % name function must exist in remote.py. This function will be called in a subthread.

  • options – Dictionary of options passed to the newly started thread

Returns:

Id of the newly started task

cobbler.cli.add_options_from_fields(object_type, parser, fields, network_interface_fields, settings, object_action)[source]

Add options to the command line from the fields queried from the Cobbler server.

Parameters:
  • object_type – The object type to add options for.

  • parser – The optparse instance to add options to.

  • fields – The list of fields to add options for.

  • network_interface_fields – The list of network interface fields if the object type is a system.

  • settings – Global cobbler settings as returned from CollectionManager.settings()

  • object_action – The object action to add options for. May be “add”, “edit”, “find”, “copy”, “rename”, “remove”. If none of these options is given then this method does nothing.

cobbler.cli.get_comma_separated_args(option: Option, opt_str, value: str, parser: OptionParser)[source]

Simple callback function to achieve option split with comma.

Reference for the method signature can be found at:

https://docs.python.org/3/library/optparse.html#defining-a-callback-option

Parameters:
  • option – The option the callback is executed for

  • opt_str – Unused for this callback function. Would be the extended option if the user used the short version.

  • value – The value which should be split by comma.

  • parser – The optparse instance which the callback should be added to.

cobbler.cli.list_items(remote, otype)[source]

List all items of a given object type and print it to stdout.

Parameters:
  • remote – The remote to use as the query-source.

  • otype – The object type to query.

cobbler.cli.main() int[source]

CLI entry point

cobbler.cli.n2s(data)[source]

Return spaces for None

Parameters:

data – The data to check for.

Returns:

The data itself or an empty string.

cobbler.cli.opt(options, k, defval='')[source]

Returns an option from an Optparse values instance

Parameters:
  • options – The options object to search in.

  • k – The key which is in the optparse values instance.

  • defval – The default value to return.

Returns:

The value for the specified key.

cobbler.cli.report_item(remote, otype: str, item=None, name=None)[source]

Return a single item in a given collection. Either this is an item object or this method searches for a name.

Parameters:
  • remote – The remote to use as the query-source.

  • otype – The object type to query.

  • item – The item to display

  • name – The name to search for and display.

cobbler.cli.report_items(remote, otype: str)[source]

Return all items for a given collection.

Parameters:
  • remote – The remote to use as the query-source. The remote to use as the query-source.

  • otype – The object type to query.

cobbler.cli.report_single_breed(name: str, items: dict) int[source]

Helper function which prints a single signature breed list to the terminal.

cobbler.cli.to_string_from_fields(item_dict, fields, interface_fields=None) str[source]

item_dict is a dictionary, fields is something like item_distro.FIELDS :param item_dict: The dictionary representation of a Cobbler item. :param fields: This is the list of fields a Cobbler item has. :param interface_fields: This is the list of fields from a network interface of a system. This is optional. :return: The string representation of a Cobbler item with all its values.

9.8. cobbler.cobblerd module

Cobbler daemon for logging remote syslog traffic during automatic installation

Copyright 2007-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

cobbler.cobblerd.core(cobbler_api: CobblerAPI)[source]

Starts Cobbler.

Parameters:

cobbler_api – The cobbler_api instance which is used for this method.

cobbler.cobblerd.do_xmlrpc_rw(cobbler_api: CobblerAPI, port)[source]

This trys to bring up the Cobbler xmlrpc_api and restart it if it fails.

Parameters:
  • cobbler_api – The cobbler_api instance which is used for this method.

  • port – The port where the xmlrpc api should run on.

cobbler.cobblerd.regen_ss_file()[source]

This is only used for Kerberos auth at the moment. It identifies XMLRPC requests from Apache that have already been cleared by Kerberos.

9.9. cobbler.configgen module

configgen.py: Generate configuration data.

Copyright 2010 Kelsey Hightower Kelsey Hightower <kelsey.hightower@gmail.com>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

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

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

Bases: object

Generate configuration data for Cobbler’s management resources: repos, files and packages. Mainly used by Koan to configure systems.

gen_config_data() dict[source]

Generate configuration data for repos, files and packages.

Returns:

A dict which has all config data in it.

Raises:

CX – In case the package or file resource is not defined.

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 | str | dict[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: 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.

9.10. cobbler.download_manager module

Cobbler DownloadManager

Copyright 2018, Jorgen Maas <jorgen.maas@gmail.com>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

class cobbler.download_manager.DownloadManager[source]

Bases: object

download_file(url, dst, proxies=None, cert=None)[source]

Donwload a file from a URL and save it to any disc location.

Parameters:
  • url – The URL the request.

  • dst – The destination file path.

  • proxies – Override the default Cobbler proxies.

  • cert – Override the default Cobbler certs.

urlread(url, proxies=None, cert=None)[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.

9.11. 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, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[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.BaudRates(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[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.ConvertableEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[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.ImageTypes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[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.MirrorType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: ConvertableEnum

This enum represents all mirror types which Cobbler can manage.

BASEURL = 'baseurl'
MIRRORLIST = 'mirrorlist'
class cobbler.enums.NetworkInterfaceType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

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

BMC = 6
BOND = 1
BONDED_BRIDGE_SLAVE = 5
BOND_SLAVE = 2
BRIDGE = 3
BRIDGE_SLAVE = 4
INFINIBAND = 7
NA = 0
class cobbler.enums.RepoArchs(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[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, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[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, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: ConvertableEnum

This enum represents all actions a resource may execute.

CREATE = 'create'
REMOVE = 'remove'
class cobbler.enums.TlsRequireCert(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[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, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[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, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[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'

9.12. cobbler.grub module

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

9.13. cobbler.manager module

Base class for modules.managers.* classes

Copyright 2021 SUSE LLC Thomas Renninger <trenn@suse.de>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

class cobbler.manager.ManagerModule(api)[source]

Bases: object

Base class for Manager modules located in modules/manager/*.py

These are typically but not necessarily used to manage systemd services. Enabling can be done via settings manage_* (e.g. manage_dhcp) and restart_* (e.g. restart_dhcp). Different modules could manage the same functionality as dhcp can be managed via isc.py or dnsmasq.py (compare with /etc/cobbler/modules.py).

regen_ethers()[source]

ISC/BIND doesn’t use this. It is there for compatibility reasons with other managers.

restart_service() int[source]

Write module specific config files. E.g. dhcp manager would write /etc/dhcpd.conf here

sync() int[source]

This syncs the manager’s server (systemd service) with it’s new config files. Basically this restarts the service to apply the changes.

Returns:

Integer return value of restart_service - 0 on success

static what()[source]

Static method to identify the manager module. Must be overwritten by the inheriting class

write_configs()[source]

Write module specific config files. E.g. dhcp manager would write /etc/dhcpd.conf here

9.14. cobbler.module_loader module

Module loader, adapted for Cobbler usage

Copyright 2006-2009, Red Hat, Inc and Others Adrian Likins <alikins@redhat.com> Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

cobbler.module_loader.get_module_by_name(name: str)[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.

cobbler.module_loader.get_module_from_file(category: str, field: str, fallback_module_name: str | None = None)[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.

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

Get module name from configuration file (currently hardcoded /etc/cobbler/modules.conf).

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.

cobbler.module_loader.get_modules_in_category(category: str) list[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.

cobbler.module_loader.load_modules(module_path: str = '/home/docs/checkouts/readthedocs.org/user_builds/cobbler/checkouts/v3.3.4/cobbler/modules')[source]

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

Parameters:

module_path – The path which should be considered as the root module path.

Returns:

Two dictionary’s with the dynamically loaded modules.

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

Copyright 2008-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

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

Bases: object

Handles power management in systems

get_power_status(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, user: str | None = None, password: str | 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, user: str | None = None, password: str | 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, user: str | None = None, password: str | 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[source]

Get possible power management types.

Returns:

Possible power management types

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

Check if a power management type is valid.

Parameters:

power_type – Power management type.

Raises:

CX – if power management type is invalid

9.16. cobbler.remote module

Copyright 2007-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

class cobbler.remote.CobblerThread(event_id, remote, options: dict, task_name: str, api)[source]

Bases: Thread

Code for Cobbler’s XMLRPC API.

on_done()[source]

This stub is needed to satisfy the Python inheritance chain.

run()[source]

Run the thread.

Returns:

The return code of the action. This may possibly a boolean or a Linux return code.

class cobbler.remote.CobblerXMLRPCInterface(api)[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, 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, 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, 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_mkloaders(options: dict, token: str) str[source]
background_power_system(options: dict, 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, 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, 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_update(options: dict, 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, 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, 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_validate_autoinstall_files(options: dict, 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) None | list[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:

None or a list of things to address.

check_access(token: str, resource: str, arg1=None, arg2=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, resource, arg1=None, arg2=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)[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=None)[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_file(object_id, newname, token=None)[source]

Copies a file 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_image(object_id, newname, token=None)[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)[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, newname, token=None)[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_mgmtclass(object_id, newname, token=None)[source]

Copies a management class 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_package(object_id, newname, token=None)[source]

Copies a package 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, newname, token=None)[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_repo(object_id, newname, token=None)[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, newname, token=None)[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.

disable_netboot(name, token=None, **rest) 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=None, **rest)[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 | None = None, expand=False, token=None, **rest)[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.

  • 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_file(criteria: dict | None = None, expand=False, token=None, **rest)[source]

Find a file 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.

  • 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_image(criteria: dict | None = None, expand=False, token=None, **rest)[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.

  • 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 | None = None, sort_field=None, expand: bool = True) list[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.

Returns:

A list of dicts.

find_items_paged(what: str, criteria: dict | None = None, sort_field: str | None = None, page=1, items_per_page=25, 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.

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

Returns:

The found items.

find_menu(criteria: dict | None = None, expand=False, token=None, **rest)[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.

  • 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_mgmtclass(criteria: dict | None = None, expand=False, token=None, **rest)[source]

Find a management class 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.

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

  • rest – This parameter is not used currently.

Returns:

All management classes which have matched the criteria.

find_package(criteria: dict | None = None, expand=False, token=None, **rest)[source]

Find a package 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.

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

  • rest – This parameter is not used currently.

Returns:

All packages which have matched the criteria.

find_profile(criteria: dict | None = None, expand=False, token=None, **rest)[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.

  • 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_repo(criteria: dict | None = None, expand=False, token=None, **rest)[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.

  • 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 | None = None, expand=False, token=None, **rest)[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.

  • 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)[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.

generate_autoinstall(profile=None, system=None, REMOTE_ADDR=None, REMOTE_MAC=None, **rest)[source]

Generate the autoinstallation file and return it.

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

  • system – The system to generate the file for.

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

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

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

Returns:

The str representation of the file.

generate_bootcfg(profile: str = None, system: str = None, **rest) 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=None, image=None, system=None, **rest) 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_profile_autoinstall(profile)[source]

Generate a profile autoinstallation.

Parameters:

profile – The profile to generate the file for.

Returns:

The str representation of the file.

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.

generate_system_autoinstall(system)[source]

Generate a system autoinstallation.

Parameters:

system – The system to generate the file for.

Returns:

The str representation of the file.

get_authn_module_name(token: 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_autoinstall_snippets(token=None, **rest)[source]

Returns all the automatic OS installation templates’ snippets.

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

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

Returns:

A list with all snippets.

get_autoinstall_templates(token=None, **rest)[source]

Returns all of the automatic OS installation templates that are in use by the system.

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

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

Returns:

A list with all templates.

get_blended_data(profile=None, system=None)[source]

Combine all data which is available from a profile and system together and return it.

Deprecated since version 3.4.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=False, resolved: bool = False, token=None, **rest)[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, **rest)[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_handle(name: str, token: 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.

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

Returns:

The handle of the desired object.

get_distros(page=None, results_per_page=None, token=None, **rest)[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)[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[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_file(name: str, flatten=False, resolved: bool = False, token=None, **rest)[source]

Get a file.

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_file_as_rendered(name: str, token: str = None, **rest)[source]

Get file after passing through Cobbler’s inheritance engine

Parameters:
  • name – file 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_file_handle(name: str, token: str)[source]

Get a handle for a file which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:
  • name – The name of the item.

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

Returns:

The handle of the desired object.

get_files(page=None, results_per_page=None, token=None, **rest)[source]

This returns all files.

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_files_since(mtime: 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_image(name: str, flatten=False, resolved: bool = False, token=None, **rest)[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, **rest)[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, token: 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.

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

Returns:

The handle of the desired object.

get_images(page=None, results_per_page=None, token=None, **rest)[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)[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=False, resolved: bool = False)[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=None)[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.

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

Returns:

The handle of the desired object.

get_item_names(what: 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: str)[source]

See also

Logically identical to get_item_resolved_value()

get_items(what: str)[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=None, **rest)[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)[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, token: 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.

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

Returns:

The handle of the desired object.

get_menus(page=None, results_per_page=None, token=None, **rest)[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)[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_mgmtclass(name: str, flatten=False, resolved: bool = False, token=None, **rest)[source]

Get a management class.

Parameters:
  • name – The name of the management class 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_mgmtclass_as_rendered(name: str, token: str = None, **rest)[source]

Get management class after passing through Cobbler’s inheritance engine

Parameters:
  • name – management class name

  • token – authentication token

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

Returns:

Get a template rendered as a management class.

get_mgmtclass_handle(name: str, token: str)[source]

Get a handle for a management class which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:
  • name – The name of the item.

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

Returns:

The handle of the desired object.

get_mgmtclasses(page=None, results_per_page=None, token=None, **rest)[source]

This returns all managementclasses.

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

get_mgmtclasses_since(mtime: 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_package(name: str, flatten=False, resolved: bool = False, token=None, **rest)[source]

Get a package.

Parameters:
  • name – The name of the package 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_package_as_rendered(name: str, token: str = None, **rest)[source]

Get package after passing through Cobbler’s inheritance engine

Parameters:
  • name – package name

  • token – authentication token

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

Returns:

Get a template rendered as a package.

get_package_handle(name: str, token: str)[source]

Get a handle for a package which allows you to use the functions modify_* or save_* to manipulate it.

Parameters:
  • name – The name of the item.

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

Returns:

The handle of the desired object.

get_packages(page=None, results_per_page=None, token=None, **rest)[source]

This returns all packages.

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 packages tracked in Cobbler.

get_packages_since(mtime: 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=False, resolved: bool = False, token=None, **rest)[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, **rest)[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_handle(name: str, token: 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.

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

Returns:

The handle of the desired object.

get_profiles(page=None, results_per_page=None, token=None, **rest)[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)[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='xenpv', token=None, **rest)[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=False, resolved: bool = False, token=None, **rest)[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, **rest)[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, **rest)[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, **rest)[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, token: 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.

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

Returns:

The handle of the desired object.

get_repos(page=None, results_per_page=None, token=None, **rest)[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=None, token=None, **rest) list[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)[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=None, **rest) dict[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=None, **rest) dict[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='normal', token=None, **rest)[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=False, resolved: bool = False, token=None, **rest)[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, **rest)[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_handle(name: str, token: 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.

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

Returns:

The handle of the desired object.

get_systems(page=None, results_per_page=None, token=None, **rest)[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)[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)[source]

Get the current status of the task.

Parameters:

event_id – The unique id of the task.

Returns:

The event status.

get_template_file_for_profile(profile_name, path, **rest)[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, path, **rest)[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_user_from_token(token: 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=None) list[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=None, **rest) list[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, token=None)[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, token=None)[source]

Return the list of valid boot loaders for the image

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

  • distro_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=None, **rest) list[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, token=None, **rest) list[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, token=None)[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, token=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.

is_autoinstall_in_use(ai, token=None, **rest)[source]

Check if the autoinstall 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=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, attribute, arg, token: str)[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_file(object_id, attribute, arg, token: str)[source]

Modify a single attribute of a file.

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, attribute, arg, token: str)[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, attribute, arg, 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.1

  • 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, attribute, arg, token: str)[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_mgmtclass(object_id, attribute, arg, token: str)[source]

Modify a single attribute of a managementclass.

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_package(object_id, attribute, arg, token: str)[source]

Modify a single attribute of a package.

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, attribute, arg, token: str)[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_repo(object_id, attribute, arg, token: str)[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, 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, attribute, arg, token: str)[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.

new_distro(token: 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_file(token: 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)[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, token, is_subobject: bool = False)[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 mgmtclass, package, file 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)[source]

See new_item().

Parameters:

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

Returns:

The object id for the newly created object.

new_mgmtclass(token: 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_package(token: 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(token: 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)[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)[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)[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)

read_autoinstall_snippet(file_path: str, token: str) str[source]

Read an automatic OS installation snippet file

Parameters:
  • file_path – automatic OS installation snippet file path

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

Returns:

file content

read_autoinstall_template(file_path: str, token: str) str[source]

Read an automatic OS installation template file

Parameters:
  • file_path – automatic OS installation template file path

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

Returns:

file content

register_new_system(info, token=None, **rest)[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_autoinstall_snippet(file_path: str, token: str)[source]

Remove an automated OS installation snippet file

Parameters:
  • file_path – automated OS installation snippet file path

  • token – Cobbler token, obtained form login()

Returns:

bool if operation was successful

remove_autoinstall_template(file_path: str, token: str)[source]

Remove an automatic OS installation template file

Parameters:
  • file_path – automatic OS installation template file path

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

Returns:

bool if operation was successful

remove_distro(name: str, token: str, recursive: bool = True)[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_file(name: str, token: str, recursive: bool = True)[source]

Deletes a file 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)[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)[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)[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_mgmtclass(name: str, token: str, recursive: bool = True)[source]

Deletes a managementclass 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_package(name: str, token: str, recursive: bool = True)[source]

Deletes a package 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)[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_repo(name: str, token: str, recursive: bool = True)[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)[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.

rename_distro(object_id, newname, token=None)[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_file(object_id, newname, token=None)[source]

Renames a file 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, newname, token=None)[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, object_id, newname, token=None)[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, newname, token=None)[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_mgmtclass(object_id, newname, token=None)[source]

Renames a managementclass 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_package(object_id, newname, token=None)[source]

Renames a package 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, newname, token=None)[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_repo(object_id, newname, token=None)[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, newname, token=None)[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.

run_install_triggers(mode, objtype, name, ip, token=None, **rest)[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, token, editmode: str = 'bypass')[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.

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

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

Returns:

True if the action succeeded.

save_file(object_id, token, editmode: str = 'bypass')[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.

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

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

Returns:

True if the action succeeded.

save_image(object_id, token, editmode: str = 'bypass')[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.

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

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

Returns:

True if the action succeeded.

save_item(what, object_id, token, editmode: str = 'bypass')[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.

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

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

Returns:

True if the action succeeded.

save_menu(object_id, token, editmode='bypass')[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.

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

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

Returns:

True if the action succeeded.

save_mgmtclass(object_id, token, editmode: str = 'bypass')[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.

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

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

Returns:

True if the action succeeded.

save_package(object_id, token, editmode: str = 'bypass')[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.

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

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

Returns:

True if the action succeeded.

save_profile(object_id, token, editmode: str = 'bypass')[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.

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

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

Returns:

True if the action succeeded.

save_repo(object_id, token, editmode: str = 'bypass')[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.

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

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

Returns:

True if the action succeeded.

save_system(object_id, token, editmode: str = 'bypass')[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.

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

  • editmode – The mode which shall be used to persist the changes. Currently “new” and “bypass” are supported.

Returns:

True if the action succeeded.

sync(token: str)[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)[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

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

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=None, **rest)[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.

write_autoinstall_snippet(file_path: str, data: str, token: str) bool[source]

Write an automatic OS installation snippet file

Parameters:
  • file_path – automatic OS installation snippet file path

  • data – new file content

  • token – Cobbler token, obtained form login()

Returns:

if operation was successful

write_autoinstall_template(file_path: str, data: str, token: str)[source]

Write an automatic OS installation template file

Parameters:
  • file_path – automatic OS installation template file path

  • data – new file content

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

Returns:

bool if operation was successful

xapi_object_edit(object_type: str, object_name: str, edit_type: str, attributes: dict, token: str)[source]

Extended API: New style object manipulations, 2.0 and later.

Extended API: New style object manipulations, 2.0 and later preferred over using new_*, modify_*`, save_* directly. Though we must preserve the old ways for backwards compatibility these cause much less XMLRPC traffic.

Ex: xapi_object_edit(“distro”,”el5”,”add”,{“kernel”:”/tmp/foo”,”initrd”:”/tmp/foo”},token)

Parameters:
  • object_type – The object type which corresponds to the collection type the object is in.

  • object_name – The name of the object under question.

  • edit_type – One of ‘add’, ‘rename’, ‘copy’, ‘remove’

  • attributes – The attributes which shall be edited. This should be JSON-style string.

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

Returns:

True if the action succeeded.

xmlrpc_hacks(data)[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)[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, proxy_class)[source]

Bases: object

class cobbler.remote.RequestHandler(request, client_address, server)[source]

Bases: SimpleXMLRPCRequestHandler

do_OPTIONS()[source]
end_headers()[source]

Send the blank line ending the MIME headers.

9.17. cobbler.serializer module

Serializer code for Cobbler Now adapted to support different storage backends

Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

cobbler.serializer.deserialize(collection, topological: bool = True)[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/item.py

cobbler.serializer.handler(num, frame)[source]
cobbler.serializer.serialize(collection)[source]

Save a collection to disk

Parameters:

collection – The collection to serialize.

cobbler.serializer.serialize_delete(collection, item)[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.

cobbler.serializer.serialize_item(collection, item)[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.

9.18. cobbler.services module

Mod Python service functions for Cobbler’s public interface (aka cool stuff that works with wget/curl)

based on code copyright 2007 Albert P. Tobey <tobert@gmail.com> additions: 2007-2009 Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

class cobbler.services.CobblerSvc(server=None, req=None)[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(**rest) 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:

rest – The keys “REMOTE_MACS”, “REMOTE_ADDR” or “interfaces”.

Returns:

The name of the possible object or an error message.

autoinstall(profile=None, system=None, REMOTE_ADDR=None, REMOTE_MAC=None, **rest)[source]

Generate automatic installation files.

Parameters:
  • profile

  • system

  • REMOTE_ADDR

  • REMOTE_MAC

  • rest – This parameter is unused.

Returns:

bootcfg(profile=None, system=None, **rest)[source]

Generate a boot.cfg config file. Used primarily for VMware ESXi.

Parameters:
  • profile

  • system

  • rest – This parameter is unused.

Returns:

debug(profile=None, **rest)[source]
events(user='', **rest) 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.

  • rest – This parameter is unused.

Returns:

A JSON object which contains all events.

find_autoinstall(system=None, profile=None, **rest)[source]

Find an autoinstallation for a system or a profile. If this is not known different parameters can be passed to rest to find it automatically. See “autodetect”.

Parameters:
  • system – The system to find the autoinstallation for,

  • profile – The profile to find the autoinstallation for.

  • rest – The metadata to find the autoinstallation automatically.

Returns:

The autoinstall script or error message.

findks(system=None, profile=None, **rest)[source]

This is a legacy function which enabled Cobbler partly to be backward compatible to 2.6.6 releases.

It should be only be used if you must. Please use find_autoinstall if possible! :param system: If you wish to find a system please set this parameter to not null. Hand over the name of it. :param profile: If you wish to find a system please set this parameter to not null. Hand over the name of it. :param rest: If you wish you can try to let Cobbler autodetect the system with the MAC address. :return: Returns the autoinstall/kickstart profile.

index(**args) str[source]

Just a placeholder method as an entry point.

Parameters:

args – This parameter is unused.

Returns:

“no mode specified”

ipxe(profile=None, image=None, system=None, mac=None, **rest)[source]

Generates an iPXE configuration.

Parameters:
  • profile – A profile.

  • image – An image.

  • system – A system.

  • mac – A MAC address.

  • rest – This parameter is unused.

ks(profile=None, system=None, REMOTE_ADDR=None, REMOTE_MAC=None, **rest)[source]

Generate automatic installation files. This is a legacy function for part backward compatibility to 2.6.6 releases.

Parameters:
  • profile

  • system

  • REMOTE_ADDR

  • REMOTE_MAC

  • rest – This parameter is unused.

Returns:

list(what='systems', **rest) str[source]

Return a list of objects of a desired category. Defaults to “systems”.

Parameters:
  • what – May be “systems”, “profiles”, “distros”, “images”, “repos”, “mgmtclasses”, “packages”, “files” or “menus”

  • rest – This parameter is unused.

Returns:

The list of object names.

nopxe(system=None, **rest) str[source]

Disables the network boot for the given system.

Parameters:
  • system – The system to disable netboot for.

  • rest – This parameter is unused.

Returns:

A boolean status if the action succeed or not.

puppet(hostname=None, **rest) str[source]

Dump the puppet data which is available for Cobbler.

Parameters:
  • hostname – The hostname for the system which should the puppet data be dumped for.

  • rest – This parameter is unused.

Returns:

The yaml for the host.

script(profile=None, system=None, **rest) 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.

  • rest – 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)[source]

Get the application configuration.

Returns:

Settings object.

template(profile=None, system=None, path=None, **rest) 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.

  • rest – This parameter is unused.

Returns:

The rendered template.

trig(mode: str = '?', profile=None, system=None, REMOTE_ADDR=None, **rest) 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.

  • rest – This parameter is unused.

Returns:

The return code of the action.

yum(profile=None, system=None, **rest) 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.

  • rest – This parameter is unused.

Returns:

The generated repository config.

9.19. cobbler.templar module

Cobbler uses Cheetah templates for lots of stuff, but there’s some additional magic around that to deal with snippets/etc. (And it’s not spelled wrong!)

Copyright 2008-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

class cobbler.templar.Templar(api)[source]

Bases: object

Wrapper to encapsulate all logic of Cheetah vs. Jinja2. This also enables us to remove and add templating as desired via our self-defined API in this class.

check_for_invalid_imports(data: str)[source]

Ensure that Cheetah code is not importing Python modules that may allow for advanced privileges by ensuring we whitelist the imports that we allow.

Parameters:

data – The Cheetah code to check.

Raises:

CX – Raised in case there could be a pontentially insecure import in the template.

render(data_input: TextIO | str, search_table: dict, out_path: str | None, template_type='default') str[source]

Render data_input back into a file.

Parameters:
  • data_input – is either a str or a TextIO object.

  • search_table – is a dict of metadata keys and values.

  • out_path – Optional parameter which (if present), represents the target path to write the result into.

  • template_type – May currently be “cheetah” or “jinja2”. “default” looks in the settings.

Returns:

The rendered template.

render_cheetah(raw_data, search_table: dict) str[source]

Render data_input back into a file.

Parameters:
  • raw_data – Is the template code which is not rendered into the result.

  • search_table – is a dict of metadata keys and values (though results are always returned)

Returns:

The rendered Cheetah Template.

Raises:
  • SyntaxError – Raised in case the NFS paths has an invalid syntax.

  • CX – Raised in case there was an error when templating.

render_jinja2(raw_data: str, search_table: dict) str[source]

Render data_input back into a file.

Parameters:
  • raw_data – Is the template code which is not rendered into the result.

  • search_table – is a dict of metadata keys and values

Returns:

The rendered Jinja2 Template.

9.20. cobbler.template_api module

Cobbler provides builtin methods for use in Cheetah templates. $SNIPPET is one such function and is now used to implement Cobbler’s SNIPPET:: syntax.

Written by Daniel Guernsey <danpg102@gmail.com> Contributions by Michael DeHaan <michael.dehaan AT gmail> US Government work; No explicit copyright attached to this file.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

class cobbler.template_api.CobblerTemplate(**kwargs)[source]

Bases: DynamicallyCompiledCheetahTemplate

This class will allow us to include any pure python builtin functions. It derives from the cheetah-compiled class above. This way, we can include both types (cheetah and pure python) of builtins in the same base template. We don’t need to override __init__

SNIPPET(file: str)[source]

Include the contents of the named snippet here. This is equivalent to the #include directive in Cheetah, except that it searches for system and profile specific snippets, and it includes the snippet’s namespace.

This may be a little frobby, but it’s really cool. This is a pure python portion of SNIPPET that appends the snippet’s searchList to the caller’s searchList. This makes any #defs within a given snippet available to the template that included the snippet.

Parameters:

file – The snippet file to read and include in the template.

Returns:

The updated template.

classmethod compile(*args, **kwargs) bytes[source]

Compile a cheetah template with Cobbler modifications. Modifications include SNIPPET:: syntax replacement and inclusion of Cobbler builtin methods. Please be aware that you cannot use the baseclass attribute of Cheetah anymore due to the fact that we are using it in our implementation to enable the Cheetah Macros.

Parameters:
  • args – These just get passed right to Cheetah.

  • kwargs – We just execute our own preprocessors and remove them and let afterwards handle Cheetah the rest.

Returns:

The compiled template.

read_snippet(file: str) str | None[source]

Locate the appropriate snippet for the current system and profile and read its contents.

This file could be located in a remote location.

This will first check for a per-system snippet, a per-profile snippet, a distro snippet, and a general snippet.

Parameters:

file – The name of the file to read. Depending on the context this gets expanded automatically.

Returns:

None (if the snippet file was not found) or the string with the read snippet.

Raises:
sedesc(value: str) str[source]

Escape a string for use in sed.

This function is used by several cheetah methods in cheetah_macros. It can be used by the end user as well.

Example: Replace all instances of /etc/banner with a value stored in $new_banner

..code:

sed 's/$sedesc("/etc/banner")/$sedesc($new_banner)/'
Parameters:

value – The phrase to escape.

Returns:

The escaped phrase.

cobbler.template_api.generate_cheetah_macros()[source]
cobbler.template_api.read_macro_file(location='/etc/cobbler/cheetah_macros')[source]

9.21. cobbler.tftpgen module

Generate files provided by TFTP server based on Cobbler object tree. This is the code behind ‘cobbler sync’.

Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

class cobbler.tftpgen.TFTPGen(api)[source]

Bases: object

Generate files provided by TFTP server

build_kernel(metadata, system, profile, distro, image=None, boot_loader: str = 'pxe')[source]

Generates kernel and initrd metadata.

Parameters:
  • metadata – Pass additional parameters to the ones being collected during the method.

  • 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, profile, distro, image, arch: Archs, autoinstall_path) 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.

  • autoinstall_path – The autoinstallation path. Normally this will be a URL because you want to pass a link to an autoyast, preseed or kickstart file.

Returns:

The generated kernel line options.

copy_bootloaders(dest)[source]

Copy bootloaders to the configured tftpboot directory NOTE: we support different arch’s if defined in our settings file.

copy_images()[source]

Like copy_distros except for images.

copy_single_distro_file(d_file: str, distro_dir: str, symlink_ok: bool)[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(d, dirtree, symlink_ok: bool)[source]

Copy the files needed for a single distro.

Parameters:
  • d – 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)[source]

Copies an image to the images directory of Cobbler.

Parameters:

img – The image to copy.

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

get_images_menu(menu, metadata, arch: Archs)[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[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=None, arch: Archs = None) dict[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, metadata, arch: Archs)[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, metadata: dict, arch: Archs)[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][source]

Generates pxe, ipxe and grub boot menus.

write_all_system_files(system, menu_items)[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.

Parameters:
  • system – The system to generate files for.

  • menu_items – TODO

write_pxe_file(filename, system, profile, distro, arch: Archs, image=None, metadata=None, format: str = 'pxe') str[source]

Write a configuration file for the boot loader(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.

  • format – Can be any of those returned by utils.get_supported_system_boot_loaders().

Returns:

The generated filecontent for the required item.

write_templates(obj, write_file: bool = False, path=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.

9.22. cobbler.utils module

Misc heavy lifting functions for Cobbler

Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

class cobbler.utils.DHCP(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

V4 = (4,)
V6 = 6
class cobbler.utils.MntEntObj(input: str = None)[source]

Bases: object

mnt_dir = None
mnt_freq = 0
mnt_fsname = None
mnt_opts = None
mnt_passno = 0
mnt_type = None
cobbler.utils.blender(api_handle, remove_dicts: bool, root_obj)[source]

Combine all of the data in an object tree from the perspective of that point on the tree, and produce a merged dictionary containing consolidated data.

Parameters:
  • api_handle – The api to use for collecting the information to blender the item.

  • remove_dicts – Boolean to decide whether dicts should be converted.

  • root_obj – The object which should act as the root-node object.

Returns:

A dictionary with all the information from the root node downwards.

cobbler.utils.cachefile(src: str, dst: str)[source]

Copy a file into a cache and link it into place. Use this with caution, otherwise you could end up copying data twice if the cache is not on the same device as the destination.

Parameters:
  • src – The sourcefile for the copy action.

  • dst – The destination for the copy action.

cobbler.utils.cheetah_exc(exc) str[source]

Converts an exception thrown by Cheetah3 into a custom error message.

Parameters:

exc – The exception to convert.

Returns:

The string representation of the Cheetah3 exception.

cobbler.utils.command_existing(cmd: str) bool[source]

This takes a command which should be known to the system and checks if it is available.

Parameters:

cmd – The executable to check

Returns:

If the binary does not exist False, otherwise True.

cobbler.utils.compare_versions_gt(ver1: str, ver2: str) bool[source]

Compares versions like “0.9.3” with each other and decides if ver1 is greater than ver2.

Parameters:
  • ver1 – The first version.

  • ver2 – The second version.

Returns:

True if ver1 is greater, otherwise False.

cobbler.utils.copyfile(src: str, dst: str, symlink=False)[source]

Copy a file from source to the destination.

Parameters:
  • src – The source file. This may also be a folder.

  • dst – The destination for the file or folder.

Raises:

OSError – Raised in case src could not be read.

cobbler.utils.copyfile_pattern(pattern, dst, require_match: bool = True, symlink_ok: bool = False, cache: bool = True, api=None)[source]

Copy 1 or more files with a pattern into a destination.

Parameters:
  • pattern – The pattern for finding the required files.

  • dst – The destination for the file(s) found.

  • require_match – If the glob pattern does not find files should an error message be thrown or not.

  • symlink_ok – If it is okay to just use a symlink to link the file to the destination.

  • cache – If it is okay to use a file from the cache (which could be possibly newer) or not.

  • api – Passed to linkfile().

Raises:

CX – Raised in case files not found according to pattern.

cobbler.utils.copyremotefile(src: str, dst1: str, api=None)[source]

Copys a file from a remote place to the local destionation.

Parameters:
  • src – The remote file URI.

  • dst1 – The copy destination on the local filesystem.

  • api – This parameter is not used currently.

Raises:

OSError – Raised in case an error occurs when fetching or writing the file.

cobbler.utils.dhcp_service_name() str[source]

Determine the dhcp service which is different on various distros. This is currently a hardcoded detection.

Returns:

This will return one of the following names: “dhcp3-server”, “isc-dhcp-server”, “dhcpd”

cobbler.utils.dhcpconf_location(protocol: DHCP, filename: str = 'dhcpd.conf') str[source]

This method returns the location of the dhcpd.conf file.

Parameters:
  • protocol – The DHCP protocol version (v4/v6) that is used.

  • filename – The filename of the DHCP configuration file.

Raises:

AttributeError – If the protocol is not v4/v6.

Returns:

The path possibly used for the dhcpd.conf file.

cobbler.utils.dict_annihilate(dictionary: dict)[source]

Annihilate entries marked for removal. This method removes all entries with key names starting with “!”. If a dictionary contains keys “!xxx” and “xxx”, then both will be removed.

Parameters:

dictionary – A dictionary to clean up.

cobbler.utils.dict_removals(results: dict, subkey: str)[source]

Remove entries from a dictionary starting with a “!”.

Parameters:
  • results – The dictionary to search in

  • subkey – The subkey to search through.

cobbler.utils.dict_to_string(_dict: dict) str | dict[source]

Convert a dictionary to a printable string. Used primarily in the kernel options string and for some legacy stuff where koan expects strings (though this last part should be changed to dictionaries)

A KV-Pair is joined with a “=”. Values are enclosed in single quotes.

Parameters:

_dict – The dictionary to convert to a string.

Returns:

The string which was previously a dictionary.

cobbler.utils.die(msg: str)[source]

This method let’s Cobbler crash with an exception. Log the exception once in the per-task log or the main log if this is not a background op.

Parameters:

msg – The message to send for raising the exception

Raises:

CX – Raised in all cases with msg.

cobbler.utils.file_is_remote(file_location) bool[source]

Returns true if the file is remote and referenced via a protocol we support.

Parameters:

file_location – The URI to check.

Returns:

True if the URI is http, https or ftp. Otherwise false.

cobbler.utils.find_distro_path(settings, distro)[source]

This returns the absolute path to the distro under the distro_mirror directory. If that directory doesn’t contain the kernel, the directory of the kernel in the distro is returned.

Parameters:
  • settings – The settings to resolve user configurable actions with.

  • distro – The distribution to find the path of.

Returns:

The path to the distribution files.

cobbler.utils.find_highest_files(directory: str, unversioned: str, regex: Pattern[str]) str[source]

Find the highest numbered file (kernel or initrd numbering scheme) in a given directory that matches a given pattern. Used for auto-booting the latest kernel in a directory.

Parameters:
  • directory – The directory to search in.

  • unversioned – The base filename which also acts as a last resort if no numbered files are found.

  • regex – The regex to search for.

Returns:

The file with the highest number or an empty string.

cobbler.utils.find_initrd(path: str) str | None[source]

Given a directory or a filename, see if the path can be made to resolve into an intird, return that full path if possible.

Parameters:

path – The path to check for initrd files.

Returns:

None or the path to the found initrd.

cobbler.utils.find_kernel(path: str) str[source]

Given a filename, find if the path can be made to resolve into a kernel, and return that full path if possible.

Parameters:

path – The path to check for a kernel.

Returns:

path if at the specified location a possible match for a kernel was found, otherwise an empty string.

cobbler.utils.find_matching_files(directory: str, regex: Pattern[str]) list[source]

Find all files in a given directory that match a given regex. Can’t use glob directly as glob doesn’t take regexen. The search does not include subdirectories.

Parameters:
  • directory – The directory to search in.

  • regex – The regex to apply to the found files.

Returns:

An array of files which apply to the regex.

cobbler.utils.flatten(data: dict) dict | None[source]

Convert certain nested dicts to strings. This is only really done for the ones koan needs as strings this should not be done for everything

Parameters:

data – The dictionary in which various keys should be converted into a string.

Returns:

None (if data is None) or the flattened string.

cobbler.utils.get_exc(exc, full: bool = True)[source]

This tries to analyze if an exception comes from Cobbler and potentially enriches or shortens the exception.

Parameters:
  • exc – The exception which should be analyzed.

  • full – If the full exception should be returned or only the most important information.

Returns:

The exception which has been converted into a string which then can be logged easily.

cobbler.utils.get_family() str[source]

Get family of running operating system.

Family is the base Linux distribution of a Linux distribution, with a set of common parents.

Returns:

May be “redhat”, “debian” or “suse” currently. If none of these are detected then just the distro name is returned.

cobbler.utils.get_file_device_path(fname)[source]
What this function attempts to do is take a file and return:
  • the device the file is on

  • the path of the file relative to the device.

For example:

/boot/vmlinuz -> (/dev/sda3, /vmlinuz) /boot/efi/efi/redhat/elilo.conf -> (/dev/cciss0, /elilo.conf) /etc/fstab -> (/dev/sda4, /etc/fstab)

Parameters:

fname – The filename to split up.

Returns:

A tuple containing the device and relative filename.

cobbler.utils.get_host_ip(ip, shorten=True) str[source]

Return the IP encoding needed for the TFTP boot tree.

Parameters:
  • ip – The IP address to pretty print.

  • shorten – Whether the IP-Address should be shortened or not.

Returns:

The IP encoded as a hexadecimal value.

cobbler.utils.get_mtab(mtab='/etc/mtab', vfstype: bool = False) list[source]

Get the list of mtab entries. If a custom mtab should be read then the location can be overridden via a parameter.

Parameters:
  • mtab – The location of the mtab. Argument can be omitted if the mtab is at its default location.

  • vfstype – If this is True, then all filesystems which are nfs are returned. Otherwise this returns all mtab entries.

Returns:

The list of requested mtab entries.

cobbler.utils.get_random_mac(api_handle, virt_type='xenpv') str[source]

Generate a random MAC address.

The code of this method was taken from xend/server/netif.py

Parameters:
  • api_handle – The main Cobbler api instance.

  • virt_type – The virtualization provider. Currently possible is ‘vmware’, ‘xen’, ‘qemu’, ‘kvm’.

Returns:

MAC address string

Raises:

CX – Raised in case unsupported virt_type given.

cobbler.utils.get_shared_secret() str | int[source]

The ‘web.ss’ file is regenerated each time cobblerd restarts and is used to agree on shared secret interchange between the web server and cobblerd, and also the CLI and cobblerd, when username/password access is not required. For the CLI, this enables root users to avoid entering username/pass if on the Cobbler server.

Returns:

The Cobbler secret which enables full access to Cobbler.

cobbler.utils.get_supported_distro_boot_loaders(distro, api_handle=None)[source]

This is trying to return you the list of known bootloaders if all resorts fail. Otherwise this returns a list which contains only the subset of bootloaders which are available by the distro in the argument.

Parameters:
  • distro – The distro to check for.

  • api_handle – The api instance to resolve metadata and settings from.

Returns:

The list of bootloaders or a dict of well known bootloaders.

cobbler.utils.get_supported_system_boot_loaders() List[str][source]

Return the list of currently supported bootloaders.

Returns:

The list of currently supported bootloaders.

cobbler.utils.get_valid_archs()[source]

Return a list of valid architectures found in the import signatures

Returns:

All architectures which are known to Cobbler according to the signature cache.

cobbler.utils.get_valid_breeds() list[source]

Return a list of valid breeds found in the import signatures

cobbler.utils.get_valid_os_versions() list[source]

Return a list of valid os-versions found in the import signatures

Returns:

All operating system versions which are known to Cobbler according to the signature cache.

cobbler.utils.get_valid_os_versions_for_breed(breed) list[source]

Return a list of valid os-versions for the given breed

Parameters:

breed – The operating system breed to check for.

Returns:

All operating system version which are known to Cobbler according to the signature cache filtered by a os-breed.

cobbler.utils.hashfile(fn, lcache=None)[source]

Returns the sha1sum of the file

Parameters:
  • fn – The file to get the sha1sum of.

  • lcache – This is a directory where Cobbler would store its link_cache.json file to speed up the return of the hash. The hash looked up would be checked against the Cobbler internal mtime of the object.

Returns:

The sha1 sum or None if the file doesn’t exist.

cobbler.utils.input_boolean(value: str | bool | int) bool[source]

Convert a str to a boolean. If this is not possible or the value is false return false.

Parameters:

value – The value to convert to boolean.

Returns:

True if the value is in the following list, otherwise false: “true”, “1”, “on”, “yes”, “y” .

cobbler.utils.input_string_or_dict(options: str | list | dict, allow_multiples=True) str | dict[source]

Older Cobbler files stored configurations in a flat way, such that all values for strings. Newer versions of Cobbler allow dictionaries. This function is used to allow loading of older value formats so new users of Cobbler aren’t broken in an upgrade.

Parameters:
  • options – The str or dict to convert.

  • allow_multiples – True (default) to allow multiple identical keys, otherwise set this false explicitly.

Returns:

A dict or the value <<inherit>> in case it is the only content of options.

Raises:

TypeError – Raised in case the input type is wrong.

cobbler.utils.input_string_or_dict_no_inherit(options: str | list | dict, allow_multiples=True) dict[source]

See input_string_or_dict()

cobbler.utils.input_string_or_list(options: str | list | None) list | str[source]

Accepts a delimited list of stuff or a list, but always returns a list. :param options: The object to split into a list. :return: str when this functions get’s passed <<inherit>>. if option is delete then an empty list is returned.

Otherwise, this function tries to return the arg option or tries to split it into a list.

Raises:

TypeError – In case the type of options was neither None, str or list.

cobbler.utils.input_string_or_list_no_inherit(options: str | list | None) list[source]

Accepts a delimited list of stuff or a list, but always returns a list.

Parameters:

options – The object to split into a list.

Returns:

If option is delete, None (object not literal) or an empty str, then an empty list is returned. Otherwise, this function tries to return the arg option or tries to split it into a list.

Raises:

TypeError – In case the type of options was neither None, str or list.

cobbler.utils.is_ip(strdata: str) bool[source]

Return whether the argument is an IP address.

Parameters:

strdata – The IP in a string format. This get’s passed to the IP object of Python.

cobbler.utils.is_remote_file(file) bool[source]

This function is trying to detect if the file in the argument is remote or not.

Parameters:

file – The filepath to check.

Returns:

If remote True, otherwise False.

Determine if it is safe to hardlink a file to the destination path.

Parameters:
  • src – The hardlink source path.

  • dst – The hardlink target path.

  • api – The api-instance to resolve needed information with.

Returns:

True if selinux is disabled, the file is on the same device, the source in not a link, and it is not a remote path. If selinux is enabled the functions still may return true if the object is a kernel or initrd. Otherwise returns False.

cobbler.utils.is_selinux_enabled() bool[source]

This check is achieved via a subprocess call to selinuxenabled. Default return is false.

Returns:

Whether selinux is enabled or not.

cobbler.utils.is_service() bool[source]

Return whether or not this system uses service.

This method currently checks if the path /usr/sbin/service exists.

cobbler.utils.is_str_float(value: str) bool[source]

Checks if the string value could be converted into a float. This is necessary since the CLI only works with strings but many methods and checks expects a float.

Parameters:

value – The value to check

Returns:

True if conversion is successful

cobbler.utils.is_str_int(value: str) bool[source]

Checks if the string value could be converted into an integer. This is necessary since the CLI only works with strings but many methods and checks expects an integer.

Parameters:

value – The value to check

Returns:

True if conversion is successful

cobbler.utils.is_supervisord() bool[source]

Return whether or not this system uses supervisod.

This method currently checks if there is a running supervisord instance on localhost.

cobbler.utils.is_systemd() bool[source]

Return whether or not this system uses systemd.

This method currently checks if the path /usr/lib/systemd/systemd exists.

cobbler.utils.kopts_overwrite(kopts: dict, cobbler_server_hostname: str = '', distro_breed: str = '', system_name: str = '')[source]

SUSE is not using ‘text’. Instead ‘textmode’ is used as kernel option.

Parameters:
  • kopts – The kopts of the system.

  • cobbler_server_hostname – The server setting from our Settings.

  • distro_breed – The distro for the system to change to kopts for.

  • system_name – The system to overwrite the kopts for.

Link a Cobbler distro from its source into the web directory to make it reachable from the outside.

Parameters:
  • settings – The settings to resolve user configurable actions with.

  • distro – The distro to link into the Cobbler web directory.

cobbler.utils.linkfile(src: str, dst: str, symlink_ok: bool = False, cache: bool = True, api=None)[source]

Attempt to create a link dst that points to src. Because file systems suck we attempt several different methods or bail to just copying the file.

Parameters:
  • src – The source file.

  • dst – The destination for the link.

  • symlink_ok – If it is okay to just use a symbolic link.

  • cache – If it is okay to use a cached file instead of the real one.

  • api – This parameter is needed to check if a file can be hardlinked. This method fails if this parameter is not present.

Raises:

CX – Raised in case the API is not given.

cobbler.utils.load_signatures(filename, cache: bool = True)[source]

Loads the import signatures for distros.

Parameters:
  • filename – Loads the file with the given name.

  • cache – If the cache should be set with the newly read data.

cobbler.utils.local_get_cobbler_api_url() str[source]

Get the URL of the Cobbler HTTP API from the Cobbler settings file.

Returns:

The api entry point. This does not respect modifications from Loadbalancers or API-Gateways.

cobbler.utils.local_get_cobbler_xmlrpc_url() str[source]

Get the URL of the Cobbler XMLRPC API from the Cobbler settings file.

Returns:

The api entry point.

cobbler.utils.lod_sort_by_key(list_to_sort: list, indexkey) list[source]

Sorts a list of dictionaries by a given key in the dictionaries.

Note: This is a destructive operation and does not sort the dictionaries.

Parameters:
  • list_to_sort – The list of dictionaries to sort.

  • indexkey – The key to index to dicts in the list.

Returns:

The sorted list.

cobbler.utils.lod_to_dod(_list: list, indexkey) dict[source]

Things like get_distros() returns a list of a dictionaries. Convert this to a dict of dicts keyed off of an arbitrary field.

Example: [ { "a" : 2 }, { "a" : 3 } ] -> { "2" : { "a" : 2 }, "3" : { "a" : "3" } }

Parameters:
  • _list – The list of dictionaries to use for the conversion.

  • indexkey – The position to use as dictionary keys.

Returns:

The converted dictionary. It is not guaranteed that the same key is not used multiple times.

cobbler.utils.log_exc()[source]

Log an exception.

cobbler.utils.mkdir(path, mode=493)[source]

Create directory with a given mode.

Parameters:
  • path – The path to create the directory at.

  • mode – The mode to create the directory with.

Raises:

CX – Raised in case creating the directory fails with error code 17.

cobbler.utils.named_service_name() str[source]

Determine the named service which is normally different on various distros.

Returns:

This will return for debian/ubuntu bind9 and on other distros named-chroot or named.

cobbler.utils.namedconf_location() str[source]

This returns the location of the named.conf file.

Returns:

If the distro is Debian/Ubuntu then this returns “/etc/bind/named.conf”. Otherwise “/etc/named.conf”

cobbler.utils.os_release()[source]

Get the os version of the linux distro. If the get_family() method succeeds then the result is normalized.

Returns:

The os-name and os version.

cobbler.utils.path_tail(apath, bpath) str[source]

Given two paths (B is longer than A), find the part in B not in A

Parameters:
  • apath – The first path.

  • bpath – The second path.

Returns:

If the paths are not starting at the same location this function returns an empty string.

cobbler.utils.pretty_hex(ip, length=8) str[source]

Pads an IP object with leading zeroes so that the result is _length_ hex digits. Also do an upper().

Parameters:
  • ip – The IP address to pretty print.

  • length – The length of the resulting hexstring. If the number is smaller than the resulting hex-string then no front-padding is done.

cobbler.utils.read_file_contents(file_location, fetch_if_remote=False) str | None[source]

Reads the contents of a file, which could be referenced locally or as a URI.

Parameters:
  • file_location – The location of the file to read.

  • fetch_if_remote – If True a remote file will be tried to read, otherwise remote files are skipped and None is returned.

Returns:

Returns None if file is remote and templating of remote files is disabled.

Raises:

FileNotFoundError – if the file does not exist at the specified location.

cobbler.utils.remote_file_exists(file_url) bool[source]

Return True if the remote file exists.

Parameters:

file_url – The URL to check.

Returns:

True if Cobbler can reach the specified URL, otherwise false.

cobbler.utils.remove_yum_olddata(path: PathLike)[source]

Delete .olddata folders that might be present from a failed run of createrepo.

Parameters:

path – The path to check for .olddata files.

cobbler.utils.revert_strip_none(data)[source]

Does the opposite to strip_none. If a value which represents None is detected, it replaces it with None.

Parameters:

data – The data to check.

Returns:

The data without None.

cobbler.utils.rmfile(path: str)[source]

Delete a single file.

Parameters:

path – The file to delete.

cobbler.utils.rmglob_files(path: str, glob_pattern: str)[source]

Deletes all files in path with glob_pattern with the help of rmfile().

Parameters:
  • path – The folder of the files to remove.

  • glob_pattern – The glob pattern for the files to remove in path.

cobbler.utils.rmtree(path: str) bool | None[source]

Delete a complete directory or just a single file.

Parameters:

path – The directory or folder to delete.

Returns:

May possibly return true on success or may return None on success.

Raises:

CX – Raised in case path does not exist.

cobbler.utils.rmtree_contents(path: str)[source]

Delete the content of a folder with a glob pattern.

Parameters:

path – This parameter presents the glob pattern of what should be deleted.

cobbler.utils.rsync_files(src: str, dst: str, args: str, quiet: bool = True) bool[source]

Sync files from src to dst. The extra arguments specified by args are appended to the command.

Parameters:
  • src – The source for the copy process.

  • dst – The destination for the copy process.

  • args – The extra arguments are appended to our standard arguments.

  • quiet – If True no progress is reported. If False then progress will be reported by rsync.

Returns:

True on success, otherwise False.

cobbler.utils.run_this(cmd: str, args: str | tuple)[source]

A simple wrapper around subprocess calls.

Parameters:
  • cmd – The command to run in a shell process.

  • args – The arguments to attach to the command.

cobbler.utils.run_triggers(api, ref, globber, additional: list = None)[source]

Runs all the trigger scripts in a given directory. Example: /var/lib/cobbler/triggers/blah/*

As of Cobbler 1.5.X, this also runs Cobbler modules that match the globbing paths.

Python triggers are always run before shell triggers.

Parameters:
  • api – The api object to use for resolving the actions.

  • ref – Can be a Cobbler object, if not None, the name will be passed to the script. If ref is None, the script will be called with no arguments.

  • globber – is a wildcard expression indicating which triggers to run.

  • additional – Additional arguments to run the triggers with.

Raises:

CX – Raised in case the trigger failed.

cobbler.utils.safe_filter(var)[source]

This function does nothing if the argument does not find any semicolons or two points behind each other.

Parameters:

var – This parameter shall not be None or have “..”/”;” at the end.

Raises:

CX – In case any .. or / is found in var.

cobbler.utils.service_restart(service_name: str)[source]

Restarts a daemon service independent of the underlining process manager. Currently SupervisorD, systemd and SysV are supported. Checks which manager is present is done in the order just described.

Parameters:

service_name – The name of the service

Returns:

If the system is SystemD or SysV based the return code of the restart command.

cobbler.utils.strip_none(data, omit_none: bool = False)[source]

Remove “None” entries from datastructures. Used prior to communicating with XMLRPC.

Parameters:
  • data – The data to strip None away.

  • omit_none – If the datastructure is not a single item then None items will be skipped instead of replaced if set to “True”.

Returns:

The modified data structure without any occurrence of None.

cobbler.utils.subprocess_call(cmd, shell: bool = True, input=None)[source]

A simple subprocess call with no output capturing.

Parameters:
  • cmd – The command to execute.

  • shell – Whether to use a shell or not for the execution of the command.

  • input – If there is any input needed for that command to stdin.

Returns:

The return code of the process

cobbler.utils.subprocess_get(cmd, shell: bool = True, input=None)[source]

A simple subprocess call with no return code capturing.

Parameters:
  • cmd – The command to execute.

  • shell – Whether to use a shell or not for the execution of the command.

  • input – If there is any input needed for that command to stdin.

Returns:

The data which the subprocess returns.

cobbler.utils.subprocess_sp(cmd, shell: bool = True, input=None)[source]

Call a shell process and redirect the output for internal usage.

Parameters:
  • cmd – The command to execute in a subprocess call.

  • shell – Whether to use a shell or not for the execution of the command.

  • input – If there is any input needed for that command to stdin.

Returns:

A tuple of the output and the return code.

cobbler.utils.uniquify(seq: list) list[source]

Remove duplicates from the sequence handed over in the args.

Parameters:

seq – The sequence to check for duplicates.

Returns:

The list without duplicates.

9.23. cobbler.validate module

Copyright 2014-2015. Jorgen Maas <jorgen.maas@gmail.com>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

cobbler.validate.hostname(dnsname: str) str[source]

Validate the DNS name.

Parameters:

dnsname – Hostname or FQDN

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=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, for_item: bool = True) str | list[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.

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_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_id(object_id: str) bool[source]

This validates a possible object ID against its Cobbler specific object id schema.

Parameters:

object_id – The possible object id candidate.

Returns:

True in case it is one, False otherwise.

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, api, bypass_check: bool = False)[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_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: bool) bool[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)[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.

9.24. cobbler.yumgen module

Builds out filesystem trees/data based on the object tree. This is the code behind ‘cobbler sync’.

Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

class cobbler.yumgen.YumGen(api)[source]

Bases: object

get_yum_config(obj, 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.

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