8. cobbler package

8.2. Submodules

8.3. cobbler.api module

class cobbler.api.CobblerAPI(is_cobblerd=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=None, addgroup=None, removeuser=None, removegroup=None, logger=None)[source]

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

add_distro(ref, check_for_duplicate_names=False, save=True, logger=None)[source]
add_file(ref, check_for_duplicate_names=False, save=True, logger=None)[source]
add_image(ref, check_for_duplicate_names=False, save=True, logger=None)[source]
add_item(what, ref, check_for_duplicate_names=False, save=True, logger=None)[source]
add_mgmtclass(ref, check_for_duplicate_names=False, save=True, logger=None)[source]
add_package(ref, check_for_duplicate_names=False, save=True, logger=None)[source]
add_profile(ref, check_for_duplicate_names=False, save=True, logger=None)[source]
add_repo(ref, check_for_duplicate_names=False, save=True, logger=None)[source]
add_system(ref, check_for_duplicate_names=False, check_for_duplicate_netinfo=False, save=True, logger=None)[source]
authenticate(user, password)[source]

(Remote) access control. Cobbler internal use only.

authorize(user, resource, arg1=None, arg2=None)[source]

(Remote) access control. Cobbler internal use only.

auto_add_repos()[source]

Import any repos this server knows about and mirror them. Credit: Seth Vidal.

