8. cobbler package¶
8.1. Subpackages¶
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_system
(ref, check_for_duplicate_names=False, check_for_duplicate_netinfo=False, save=True, logger=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.
-
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.
-
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_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.
-
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.
-
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
-
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
-
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.
-
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.
-
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
-
get_autoinstall_templates
()[source]¶ Get automatic OS installation templates
@return list automatic installation templates
-
log_autoinstall_validation_errors
(errors_type, errors)[source]¶ Log automatic installation file errors
@param int errors_type validation errors type
-
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_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
-
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
-
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)
-
8.6. cobbler.cexceptions module¶
Custom exceptions for Cobbler
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.
-
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”
-
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.
8.9. cobbler.cobblerd module¶
cobbler daemon for logging remote syslog traffic during automatic installation
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.
8.11. cobbler.download_manager module¶
Cobbler DownloadManager
8.12. cobbler.field_info module¶
8.13. cobbler.module_loader module¶
Module loader, adapted for cobbler usage
-
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
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
-
-
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
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.
-
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_buildiso
(options, token)[source]¶ Generates an ISO in /var/www/cobbler/pub that can be used to install profiles without using PXE.
-
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_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.
-
copy_item
(what, object_id, newname, token=None)[source]¶ Creates a new object that matches an existing object, as specified by an id.
-
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_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.
-
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_config_data
(hostname)[source]¶ Generate configuration data for the system specified by hostname.
-
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_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_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_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_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_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_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_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_random_mac
(virt_type='xenpv', token=None, **rest)[source]¶ Wrapper for utils.get_random_mac Used in the webui
-
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_repos_compatible_with_profile
(profile=None, token=None, **rest)[source]¶ Get repos that can be used with a given profile name
-
get_settings
(token=None, **rest)[source]¶ Return the contents of /etc/cobbler/settings, which is a dict.
-
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_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_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.
-
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.
-
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.
-
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 finallysave_*
methods. The handle only exists in memory until saved.“what” specifies the type of object:
distro
,profile
,system
,repo
, orimage
-
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_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.
-
rename_item
(what, object_id, newname, token=None)[source]¶ Renames an object specified by object_id to a new name.
-
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_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.
-
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.
-
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)
-
-
class
cobbler.remote.
CobblerXMLRPCServer
(args)[source]¶ Bases:
socketserver.ThreadingMixIn
,xmlrpc.server.SimpleXMLRPCServer
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_mode
(mode)[source]¶ Unix file permission mode ie: ‘0644’ assigned to file and directory resources.
-
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.
serialize
(collection)[source]¶ Save a collection to disk
@param Collection collection collection
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.
-
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.
-
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.
-
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:
-
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
-
8.19. cobbler.settings module¶
Cobbler app-wide settings
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.
-
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.
Generates menu items for pxe and grub
Generates both pxe and grub boot menus.
-
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.
clear_from_fields
(item, fields, is_subobject=False)[source]¶ Used by various item_*.py classes for automating datastructure boilerplate.
-
cobbler.utils.
copyfile_pattern
(pattern, dst, require_match=True, symlink_ok=False, cache=True, api=None, logger=None)[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.
file_is_remote
(file_location)[source]¶ Returns true if the file is remote and referenced via a protocol we support.
-
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.
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_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.
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_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.
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.
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.
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.
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.
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.
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_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.
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.
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)
8.25. cobbler.yumgen module¶
Builds out filesystem trees/data based on the object tree. This is the code behind ‘cobbler sync’.