9.1.1. cobbler.actions package¶
9.1.1.1. Submodules¶
9.1.1.2. cobbler.actions.acl module¶
Configures acls for various users/groups so they can access the Cobbler command line as non-root. Now that CLI is largely remoted (XMLRPC) this is largely just useful for not having to log in (access to shared-secret) file but also grants access to hand-edit various cobbler_collections files and other useful things.
- class cobbler.actions.acl.AclConfig(api)[source]¶
Bases:
object
- modacl(isadd: bool, isuser: bool, who: str)[source]¶
Modify the acls for Cobbler on the filesystem.
- Parameters
isadd – If true then the
who
will be added. If false thenwho
will be removed.isuser – If true then the
who
may be a user. If false thenwho
may be a group.who – The user or group to be added or removed.
- run(adduser: Optional[str] = None, addgroup: Optional[str] = None, removeuser: Optional[str] = None, removegroup: Optional[str] = None)[source]¶
Automate setfacl commands. Only one of the four may be specified but one option also must be specified.
- Parameters
adduser – Add a user to be able to manage Cobbler.
addgroup – Add a group to be able to manage Cobbler.
removeuser – Remove a user to be able to manage Cobbler.
removegroup – Remove a group to be able to manage Cobbler.
- Raises
CX – Raised in case not enough arguments are specified.
9.1.1.3. cobbler.actions.buildiso module¶
Builds bootable CD images that have PXE-equivalent behavior for all Cobbler distros/profiles/systems currently in memory.
- class cobbler.actions.buildiso.BuildIso(api)[source]¶
Bases:
object
Handles conversion of internal state to the isolinux tree layout
- calculate_grub_name(distro) str [source]¶
This function checks the bootloaders_formats in our settings and then checks if there is a match between the architectures and the distribution architecture. :param distro: The distribution to get the GRUB2 loader name for.
- copy_boot_files(distro, destdir: str, new_filename: str = '')[source]¶
Copy kernel/initrd to destdir with (optional) newfile prefix :param distro: Distro object to return the boot files for. :param destdir: The destination directory. :param new_filename: The file new filename. Kernel and Initrd have different extensions to seperate them from
each another.
- filter_items(all_objs, selected_items: List[str]) list [source]¶
Return a list of valid profile or system objects selected from all profiles or systems by name, or everything if selected_items is empty. :param all_objs: The collection of items to filter. :param selected_items: The list of names :raises ValueError: Second option that this error is raised
when the list of filtered systems or profiles is empty.
- Returns
A list of valid profiles OR systems. If an error occurred this is logged and an empty list is returned.
- filter_profiles(selected_items: Optional[List[str]] = None) list [source]¶
Return a list of valid profile objects selected from all profiles by name, or everything if
selected_items
is empty. :param selected_items: A list of names to include in the returned list. :return: A list of valid profiles. If an error occurred this is logged and an empty list is returned.
9.1.1.4. cobbler.actions.check module¶
Cobbler Trigger Module that checks against a list of hardcoded potential common errors in a Cobbler installation.
- class cobbler.actions.check.CobblerCheck(api)[source]¶
Bases:
object
Validates whether the system is reasonably well configured for serving up content. This is the code behind ‘cobbler check’.
- check_bind_bin(status)[source]¶
Check if bind is installed.
- Parameters
status – The status list with possible problems.
- check_bootloaders(status)[source]¶
Check if network bootloaders are installed
- Parameters
status – The status list with possible problems.
- check_ctftpd_dir(status)[source]¶
Check if
cobbler.conf
’s tftpboot directory exists.- Parameters
status – The status list with possible problems.
- check_debmirror(status)[source]¶
Check if debmirror is available and the config file for it exists. If the distro family is suse then this will pass without checking.
- Parameters
status – The status list with possible problems.
- check_dhcpd_bin(status)[source]¶
Check if dhcpd is installed.
- Parameters
status – The status list with possible problems.
- check_dhcpd_conf(status)[source]¶
NOTE: this code only applies if Cobbler is NOT set to generate a
dhcp.conf
file.Check that dhcpd appears to be configured for pxe booting. We can’t assure file correctness. Since a Cobbler user might have dhcp on another server, it’s okay if it’s not there and/or not configured correctly according to automated scans.
- Parameters
status – The status list with possible problems.
- check_dnsmasq_bin(status)[source]¶
Check if dnsmasq is installed.
- Parameters
status – The status list with possible problems.
- check_for_cman(status)[source]¶
Check if the fence agents are available. This is done through checking if the binary
fence_ilo
is present in/sbin
or/usr/sbin
.- Parameters
status – The status list with possible problems. The status list with possible problems.
- check_for_default_password(status)[source]¶
Check if the default password of Cobbler was changed.
- Parameters
status – The status list with possible problems.
- check_for_ksvalidator(status)[source]¶
Check if the
ksvalidator
is present in/usr/bin
.- Parameters
status – The status list with possible problems. The status list with possible problems.
- check_for_unreferenced_repos(status)[source]¶
Check if there are repositories which are not used and thus could be removed.
- Parameters
status – The status list with possible problems.
- check_for_unsynced_repos(status)[source]¶
Check if there are unsynchronized repositories which need an update.
- Parameters
status – The status list with possible problems.
- check_for_wget_curl(status)[source]¶
Check to make sure wget or curl is installed
- Parameters
status – The status list with possible problems.
- check_iptables(status)[source]¶
Check if iptables is running. If yes print the needed ports. This is unavailable on Debian, SUSE and CentOS7 as a service. However this only indicates that the way of persisting the iptable rules are persisted via other means.
- Parameters
status – The status list with possible problems.
- check_name(status)[source]¶
If the server name in the config file is still set to localhost automatic installations run from koan will not have proper kernel line parameters.
- Parameters
status – The status list with possible problems.
- check_rsync_conf(status)[source]¶
Check that rsync is enabled to autostart.
- Parameters
status – The status list with possible problems.
- check_selinux(status)[source]¶
Suggests various SELinux rules changes to run Cobbler happily with SELinux in enforcing mode.
- Parameters
status – The status list with possible problems.
- check_service(status, which, notes='')[source]¶
Check if the service command is available or the old init.d system has to be used.
- Parameters
status – The status list with possible problems.
which – The service to check for.
notes – A manual not to attach.
- check_tftpd_dir(status)[source]¶
Check if cobbler.conf’s tftpboot directory exists
- Parameters
status – The status list with possible problems.
9.1.1.5. cobbler.actions.hardlink module¶
Hard links Cobbler content together to save space.
9.1.1.6. cobbler.actions.log module¶
Cobbler Trigger Module that managed the logs associated with a Cobbler system.
9.1.1.7. cobbler.actions.replicate module¶
Replicate from a Cobbler master.
- class cobbler.actions.replicate.Replicate(api)[source]¶
Bases:
object
This class contains the magic to replicate a Cobbler instance to another Cobbler instance.
- add_objects_not_on_local(obj_type)[source]¶
Add objects locally which are not present on the slave but on the master.
- Parameters
obj_type –
- link_distros()[source]¶
Link a distro from its location into the web directory to make it available for usage.
- remove_objects_not_on_master(obj_type)[source]¶
Remove objects on this slave which are not on the master.
- Parameters
obj_type – The type of object which should be synchronized.
- replace_objects_newer_on_remote(obj_type)[source]¶
Replace objects which are newer on the local slave then on the remote slave
- Parameters
obj_type – The type of object to synchronize.
- rsync_it(from_path, to_path, type: Optional[str] = None)[source]¶
Rsync from a source to a destination with the rsync options Cobbler was configured with.
- Parameters
from_path – The source to rsync from.
to_path – The destination to rsync to.
type – If set to “repo” this will take the repo rsync options instead of the global ones.
- run(cobbler_master=None, port: str = '80', distro_patterns=None, profile_patterns=None, system_patterns=None, repo_patterns=None, image_patterns=None, mgmtclass_patterns=None, package_patterns=None, file_patterns=None, prune: bool = False, omit_data=False, sync_all: bool = False, use_ssl: bool = False)[source]¶
Get remote profiles and distros and sync them locally
- Parameters
cobbler_master – The remote url of the master server.
port – The remote port of the master server.
distro_patterns – The pattern of distros to sync.
profile_patterns – The pattern of profiles to sync.
system_patterns – The pattern of systems to sync.
repo_patterns – The pattern of repositories to sync.
image_patterns – The pattern of images to sync.
mgmtclass_patterns – The pattern of management classes to sync.
package_patterns – The pattern of packages to sync.
file_patterns – The pattern of files to sync.
prune – If the local server should be pruned before coping stuff.
omit_data – If the data behind images etc should be omitted or not.
sync_all – If everything should be synced (then the patterns are useless) or not.
use_ssl – If HTTPS or HTTP should be used.
9.1.1.8. cobbler.actions.report module¶
Report from a Cobbler master. FIXME: reinstante functionality for 2.0
- class cobbler.actions.report.Report(api)[source]¶
Bases:
object
- fielder(structure: dict, fields_list: list)[source]¶
Return data from a subset of fields of some item
- Parameters
structure – The item structure to report.
fields_list – The list of fields which should be returned.
- Returns
The same item with only the given subset of information.
- print_formatted_data(data, order: list, report_type: str, noheaders: bool)[source]¶
Used for picking the correct format to output data as
- Parameters
data – The list of iteratable items for table output.
order – The list of fields which are available in the table file.
noheaders – Whether headers are printed to the output or not.
report_type – The type of report which should be used.
- reporting_csv(info, order: list, noheaders: bool) str [source]¶
Formats data on ‘info’ for csv output
- Parameters
info – The list of iteratable items for csv output.
order – The list of fields which are available in the csv file.
noheaders – Whether headers are printed to the output or not.
- Returns
The string with the csv.
- reporting_doku(info, order: list, noheaders: bool) str [source]¶
Formats data on ‘info’ for doku wiki table output
- Parameters
info – The list of iteratable items for table output.
order – The list of fields which are available in the table file.
noheaders – Whether headers are printed to the output or not.
- Returns
The string with the generated table.
- reporting_list_names2(collection, name: str)[source]¶
Prints a specific object in a collection.
- Parameters
collection – The collections object to print a collection from.
name – The name of the collection to print.
- reporting_mediawiki(info, order: list, noheaders: bool) str [source]¶
Formats data on ‘info’ for mediawiki table output
- Parameters
info – The list of iteratable items for table output.
order – The list of fields which are available in the table file.
noheaders – Whether headers are printed to the output or not.
- Returns
The string with the generated table.
- reporting_print_all_fields(collection, report_name: str, report_type: str, report_noheaders: bool) str [source]¶
Prints all fields in a collection as a table given the report type
- Parameters
collection – The collection to report.
report_name – The name of the report.
report_type – The type of report to give.
report_noheaders – Report without the headers. (May be useful for machine parsing)
- Returns
A report with all fields included pretty printed or machine readable.
- reporting_print_sorted(collection)[source]¶
Prints all objects in a collection sorted by name
- Parameters
collection – The collection to print.
- reporting_print_x_fields(collection, report_name: str, report_type: str, report_fields: str, report_noheaders: bool)[source]¶
Prints specific fields in a collection as a table given the report type
- Parameters
collection – The collection to report.
report_name – The name of the report.
report_type – The type of report to give.
report_fields – The fields which should be included in the report.
report_noheaders – Report without the headers. (May be useful for machine parsing)
- reporting_trac(info, order: list, noheaders: bool) str [source]¶
Formats data on ‘info’ for trac wiki table output
- Parameters
info – The list of iteratable items for table output.
order – The list of fields which are available in the table file.
noheaders – Whether headers are printed to the output or not.
- Returns
The string with the generated table.
- run(report_what: Optional[str] = None, report_name: Optional[str] = None, report_type: Optional[str] = None, report_fields: Optional[str] = None, report_noheaders: Optional[bool] = None)[source]¶
Get remote profiles and distros and sync them locally
Handles original report output
Handles all fields of report outputs as table given a format
Handles specific fields of report outputs as table given a format
- Parameters
report_what – What should be reported. May be “all”.
report_name – The name of the report.
report_type – The type of report to give.
report_fields – The fields which should be included in the report.
report_noheaders – Report without the headers. (May be useful for machine parsing)
9.1.1.9. cobbler.actions.reposync module¶
Builds out and synchronizes yum repo mirrors. Initial support for rsync, perhaps reposync coming later.
- class cobbler.actions.reposync.RepoSync(api, tries: int = 1, nofail: bool = False)[source]¶
Bases:
object
Handles conversion of internal state to the tftpboot tree layout.
- apt_sync(repo)[source]¶
Handle copying of http:// and ftp:// debian repos.
- Parameters
repo – The apt repository to sync.
- create_local_file(dest_path: str, repo, output: bool = True) str [source]¶
Creates Yum config files for use by reposync
Two uses: (A) output=True, Create local files that can be used with yum on provisioned clients to make use of this mirror. (B) output=False, Create a temporary file for yum to feed into yum for mirroring
- Parameters
dest_path – The destination path to create the file at.
repo – The repository object to create a file for.
output – See described above.
- Returns
The name of the file which was written.
- createrepo_walker(repo, dirname: str, fnames)[source]¶
Used to run createrepo on a copied Yum mirror.
- Parameters
repo – The repository object to run for.
dirname – The directory to run in.
fnames – Not known what this is for.
- gen_urlgrab_ssl_opts(yumopts) Union[str, bool] [source]¶
This function translates yum repository options into the appropriate options for python-requests
- Parameters
yumopts – The options to convert.
- Returns
A tuple with the cert and a boolean if it should be verified or not.
- librepo_getinfo(dirname: str) dict [source]¶
Used to get records from a repomd.xml file of downloaded rpmmd repository.
- Parameters
dirname – The local path of rpmmd repository.
- Returns
The dict representing records from a repomd.xml file of rpmmd repository.
- reposync_cmd() str [source]¶
Determine reposync command
- Returns
The path to the reposync command. If dnf exists it is used instead of reposync.
- rhn_sync(repo)[source]¶
Handle mirroring of RHN repos.
- Parameters
repo – The repo object to synchronize.
- rsync_sync(repo)[source]¶
Handle copying of rsync:// and rsync-over-ssh repos.
- Parameters
repo – The repo to sync via rsync.
- run(name: Optional[str] = None, verbose: bool = True)[source]¶
Syncs the current repo configuration file with the filesystem.
- Parameters
name – The name of the repository to synchronize.
verbose – If the action should be logged verbose or not.
- update_permissions(repo_path)[source]¶
Verifies that permissions and contexts after an rsync are as expected. Sending proper rsync flags should prevent the need for this, though this is largely a safeguard.
- Parameters
repo_path – The path to update the permissions of.
- cobbler.actions.reposync.repo_walker(top, func, arg)[source]¶
Directory tree walk with callback function.
For each directory in the directory tree rooted at top (including top itself, but excluding ‘.’ and ‘..’), call func(arg, dirname, fnames). dirname is the name of the directory, and fnames a list of the names of the files and subdirectories in dirname (excluding ‘.’ and ‘..’). func may modify the fnames list in-place (e.g. via del or slice assignment), and walk will only recurse into the subdirectories whose names remain in fnames; this can be used to implement a filter, or to impose a specific order of visiting. No semantics are defined for, or required of, arg, beyond that arg is always passed to func. It can be used, e.g., to pass a filename pattern, or a mutable object designed to accumulate statistics. Passing None for arg is common.
- Parameters
top – The directory that should be taken as root. The root dir will also be included in the processing.
func – The function that should be executed.
arg – The arguments for that function.
9.1.1.10. cobbler.actions.status module¶
Reports on automatic installation activity by examining the logs in /var/log/cobbler.
- class cobbler.actions.status.CobblerStatusReport(api, mode: str)[source]¶
Bases:
object
- catalog(profile_or_system: str, name: str, ip, start_or_stop: str, ts: float)[source]¶
Add a system to
cobbler status
.- Parameters
profile_or_system – This can be
system
orprofile
.name – The name of the object.
ip – The ip of the system to watch.
start_or_stop – This parameter may be
start
orstop
ts – Don’t know what this does.
- get_printable_results()[source]¶
Convert the status of Cobbler from a machine readable form to human readable.
- Returns
A nice formatted representation of the results of
cobbler status
.
9.1.1.11. cobbler.actions.sync module¶
Builds out filesystem trees/data based on the object tree. This is the code behind ‘cobbler sync’.
- class cobbler.actions.sync.CobblerSync(api, verbose: bool = True, dhcp=None, dns=None, tftpd=None)[source]¶
Bases:
object
Handles conversion of internal state to the tftpboot tree layout
- add_single_distro(name)[source]¶
Sync adding a single distro.
- Parameters
name – The name of the distribution.
- add_single_image(name)[source]¶
Sync adding a single image.
- Parameters
name – The name of the image.
- add_single_profile(name: str, rebuild_menu: bool = True) Optional[bool] [source]¶
Sync adding a single profile.
- Parameters
name – The name of the profile.
rebuild_menu – Whether to rebuild the grub/… menu or not.
- Returns
True
if this succeeded.
- add_single_system(name: str)[source]¶
Sync adding a single system.
- Parameters
name – The name of the system.
- clean_link_cache()[source]¶
All files which are linked into the cache will be deleted so the cache can be rebuild.
- clean_trees()[source]¶
Delete any previously built pxelinux.cfg tree and virt tree info and then create directories.
Note: for SELinux reasons, some information goes in
/tftpboot
, some in/var/www/cobbler
and some must be duplicated in both. This is because PXE needs tftp, and automatic installation and Virt operations need http. Only the kernel and initrd images are duplicated, which is unfortunate, though SELinux won’t let me give them two contexts, so symlinks are not a solution. Otherwise duplication is minimal.
- remove_single_distro(name)[source]¶
Sync removing a single distro.
- Parameters
name – The name of the distribution.
- remove_single_image(name)[source]¶
Sync removing a single image.
- Parameters
name – The name of the image.
Sync removing a single menu. :param rebuild_menu: Whether to rebuild the grub/… menu or not.
- remove_single_profile(name: str, rebuild_menu: bool = True)[source]¶
Sync removing a single profile.
- Parameters
name – The name of the profile.
rebuild_menu – Whether to rebuild the grub/… menu or not.
- remove_single_system(name: str)[source]¶
Sync removing a single system.
- Parameters
name – The name of the system.
- run()[source]¶
Syncs the current configuration file with the config tree. Using the
Check().run_
functions previously is recommended
9.1.1.12. Module contents¶
The action module is responsible for containing one Python module for each action which Cobbler offers. The code should never be dependent on another module or on other parts. An action should request the exact data it requires and nothing more.