build_iso(iso=None, profiles=None, systems=None, buildisodir=None, distro=None, standalone=None, airgapped=None, source=None, exclude_dns=None, mkisofs_opts=None, logger=None)[source]
check(logger=None)[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.

clear_logs(system, logger=None)[source]

Clears console and anamon logs for system

copy_distro(ref, newname)[source]
copy_file(ref, newname)[source]
copy_image(ref, newname)[source]
copy_item(what, ref, newname, logger=None)[source]
copy_mgmtclass(ref, newname)[source]
copy_package(ref, newname)[source]
copy_profile(ref, newname)[source]
copy_repo(ref, newname)[source]
copy_system(ref, newname)[source]
deserialize()[source]

Load cobbler_collections from disk. Cobbler internal use only.

distros()[source]

Return the current list of distributions

dlcontent(force=False, logger=None)[source]

Downloads bootloader content that may not be avialable in packages for the given arch, ex: if installing on PPC, get syslinux. If installing on x86_64, get elilo, etc.

dump_vars(obj, format=False)[source]
files()[source]

Return the current list of files

find_distro(name=None, return_list=False, no_errors=False, **kargs)[source]
find_file(name=None, return_list=False, no_errors=False, **kargs)[source]
find_image(name=None, return_list=False, no_errors=False, **kargs)[source]
find_items(what, criteria=None)[source]
find_mgmtclass(name=None, return_list=False, no_errors=False, **kargs)[source]
find_package(name=None, return_list=False, no_errors=False, **kargs)[source]
find_profile(name=None, return_list=False, no_errors=False, **kargs)[source]
find_repo(name=None, return_list=False, no_errors=False, **kargs)[source]
find_system(name=None, return_list=False, no_errors=False, **kargs)[source]
generate_bootcfg(profile, system)[source]
generate_gpxe(profile, system)[source]
generate_script(profile, system, name)[source]
get_distros_since(mtime, collapse=False)[source]

Returns distros modified since a certain time (in seconds since Epoch) collapse=True specifies returning a dict instead of objects.

get_files_since(mtime, collapse=False)[source]
get_images_since(mtime, collapse=False)[source]
get_item(what, name)[source]
get_items(what)[source]
get_mgmtclasses_since(mtime, collapse=False)[source]
get_module_by_name(module_name)[source]

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

get_module_from_file(section, name, fallback=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.

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

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

get_modules_in_category(category)[source]

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

get_packages_since(mtime, collapse=False)[source]
get_profiles_since(mtime, collapse=False)[source]
get_repo_config_for_profile(obj)[source]
get_repo_config_for_system(obj)[source]
get_repos_since(mtime, collapse=False)[source]
get_signatures()[source]
get_sync(verbose=False, logger=None)[source]
get_systems_since(mtime, collapse=False)[source]
get_template_file_for_profile(obj, path)[source]
get_template_file_for_system(obj, path)[source]
images()[source]

Return the current list of images

import_tree(mirror_url, mirror_name, network_root=None, autoinstall_file=None, rsync_flags=None, arch=None, breed=None, os_version=None, logger=None)[source]

Automatically import a directory tree full of distribution files. 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”

is_selinux_enabled()[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()[source]

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

last_modified_time()[source]

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

log(msg, args=None, debug=False)[source]
mgmtclasses()[source]

Return the current list of mgmtclasses

new_distro(is_subobject=False)[source]
new_file(is_subobject=False)[source]
new_image(is_subobject=False)[source]
new_mgmtclass(is_subobject=False)[source]
new_package(is_subobject=False)[source]
new_profile(is_subobject=False)[source]
new_repo(is_subobject=False)[source]
new_system(is_subobject=False)[source]
packages()[source]

Return the current list of packages

power_system(system, power_operation, user=None, password=None, logger=None)[source]

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

@param str system Cobbler system @param str power_operation power operation. Valid values: on, off, reboot, status @param str token Cobbler authentication token @param str user power management user @param str password power management password @param Logger logger logger @return bool if operation was successful

profiles()[source]

Return the current list of profiles

remove_distro(ref, recursive=False, delete=True, with_triggers=True, logger=None)[source]
remove_file(ref, recursive=False, delete=True, with_triggers=True, logger=None)[source]
remove_image(ref, recursive=False, delete=True, with_triggers=True, logger=None)[source]
remove_item(what, ref, recursive=False, delete=True, with_triggers=True, logger=None)[source]
remove_mgmtclass(ref, recursive=False, delete=True, with_triggers=True, logger=None)[source]
remove_package(ref, recursive=False, delete=True, with_triggers=True, logger=None)[source]
remove_profile(ref, recursive=False, delete=True, with_triggers=True, logger=None)[source]
remove_repo(ref, recursive=False, delete=True, with_triggers=True, logger=None)[source]
remove_system(ref, recursive=False, delete=True, with_triggers=True, logger=None)[source]
rename_distro(ref, newname, logger=None)[source]
rename_file(ref, newname, logger=None)[source]
rename_image(ref, newname, logger=None)[source]
rename_item(what, ref, newname, logger=None)[source]
rename_mgmtclass(ref, newname, logger=None)[source]
rename_package(ref, newname, logger=None)[source]
rename_profile(ref, newname, logger=None)[source]
rename_repo(ref, newname, logger=None)[source]
rename_system(ref, newname, logger=None)[source]
replicate(cobbler_master=None, port='80', distro_patterns='', profile_patterns='', system_patterns='', repo_patterns='', image_patterns='', mgmtclass_patterns=None, package_patterns=None, file_patterns=None, prune=False, omit_data=False, sync_all=False, use_ssl=False, logger=None)[source]

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

report(report_what=None, report_name=None, report_type=None, report_fields=None, report_noheaders=None)[source]

Report functionality for cobbler

repos()[source]

Return the current list of repos

reposync(name=None, tries=1, nofail=False, logger=None)[source]

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

serialize()[source]

Save the cobbler_collections to disk. Cobbler internal use only.

settings()[source]

Return the application configuration

signature_update(logger)[source]
status(mode, logger=None)[source]
sync(verbose=False, logger=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.

sync_dhcp(verbose=False, logger=None)[source]

Only build out the DHCP configuration

systems()[source]

Return the current list of systems

validate_autoinstall_files(logger=None)[source]
version(extended=False)[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 ]

8.4. cobbler.autoinstall_manager module

class cobbler.autoinstall_manager.AutoInstallationManager(collection_mgr, logger=None)[source]

Bases: object

Manage automatic installation templates, snippets and final files

generate_autoinstall(profile=None, system=None)[source]
get_autoinstall_snippets()[source]
get_autoinstall_templates()[source]

Get automatic OS installation templates

@return list automatic installation templates

is_autoinstall_in_use(name)[source]
log_autoinstall_validation_errors(errors_type, errors)[source]

Log automatic installation file errors

@param int errors_type validation errors type

read_autoinstall_snippet(file_path)[source]
read_autoinstall_template(file_path)[source]

Read an automatic OS installation template

@param str file_path automatic installation template relative file path @return str automatic installation template content

remove_autoinstall_snippet(file_path)[source]
remove_autoinstall_template(file_path)[source]

Remove an automatic OS installation template

@param str file_path automatic installation template relative file path

validate_autoinstall_file(obj, is_profile)[source]

Validate automatic installation file used by a system/profile

@param Item obj system/profile @param bool is_profile if obj is a profile @return [bool, int, list] list with validation result, errors type and list of errors

validate_autoinstall_files(logger=None)[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.

@param Logger logger logger @return bool if all automatic installation files are valid

validate_autoinstall_snippet_file_path(snippet, new_snippet=False)[source]

Validate the snippet’s relative file path.

@param: str snippet automatic installation snippet relative file path @param: bool new_snippet (when set to true new filenames are allowed) @returns: str snippet or CX

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

Validate the automatic installation template’s relative file path.

@param: str autoinstall automatic installation template relative file path @param: bool for_item (enable/disable special handling for Item objects) @param: bool new_autoinstall (when set to true new filenames are allowed) @returns str automatic installation template relative file path

write_autoinstall_snippet(file_path, data)[source]
write_autoinstall_template(file_path, data)[source]

Write an automatic OS installation template

@param str file_path automatic installation template relative file path @param str data automatic installation template content

8.5. cobbler.autoinstallgen module

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

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

Bases: object

Handles conversion of internal state to the tftpboot tree layout

addAutoYaSTScript(document, type, source)[source]
createAutoYaSTScript(document, script, name)[source]
generate_autoinstall(profile=None, system=None)[source]
generate_autoinstall_for_profile(g)[source]
generate_autoinstall_for_system(sys_name)[source]
generate_autoyast(profile=None, system=None, raw_data=None)[source]
generate_config_stanza(obj, is_profile=True)[source]

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

generate_repo_stanza(obj, is_profile=True)[source]

Automatically attaches yum repos to profiles/systems in automatic installation files (kickstart 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)

get_last_errors()[source]

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

8.6. cobbler.cexceptions module

Custom exceptions for Cobbler

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

Bases: cobbler.cexceptions.CobblerException

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

Bases: Exception

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

Bases: cobbler.cexceptions.CobblerException

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

Bases: cobbler.cexceptions.CobblerException

8.7. cobbler.cli module

Command line interface for cobbler.

class cobbler.cli.CobblerCLI[source]

Bases: object

check_setup()[source]

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

cleanup_fault_string(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.

direct_command(action_name)[source]

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

follow_task(task_id)[source]
get_direct_action(object_type, args)[source]

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

get_fields(object_type)[source]

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

get_object_action(object_type, args)[source]

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

get_object_type(args)[source]

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

object_command(object_type, object_action)[source]

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

print_help()[source]

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

print_object_help(object_type)[source]

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

print_task(task_id)[source]
run(args)[source]

Process the command line and do what the user asks.

start_task(name, options)[source]
cobbler.cli.add_options_from_fields(object_type, parser, fields, network_interface_fields, settings, object_action)[source]
cobbler.cli.list_items(remote, otype)[source]
cobbler.cli.main()[source]

CLI entry point

cobbler.cli.n2s(data)[source]

Return spaces for None

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

Returns an option from an Optparse values instance

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

8.8. cobbler.clogger module

Python standard logging doesn’t super-intelligent and won’t expose filehandles, which we want. So we’re not using it.

class cobbler.clogger.Logger(logfile=None)[source]

Bases: object

critical(msg)[source]
debug(msg)[source]
error(msg)[source]
flat(msg)[source]
info(msg)[source]
warning(msg)[source]

8.9. cobbler.cobblerd module

cobbler daemon for logging remote syslog traffic during automatic installation

cobbler.cobblerd.core(api)[source]
cobbler.cobblerd.do_xmlrpc_rw(cobbler_api, settings, port)[source]
cobbler.cobblerd.do_xmlrpc_tasks(cobbler_api, settings, xmlrpc_port)[source]
cobbler.cobblerd.log(logger, msg)[source]
cobbler.cobblerd.regen_ss_file()[source]

8.10. cobbler.configgen module

configgen.py: Generate configuration data.

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

class cobbler.configgen.ConfigGen(hostname)[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()[source]

Generate configuration data for repos, files and packages. Returns a dict.

gen_config_data_for_koan()[source]

Encode configuration data. Return json object for Koan.

get_cobbler_resource(resource)[source]

Wrapper around cobbler blender method

resolve_resource_list(list_data)[source]

Substitute variables in lists. Return new list.

resolve_resource_var(string_data)[source]

Substitute variables in strings.

8.11. cobbler.download_manager module

Cobbler DownloadManager

class cobbler.download_manager.DownloadManager(collection_mgr, logger=None)[source]

Bases: object

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

8.12. cobbler.field_info module

8.13. cobbler.module_loader module

Module loader, adapted for cobbler usage

cobbler.module_loader.get_module_by_name(name)[source]
cobbler.module_loader.get_module_from_file(category, field, fallback_module_name=None)[source]

Get Python module, based on name defined in configuration file

@param category str field category in configuration file @param field str field in configuration file @param fallback_module_name str default value used if category/field is not found in configuration file @raise CX if unable to load Python module @return module Python module

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

Get module name from configuration file

@param category str field category in configuration file @param field str field in configuration file @param fallback_module_name str default value used if category/field is not found in configuration file @raise CX if unable to find configuration file @return str module name

cobbler.module_loader.get_modules_in_category(category)[source]
cobbler.module_loader.load_modules(module_path='/home/egotthold/Sources/Pycharm Projects/cobbler/cobbler/modules', blacklist=None)[source]

8.14. cobbler.power_manager module

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

class cobbler.power_manager.PowerManager(api, collection_mgr, logger=None)[source]

Bases: object

Handles power management in systems

get_power_status(system, user=None, password=None, logger=None)[source]

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

@param System system Cobbler system @param str user power management user @param str password power management password @param Logger logger logger @return bool if system is powered on

power_off(system, user=None, password=None, logger=None)[source]

Powers down a system that has power management configured.

@param System system Cobbler system @param str user power management user @param str password power management password @param Logger logger logger

power_on(system, user=None, password=None, logger=None)[source]

Powers up a system that has power management configured.

@param System system Cobbler system @param str user power management user @param str password power management password @param Logger logger logger

reboot(system, user=None, password=None, logger=None)[source]

Reboot a system that has power management configured.

@param System system Cobbler system @param str user power management user @param str password power management password @param Logger logger logger

cobbler.power_manager.get_power_command(power_type)[source]

Get power management command path

@param str power_type power management type @return str power management command path

cobbler.power_manager.get_power_types()[source]

Get possible power management types

@return list possible power management types

cobbler.power_manager.validate_power_type(power_type)[source]

Check if a power management type is valid

@param str power_type power management type @raise CX if power management type is invalid

8.15. cobbler.remote module

class cobbler.remote.CobblerThread(event_id, remote, logatron, options, task_name, api)[source]

Bases: threading.Thread

Code for Cobbler’s XMLRPC API.

on_done()[source]
run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

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.

background_aclsetup(options, token)[source]
background_buildiso(options, token)[source]

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

background_dlcontent(options, token)[source]

Download bootloaders and other support files.

background_import(options, token)[source]
background_power_system(options, token)[source]
background_replicate(options, token)[source]
background_reposync(options, token)[source]
background_signature_update(options, token)[source]
background_sync(options, token)[source]
background_validate_autoinstall_files(options, token)[source]
check(token)[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.

check_access(token, resource, arg1=None, arg2=None)[source]
check_access_no_fail(token, resource, arg1=None, arg2=None)[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.

clear_system_logs(object_id, token=None, logger=None)[source]

clears console logs of a system

copy_distro(object_id, newname, token=None)[source]
copy_file(object_id, newname, token=None)[source]
copy_image(object_id, newname, token=None)[source]
copy_item(what, object_id, newname, token=None)[source]

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

copy_mgmtclass(object_id, newname, token=None)[source]
copy_package(object_id, newname, token=None)[source]
copy_profile(object_id, newname, token=None)[source]
copy_repo(object_id, newname, token=None)[source]
copy_system(object_id, newname, token=None)[source]
disable_netboot(name, token=None, **rest)[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.

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

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

find_distro(criteria=None, expand=False, token=None, **rest)[source]
find_file(criteria=None, expand=False, token=None, **rest)[source]
find_image(criteria=None, expand=False, token=None, **rest)[source]
find_items(what, criteria=None, sort_field=None, expand=True)[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’.

:returns A list of dicts.

find_items_paged(what, criteria=None, sort_field=None, page=None, items_per_page=None, token=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.

find_mgmtclass(criteria=None, expand=False, token=None, **rest)[source]
find_package(criteria=None, expand=False, token=None, **rest)[source]
find_profile(criteria=None, expand=False, token=None, **rest)[source]
find_repo(criteria=None, expand=False, token=None, **rest)[source]
find_system(criteria=None, expand=False, token=None, **rest)[source]
find_system_by_dns_name(dns_name)[source]
generate_autoinstall(profile=None, system=None, REMOTE_ADDR=None, REMOTE_MAC=None, **rest)[source]
generate_bootcfg(profile=None, system=None, **rest)[source]
generate_gpxe(profile=None, system=None, **rest)[source]
generate_profile_autoinstall(profile)[source]
generate_script(profile=None, system=None, name=None, **rest)[source]
generate_system_autoinstall(system)[source]
get_authn_module_name(token)[source]
get_autoinstall_snippets(token=None, **rest)[source]

Returns all the automatic OS installation templates’ snippets.

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

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

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

Generate configuration data for the system specified by hostname.

get_distro(name, flatten=False, token=None, **rest)[source]
get_distro_as_rendered(name, token=None, **rest)[source]

Get distribution after passing through Cobbler’s inheritance engine.

@param str name distro name @param str token authentication token

get_distro_for_koan(name, token=None, **rest)[source]

This is a legacy function for 2.6.6 releases. :param name: The name of the distro to get. :param token: Auth token to authenticate against the api. :param rest: This is dropped in this method since it is not needed here. :return: The desired distro or ‘~’.

get_distro_handle(name, token)[source]
get_distros(page=None, results_per_page=None, token=None, **rest)[source]
get_distros_since(mtime)[source]

Return all of the distro objects that have been modified after mtime.

get_event_log(event_id)[source]

Returns the contents of a task log. Events that are not task-based do not have logs.

get_events(for_user='')[source]

Returns a dict(key=event id) = [ statetime, name, state, [read_by_who] ] If for_user is set to a string, it will only return events the user has not seen yet. If left unset, it will return /all/ events.

get_file(name, flatten=False, token=None, **rest)[source]
get_file_as_rendered(name, token=None, **rest)[source]

Get file after passing through Cobbler’s inheritance engine

@param str name file name @param str token authentication token

get_file_for_koan(name, token=None, **rest)[source]

This is a legacy function for 2.6.6 releases. :param name: Name of the file to get. :param token: Auth token to authenticate against the api. :param rest: This is dropped in this method since it is not needed here. :return: The desired file or ‘~’.

get_file_handle(name, token)[source]
get_files(page=None, results_per_page=None, token=None, **rest)[source]
get_files_since(mtime)[source]

See documentation for get_distros_since

get_image(name, flatten=False, token=None, **rest)[source]
get_image_as_rendered(name, token=None, **rest)[source]

Get repository after passing through Cobbler’s inheritance engine.

@param str name image name @param str token authentication token

get_image_for_koan(name, token=None, **rest)[source]

This is a legacy function for 2.6.6 releases. :param name: The name of the image to get. :param token: Auth token to authenticate against the api. :param rest: This is dropped in this method since it is not needed here. :return: The desired image or ‘~’

get_image_handle(name, token)[source]
get_images(page=None, results_per_page=None, token=None, **rest)[source]
get_images_since(mtime)[source]

See documentation for get_distros_since

get_item(what, name, flatten=False)[source]

Returns a dict describing a given object. what – “distro”, “profile”, “system”, “image”, “repo”, etc name – the object name to retrieve flatten – reduce dicts to string representations (True/False)

get_item_handle(what, name, 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.

get_item_names(what)[source]

Returns a list of object names (keys) for the given object type. This is just like get_items, but transmits less data.

get_items(what)[source]

Returns a list of dicts. what is the name of a cobbler object type, as described for get_item. Individual list elements are the same for get_item.

get_mgmtclass(name, flatten=False, token=None, **rest)[source]
get_mgmtclass_as_rendered(name, token=None, **rest)[source]

Get management class after passing through Cobbler’s inheritance engine

@param str name management class name @param str token authentication token

get_mgmtclass_for_koan(name, token=None, **rest)[source]

This is a legacy function for 2.6.6 releases. :param name: Name of the mgmtclass to get. :param token: Auth token to authenticate against the api. :param rest: This is dropped in this method since it is not needed here. :return: The desired mgmtclass or ~.

get_mgmtclass_handle(name, token)[source]
get_mgmtclasses(page=None, results_per_page=None, token=None, **rest)[source]
get_mgmtclasses_since(mtime)[source]

See documentation for get_distros_since

get_package(name, flatten=False, token=None, **rest)[source]
get_package_as_rendered(name, token=None, **rest)[source]

Get package after passing through Cobbler’s inheritance engine

@param str name package name @param str token authentication token

get_package_for_koan(name, token=None, **rest)[source]

This is a legacy function for 2.6.6 releases. :param name: Name of the package to get. :param token: Auth token to authenticate against the api. :param rest: This is dropped in this method since it is not needed here. :return: The desired package or ‘~’.

get_package_handle(name, token)[source]
get_packages(page=None, results_per_page=None, token=None, **rest)[source]
get_packages_since(mtime)[source]

See documentation for get_distros_since

get_profile(name, flatten=False, token=None, **rest)[source]
get_profile_as_rendered(name, token=None, **rest)[source]

Get profile after passing through Cobbler’s inheritance engine.

@param str name profile name @param str token authentication token

get_profile_for_koan(name, token=None, **rest)[source]

This is a legacy function for 2.6.6 releases. :param name: The name of the profile to get. :param token: Auth token to authenticate against the api. :param rest: This is dropped in this method since it is not needed here. :return: The desired profile or ‘~’.

get_profile_handle(name, token)[source]
get_profiles(page=None, results_per_page=None, token=None, **rest)[source]
get_profiles_since(mtime)[source]

See documentation for get_distros_since

get_random_mac(virt_type='xenpv', token=None, **rest)[source]

Wrapper for utils.get_random_mac Used in the webui

get_repo(name, flatten=False, token=None, **rest)[source]
get_repo_as_rendered(name, token=None, **rest)[source]

Get repository after passing through Cobbler’s inheritance engine.

@param str name repository name @param str token authentication token

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.

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.

get_repo_for_koan(name, token=None, **rest)[source]

This is a legacy function for 2.6.6 releases. :param name: The name of the repo to get. :param token: Auth token to authenticate against the api. :param rest: This is dropped in this method since it is not needed here. :return: The desired repo or ‘~’.

get_repo_handle(name, token)[source]
get_repos(page=None, results_per_page=None, token=None, **rest)[source]
get_repos_compatible_with_profile(profile=None, token=None, **rest)[source]

Get repos that can be used with a given profile name

get_repos_since(mtime)[source]

See documentation for get_distros_since

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

Return the contents of /etc/cobbler/settings, which is a dict.

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

Return the contents of the API signatures

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

get_system(name, flatten=False, token=None, **rest)[source]
get_system_as_rendered(name, token=None, **rest)[source]

Get profile after passing through Cobbler’s inheritance engine.

@param str name system name @param str token authentication token

get_system_for_koan(name, token=None, **rest)[source]

This is a legacy function for 2.6.6 releases. :param name: The name of the system to get. :param token: Auth token to authenticate against the api. :param rest: This is dropped in this method since it is not needed here. :return: The desired system or ‘~’.

get_system_handle(name, token)[source]
get_systems(page=None, results_per_page=None, token=None, **rest)[source]
get_systems_since(mtime)[source]

See documentation for get_distros_since

get_task_status(event_id)[source]
get_template_file_for_profile(profile_name, path, **rest)[source]

Return the templated file requested for this profile

get_template_file_for_system(system_name, path, **rest)[source]

Return the templated file requested for this system

get_user_from_token(token)[source]

Given a token returned from login, return the username that logged in with it.

get_valid_archs(token=None)[source]

Return the list of valid architectures as read in from the distro signatures data

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

Return the list of valid breeds as read in from the distro signatures data

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

Return the list of valid os_versions as read in from the distro signatures data

get_valid_os_versions_for_breed(breed, token=None, **rest)[source]

Return the list of valid os_versions for the given breed

has_item(what, name, token=None)[source]

Returns True if a given collection has an item with a given name, otherwise returns False.

is_autoinstall_in_use(ai, token=None, **rest)[source]
last_modified_time(token=None)[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.

login(login_user, login_password)[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.

logout(token)[source]

Retires a token ahead of the timeout.

modify_distro(object_id, attribute, arg, token)[source]
modify_file(object_id, attribute, arg, token)[source]
modify_image(object_id, attribute, arg, token)[source]
modify_item(what, object_id, attribute, arg, token)[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.

modify_mgmtclass(object_id, attribute, arg, token)[source]
modify_package(object_id, attribute, arg, token)[source]
modify_profile(object_id, attribute, arg, token)[source]
modify_repo(object_id, attribute, arg, token)[source]
modify_setting(setting_name, value, token)[source]
modify_system(object_id, attribute, arg, token)[source]
new_distro(token)[source]
new_file(token)[source]
new_image(token)[source]
new_item(what, token, is_subobject=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.

“what” specifies the type of object: distro, profile, system, repo, or image

new_mgmtclass(token)[source]
new_package(token)[source]
new_profile(token)[source]
new_repo(token)[source]
new_subprofile(token)[source]
new_system(token)[source]
ping()[source]

Deprecated method. Now does nothing.

power_system(system_id, power, token)[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 – token from login() call, all tasks require tokens

  • system_id – system handle

  • power – power operation (on/off/status/reboot)

read_autoinstall_snippet(file_path, token)[source]

Read an automatic OS installation snippet file

@param str file_path automatic OS installation snippet file path @param ? token @return str file content

read_autoinstall_template(file_path, token)[source]

Read an automatic OS installation template file

@param str file_path automatic OS installation template file path @param ? token @return str 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.

remove_autoinstall_snippet(file_path, token)[source]

Remove an automated OS installation snippet file

@param str file_path automated OS installation snippet file path @param ? token @return bool if operation was successful

remove_autoinstall_template(file_path, token)[source]

Remove an automatic OS installation template file

@param str file_path automatic OS installation template file path @param ? token @return bool if operation was successful

remove_distro(name, token, recursive=True)[source]
remove_file(name, token, recursive=True)[source]
remove_image(name, token, recursive=True)[source]
remove_item(what, name, token, recursive=True)[source]

Deletes an item from a collection. Note that this requires the name of the distro, not an item handle.

remove_mgmtclass(name, token, recursive=True)[source]
remove_package(name, token, recursive=True)[source]
remove_profile(name, token, recursive=True)[source]
remove_repo(name, token, recursive=True)[source]
remove_system(name, token, recursive=True)[source]
rename_distro(object_id, newname, token=None)[source]
rename_file(object_id, newname, token=None)[source]
rename_image(object_id, newname, token=None)[source]
rename_item(what, object_id, newname, token=None)[source]

Renames an object specified by object_id to a new name.

rename_mgmtclass(object_id, newname, token=None)[source]
rename_package(object_id, newname, token=None)[source]
rename_profile(object_id, newname, token=None)[source]
rename_repo(object_id, newname, token=None)[source]
rename_system(object_id, newname, token=None)[source]
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

save_distro(object_id, token, editmode='bypass')[source]
save_file(object_id, token, editmode='bypass')[source]
save_image(object_id, token, editmode='bypass')[source]
save_item(what, object_id, token, editmode='bypass')[source]

Saves a newly created or modified object to disk. Calling save is required for any changes to persist.

save_mgmtclass(object_id, token, editmode='bypass')[source]
save_package(object_id, token, editmode='bypass')[source]
save_profile(object_id, token, editmode='bypass')[source]
save_repo(object_id, token, editmode='bypass')[source]
save_system(object_id, token, editmode='bypass')[source]
sync(token)[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.

sync_dhcp(token)[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.

token_check(token)[source]

Checks to make sure a token is valid or not

upload_log_data(sys_name, file, size, offset, data, token=None, **rest)[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 /etc/cobbler/settings.

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

Return the cobbler version for compatibility testing with remote applications. See api.py for documentation.

write_autoinstall_snippet(file_path, data, token)[source]

Write an automatic OS installation snippet file

@param str file_path automatic OS installation snippet file path @param str data new file content @param ? token @return bool if operation was successful

write_autoinstall_template(file_path, data, token)[source]

Write an automatic OS installation template file

@param str file_path automatic OS installation template file path @param str data new file content @param ? token @return bool if operation was successful

xapi_object_edit(object_type, object_name, edit_type, attributes, token)[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.

edit_type - One of ‘add’, ‘rename’, ‘copy’, ‘remove’

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

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.

class cobbler.remote.CobblerXMLRPCServer(args)[source]

Bases: socketserver.ThreadingMixIn, xmlrpc.server.SimpleXMLRPCServer

class cobbler.remote.ProxiedXMLRPCInterface(api, proxy_class)[source]

Bases: object

8.16. cobbler.resource module

An Resource is a serializable thing that can appear in a Collection

class cobbler.resource.Resource(collection_mgr, is_subobject=False)[source]

Bases: cobbler.items.item.Item

Base Class for management resources.

set_action(action)[source]

All management resources have an action. Action determine weather a most resources should be created or removed, and if packages should be installed or un-installed.

set_group(group)[source]

Unix group ownership of a file or directory.

set_mode(mode)[source]

Unix file permission mode ie: ‘0644’ assigned to file and directory resources.

set_owner(owner)[source]

Unix owner of a file or directory

set_path(path)[source]

File path used by file and directory resources. Normally a absolute path of the file or directory to create or manage.

set_template(template)[source]

Path to cheetah template on cobbler’s local file system. Used to generate file data shipped to koan via json. All templates have access to flatten autoinstall_meta data.

8.17. cobbler.serializer module

Serializer code for cobbler Now adapted to support different storage backends

cobbler.serializer.deserialize(collection, topological=True)[source]

Load a collection from disk

@param Collection collection collection @param bool topological

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

Save a collection to disk

@param Collection collection collection

cobbler.serializer.serialize_delete(collection, item)[source]

Delete a collection item from disk

@param Collection collection collection @param Item item collection item

cobbler.serializer.serialize_item(collection, item)[source]

Save a collection item to disk

@param Collection collection collection @param Item item collection item

8.18. cobbler.services module

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

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)[source]
autoinstall(profile=None, system=None, REMOTE_ADDR=None, REMOTE_MAC=None, **rest)[source]

Generate automatic installation files

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

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

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

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

Generate a gPXE config

index(**args)[source]
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 compability to 2.6.6 releases. :param profile: :param system: :param REMOTE_ADDR: :param REMOTE_MAC: :param rest: :return:

list(what='systems', **rest)[source]
look(**rest)[source]
nopxe(system=None, **rest)[source]
puppet(hostname=None, **rest)[source]
script(profile=None, system=None, **rest)[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.

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

Generate a templated file for the system

trig(mode='?', profile=None, system=None, REMOTE_ADDR=None, **rest)[source]

Hook to call install triggers.

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

8.19. cobbler.settings module

Cobbler app-wide settings

class cobbler.settings.Settings[source]

Bases: object

collection_type()[source]
from_dict(_dict)[source]

Modify this object to load values in dictionary.

set(name, value)[source]
to_dict()[source]

Return an easily serializable representation of the config.

to_string()[source]

8.20. 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!)

class cobbler.templar.Templar(collection_mgr, logger=None)[source]

Bases: object

check_for_invalid_imports(data)[source]

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

render(data_input, search_table, out_path, subject=None, template_type=None)[source]

Render data_input back into a file. data_input is either a string or a filename search_table is a dict of metadata keys and values out_path if not-none writes the results to a file (though results are always returned) subject is a profile or system object, if available (for snippet eval)

render_cheetah(raw_data, search_table, subject=None)[source]

Render data_input back into a file. data_input is either a string or a filename search_table is a dict of metadata keys and values (though results are always returned) subject is a profile or system object, if available (for snippet eval)

render_jinja2(raw_data, search_table, subject=None)[source]

Render data_input back into a file. data_input is either a string or a filename search_table is a dict of metadata keys and values out_path if not-none writes the results to a file (though results are always returned) subject is a profile or system object, if available (for snippet eval)

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

class cobbler.template_api.Template[source]

Bases: object

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

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

Compile a cheetah template with cobbler modifications. Modifications include SNIPPET:: syntax replacement and inclusion of cobbler builtin methods.

read_snippet(file)[source]

Locate the appropriate snippet for the current system and profile and read it’s 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. If no snippet is located, it returns None.

sedesc(value)[source]

Escape a string for use in sed.

8.22. cobbler.tftpgen module

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

class cobbler.tftpgen.TFTPGen(collection_mgr, logger)[source]

Bases: object

Generate files provided by TFTP server

build_kernel_options(system, profile, distro, image, arch, autoinstall_path)[source]

Builds the full kernel options line.

copy_bootloaders()[source]

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

copy_images()[source]

Like copy_distros except for images.

copy_single_distro_files(d, dirtree, symlink_ok)[source]
copy_single_image_files(img)[source]
generate_bootcfg(what, name)[source]
generate_gpxe(what, name)[source]
generate_script(what, objname, script_name)[source]
get_menu_items(arch=None)[source]

Generates menu items for pxe and grub

make_pxe_menu()[source]

Generates both pxe and grub boot menus.

write_all_system_files(system, menu_items)[source]
write_pxe_file(filename, system, profile, distro, arch, image=None, include_header=True, metadata=None, format='pxe')[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”.

write_templates(obj, write_file=False, path=None)[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.

The return value is a dict of the destination file names (after variable substitution is done) and the data in the file.

8.23. cobbler.utils module

Misc heavy lifting functions for cobbler

class cobbler.utils.MntEntObj(input=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, 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.

cobbler.utils.cachefile(src, dst, api=None, logger=None)[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

cobbler.utils.cheetah_exc(exc, full=False)[source]
cobbler.utils.clear_from_fields(item, fields, is_subobject=False)[source]

Used by various item_*.py classes for automating datastructure boilerplate.

cobbler.utils.compare_versions_gt(ver1, ver2)[source]
cobbler.utils.copyfile(src, dst, api=None, logger=None)[source]
cobbler.utils.copyfile_pattern(pattern, dst, require_match=True, symlink_ok=False, cache=True, api=None, logger=None)[source]
cobbler.utils.copyremotefile(src, dst1, api=None, logger=None)[source]
cobbler.utils.dhcp_service_name(api)[source]
cobbler.utils.dhcpconf_location(api)[source]
cobbler.utils.dict_removals(results, subkey)[source]
cobbler.utils.dict_to_string(_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)

cobbler.utils.die(logger, msg)[source]
cobbler.utils.file_is_remote(file_location)[source]

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

cobbler.utils.find_distro_path(settings, distro)[source]
cobbler.utils.find_highest_files(directory, unversioned, regex)[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.

cobbler.utils.find_initrd(path)[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.

cobbler.utils.find_kernel(path)[source]

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

cobbler.utils.find_matching_files(directory, regex)[source]

Find all files in a given directory that match a given regex. Can’t use glob directly as glob doesn’t take regexen.

cobbler.utils.flatten(data)[source]
cobbler.utils.from_dict_from_fields(item, item_dict, fields)[source]
cobbler.utils.get_exc(exc, full=True)[source]
cobbler.utils.get_family()[source]

Get family of running operating system.

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

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)

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

Return the IP encoding needed for the TFTP boot tree.

cobbler.utils.get_mtab(mtab='/etc/mtab', vfstype=None)[source]
cobbler.utils.get_random_mac(api_handle, virt_type='xenpv')[source]

Generate a random MAC address. from xend/server/netif.py return: MAC address string

cobbler.utils.get_setter_methods_from_fields(item, fields)[source]

Return the name of set functions for all fields, keyed by the field name.

cobbler.utils.get_shared_secret()[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.

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

Return a list of valid architectures found in the import signatures

cobbler.utils.get_valid_breeds()[source]

Return a list of valid breeds found in the import signatures

cobbler.utils.get_valid_os_versions()[source]

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

cobbler.utils.get_valid_os_versions_for_breed(breed)[source]

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

cobbler.utils.grab_tree(api_handle, item)[source]

Climb the tree and get every node.

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

Returns the sha1sum of the file

cobbler.utils.input_boolean(value)[source]
cobbler.utils.input_string_or_dict(options, allow_multiples=True)[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.

cobbler.utils.input_string_or_list(options)[source]

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

cobbler.utils.is_ip(strdata)[source]

Return whether the argument is an IP address.

cobbler.utils.is_mac(strdata)[source]

Return whether the argument is a mac address.

cobbler.utils.is_remote_file(file)[source]
cobbler.utils.is_selinux_enabled()[source]
cobbler.utils.is_systemd()[source]

Return whether or not this system uses systemd

cobbler.utils.kopts_overwrite(system, distro, kopts, settings)[source]
cobbler.utils.linkfile(src, dst, symlink_ok=False, cache=True, api=None, logger=None)[source]

Attempt to create a link dst that points to src. Because file systems suck we attempt several different methods or bail to copyfile()

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

Loads the import signatures for distros

cobbler.utils.local_get_cobbler_api_url()[source]
cobbler.utils.local_get_cobbler_xmlrpc_url()[source]
cobbler.utils.lod_sort_by_key(_list, indexkey)[source]

Sorts a list of dictionaries by a given key in the dictionaries note: this is a destructive operation

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

things like get_distros() returns a list of a dictionaries convert this to a dict of dicts keyed off of an arbitrary field

EX: [ { “a” : 2 }, { “a : 3 } ] -> { “2” : { “a” : 2 }, “3” : { “a” : “3” }

cobbler.utils.log_exc(logger)[source]

Log an exception.

cobbler.utils.mkdir(path, mode=493, logger=None)[source]
cobbler.utils.mycmp(x, y)[source]
cobbler.utils.named_service_name(api, logger=None)[source]
cobbler.utils.namedconf_location(api)[source]
cobbler.utils.os_release()[source]
cobbler.utils.path_tail(apath, bpath)[source]

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

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

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

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

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

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

Throws a FileNotFoundException if the file does not exist at the specified location.

cobbler.utils.remote_file_exists(file_url)[source]

Return True if the remote file exists.

cobbler.utils.remove_yum_olddata(path, logger=None)[source]

Delete .olddata files that might be present from a failed run of createrepo. # FIXME: verify this is still being used

cobbler.utils.revert_strip_none(data)[source]

Does the opposite to strip_none

cobbler.utils.rmfile(path, logger=None)[source]
cobbler.utils.rmtree(path, logger=None)[source]
cobbler.utils.rmtree_contents(path, logger=None)[source]
cobbler.utils.rsync_files(src, dst, args, logger=None, quiet=True)[source]

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

cobbler.utils.run_this(cmd, args, logger)[source]

A simple wrapper around subprocess calls.

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

Runs all the trigger scripts in a given directory.

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 argumenets. Globber is a wildcard expression indicating which triggers to run.

Example: /var/lib/cobbler/triggers/blah/*

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

cobbler.utils.safe_filter(var)[source]
cobbler.utils.set_arch(self, arch, repo=False)[source]
cobbler.utils.set_breed(self, breed)[source]
cobbler.utils.set_os_version(self, os_version)[source]
cobbler.utils.set_repo_breed(self, breed)[source]
cobbler.utils.set_repo_os_version(self, os_version)[source]
cobbler.utils.set_repos(self, repos, bypass_check=False)[source]
cobbler.utils.set_serial_baud_rate(self, baud_rate)[source]
cobbler.utils.set_serial_device(self, device_number)[source]
cobbler.utils.set_virt_auto_boot(self, num)[source]

For Virt only. Specifies whether the VM should automatically boot upon host reboot 0 tells Koan not to auto_boot virtuals

cobbler.utils.set_virt_bridge(self, vbridge)[source]

The default bridge for all virtual interfaces under this profile.

cobbler.utils.set_virt_cpus(self, num)[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 :)

cobbler.utils.set_virt_disk_driver(self, driver)[source]

For Virt only. Specifies the on-disk format for the virtualized disk

cobbler.utils.set_virt_file_size(self, num)[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”

cobbler.utils.set_virt_path(self, path, for_system=False)[source]

Virtual storage location suggestion, can be overriden by koan.

cobbler.utils.set_virt_pxe_boot(self, num)[source]

For Virt only. Specifies whether the VM should use PXE for booting 0 tells Koan not to PXE boot virtuals

cobbler.utils.set_virt_ram(self, num)[source]

For Virt only. Specifies the size of the Virt RAM in MB. 0 tells Koan to just choose a reasonable default.

cobbler.utils.set_virt_type(self, vtype)[source]

Virtualization preference, can be overridden by koan.

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

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

cobbler.utils.subprocess_call(logger, cmd, shell=True, input=None)[source]
cobbler.utils.subprocess_get(logger, cmd, shell=True, input=None)[source]
cobbler.utils.subprocess_sp(logger, cmd, shell=True, input=None)[source]
cobbler.utils.to_dict_from_fields(item, fields)[source]
cobbler.utils.to_string_from_fields(item_dict, fields, interface_fields=None)[source]

item_dict is a dictionary, fields is something like item_distro.FIELDS

cobbler.utils.uniquify(seq)[source]
cobbler.utils.update_settings_file(data)[source]
cobbler.utils.zonefile_base(api)[source]

8.24. cobbler.validate module

cobbler.validate.hostname(dnsname)[source]

Validate the dns name.

@param: str dnsname (hostname or fqdn) @returns: str dnsname or CX

cobbler.validate.ipv4_address(addr)[source]

Validate an IPv4 address.

@param: str addr (ipv4 address) @returns: str addr or CX

cobbler.validate.ipv4_netmask(addr)[source]

Validate an IPv4 netmask.

@param: str addr (ipv4 netmask) @returns: str addr or CX

cobbler.validate.ipv6_address(addr)[source]

Validate an IPv6 address.

@param: str addr (ipv6 address) @returns: str addr or CX

cobbler.validate.mac_address(mac, for_item=True)[source]

Validate as an Eternet mac address.

@param: str mac (mac address) @returns: str mac or CX

cobbler.validate.name_servers(nameservers, for_item=True)[source]

Validate nameservers IP addresses, works for IPv4 and IPv6

@param: str/list nameservers (string or list of nameserver addresses) @param: bool for_item (enable/disable special handling for Item objects)

Validate nameservers search domains.

@param: str/list search (string or list of search domains) @param: bool for_item (enable/disable special handling for Item objects)

cobbler.validate.object_name(name, parent)[source]

Validate the object name.

@param: str name (object name) @param: str parent (parent object name) @returns: str name or CX

8.25. cobbler.yumgen module

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

class cobbler.yumgen.YumGen(collection_mgr)[source]

Bases: object

get_yum_config(obj, is_profile)[source]

Return one large yum repo config blob suitable for use by any target system that requests it.

8.26. Module contents