8.1.1. cobbler.actions package
8.1.1.1. Subpackages
- 8.1.1.1.1. cobbler.actions.buildiso package
8.1.1.2. Submodules
8.1.1.3. 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: CobblerAPI)[source]
Bases:
object
TODO
- modacl(isadd: bool, isuser: bool, who: str) None [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) 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.
8.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: CobblerAPI)[source]
Bases:
object
Validates whether the system is reasonably well configured for serving up content. This is the code behind ‘cobbler check’.
- static check_bind_bin(status: List[str]) None [source]
Check if bind is installed.
- Parameters
status – The status list with possible problems.
- static check_bootloaders(status: List[str]) None [source]
Check if network bootloaders are installed
- Parameters
status – The status list with possible problems.
- check_ctftpd_dir(status: List[str]) None [source]
Check if
cobbler.conf
’s tftpboot directory exists.- Parameters
status – The status list with possible problems.
- check_debmirror(status: List[str]) None [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.
- static check_dhcpd_bin(status: List[str]) None [source]
Check if dhcpd is installed.
- Parameters
status – The status list with possible problems.
- check_dhcpd_conf(status: List[str]) None [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.
- static check_dnsmasq_bin(status: List[str]) None [source]
Check if dnsmasq is installed.
- Parameters
status – The status list with possible problems.
- static check_for_cman(status: List[str]) None [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: List[str]) None [source]
Check if the default password of Cobbler was changed.
- Parameters
status – The status list with possible problems.
- check_for_ksvalidator(status: List[str]) None [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: List[str]) None [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: List[str]) None [source]
Check if there are unsynchronized repositories which need an update.
- Parameters
status – The status list with possible problems.
- static check_for_wget_curl(status: List[str]) None [source]
Check to make sure wget or curl is installed
- Parameters
status – The status list with possible problems.
- check_iptables(status: List[str]) None [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: List[str]) None [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: List[str]) None [source]
Check that rsync is enabled to autostart.
- Parameters
status – The status list with possible problems.
- check_selinux(status: List[str]) None [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: List[str], which: str, notes: str = '') None [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: List[str]) None [source]
Check if cobbler.conf’s tftpboot directory exists
- Parameters
status – The status list with possible problems.
8.1.1.5. cobbler.actions.hardlink module
Hard links Cobbler content together to save space.
8.1.1.6. cobbler.actions.importer module
This module contains the logic that kicks of the cobbler import
process. This is extracted logic from api.py
that is essentially calling modules/mangers/import_signatures.py
with some preparatory code.
- class cobbler.actions.importer.Importer(api: CobblerAPI)[source]
Bases:
object
Wrapper class to adhere to the style of all other actions.
- run(mirror_url: str, mirror_name: str, network_root: Optional[str] = None, autoinstall_file: Optional[str] = None, rsync_flags: Optional[str] = None, arch: Optional[str] = None, breed: Optional[str] = None, os_version: Optional[str] = None) bool [source]
Automatically import a directory tree full of distribution files.
- Parameters
mirror_url – Can be a string that represents a path, a user@host syntax for SSH, or an rsync:// address. If mirror_url is a filesystem path and mirroring is not desired, set network_root to something like “nfs://path/to/mirror_url/root”
mirror_name – The name of the mirror.
network_root – the remote path (nfs/http/ftp) for the distro files
autoinstall_file – user-specified response file, which will override the default
rsync_flags – Additional flags that will be passed to the rsync call that will sync everything to the Cobbler webroot.
arch – user-specified architecture
breed – user-specified breed
os_version – user-specified OS version
8.1.1.7. cobbler.actions.log module
Cobbler Trigger Module that managed the logs associated with a Cobbler system.
8.1.1.8. cobbler.actions.mkloaders module
Cobbler action to create bootable Grub2 images.
This action calls grub2-mkimage for all bootloader formats configured in Cobbler’s settings. See man(1) grub2-mkimage for available formats.
- class cobbler.actions.mkloaders.MkLoaders(api: CobblerAPI)[source]
Bases:
object
Action to create bootloader images.
- create_directories() None [source]
Create the required directories so that this succeeds. If existing, do nothing. This should create the tree for all supported bootloaders, regardless of the capabilities to symlink/install/build them.
- make_grub() None [source]
Create symlink of the GRUB 2 bootloader in case it is available on the system. Additionally build the loaders for other architectures if the modules to do so are available.
- make_ipxe() None [source]
Create symlink of the iPXE bootloader in case it is available on the system.
- make_shim() None [source]
Create symlink of the shim bootloader in case it is available on the system.
- cobbler.actions.mkloaders.find_file(glob_path: Path, file_regex: Pattern[str]) Optional[Path] [source]
Given a path glob and a file regex, return a full path of the file.
- Param
glob_path: Glob of a path, e.g. Path(‘/var/*/rhn’)
- Param
file_regex: A regex for a filename in the path
- Returns
The full file path or None if no file was found
- cobbler.actions.mkloaders.get_syslinux_version() int [source]
This calls syslinux and asks for the version number.
- Returns
The major syslinux release number.
- Raises
subprocess.CalledProcessError – Error raised by
subprocess.run
in case syslinux does not return zero.
- cobbler.actions.mkloaders.mkimage(image_format: str, image_filename: Path, modules: List[str]) None [source]
Create a bootable image of GRUB using grub2-mkimage.
- Parameters
image_format – Format of the image that is being created. See man(1) grub2-mkimage for a list of supported formats.
image_filename – Location of the image that is being created.
modules – List of GRUB modules to include into the image
- Raises
subprocess.CalledProcessError – Error raised by
subprocess.run
.
- cobbler.actions.mkloaders.symlink(target: Path, link: Path, skip_existing: bool = False) None [source]
Create a symlink LINK pointing to TARGET.
- Parameters
target – File/directory that the link will point to. The file/directory must exist.
link – Filename for the link.
skip_existing – Controls if existing links are skipped, defaults to False.
- Raises
FileNotFoundError –
target
is not an existing file.FileExistsError –
skip_existing
is False andlink
already exists.
8.1.1.9. cobbler.actions.replicate module
Replicate from a Cobbler master.
- class cobbler.actions.replicate.Replicate(api: CobblerAPI)[source]
Bases:
object
This class contains the magic to replicate a Cobbler instance to another Cobbler instance.
- add_objects_not_on_local(obj_type: str) None [source]
Add objects locally which are not present on the slave but on the master.
- Parameters
obj_type –
- generate_include_map() None [source]
Method that generates the information that is required to perform the replicate option.
- link_distros() None [source]
Link a distro from its location into the web directory to make it available for usage.
- remove_objects_not_on_master(obj_type: str) None [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: str) None [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: str, to_path: str, object_type: Optional[str] = None) 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.
object_type – If set to “repo” this will take the repo rsync options instead of the global ones.
- run(cobbler_master: Optional[str] = None, port: str = '80', distro_patterns: Optional[str] = None, profile_patterns: Optional[str] = None, system_patterns: Optional[str] = None, repo_patterns: Optional[str] = None, image_patterns: Optional[str] = None, prune: bool = False, omit_data: bool = False, sync_all: bool = False, use_ssl: bool = False) None [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.
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.
8.1.1.10. 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: CobblerAPI, tries: int = 1, nofail: bool = False)[source]
Bases:
object
Handles conversion of internal state to the tftpboot tree layout.
- apt_sync(repo: Repo) None [source]
Handle copying of http:// and ftp:// debian repos.
- Parameters
repo – The apt repository to sync.
- create_local_file(dest_path: str, repo: 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: Repo, dirname: str, fnames: Any) None [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: Dict[str, Any]) Tuple[Optional[Tuple[Any, ...]], 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[Any, Any] [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.
- static reposync_cmd() List[str] [source]
Determine reposync command
- Returns
The path to the reposync command. If dnf exists it is used instead of reposync.
- rhn_sync(repo: Repo) None [source]
Handle mirroring of RHN repos.
- Parameters
repo – The repo object to synchronize.
- rsync_sync(repo: Repo) None [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) None [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.
- sync(repo: Repo) None [source]
Conditionally sync a repo, based on type.
- Parameters
repo – The repo to sync.
- update_permissions(repo_path: str) None [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: str, func: Callable[[Any, str, List[str]], None], arg: Any) None [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.
8.1.1.11. cobbler.actions.status module
Reports on automatic installation activity by examining the logs in /var/log/cobbler.
- class cobbler.actions.status.CobblerStatusReport(api: CobblerAPI, mode: str)[source]
Bases:
object
TODO
- catalog(profile_or_system: str, name: str, ip_address: str, start_or_stop: str, timestamp: float) None [source]
Add a system to
cobbler status
.- Parameters
profile_or_system – This can be
system
orprofile
.name – The name of the object.
ip_address – The ip of the system to watch.
start_or_stop – This parameter may be
start
orstop
timestamp – Timestamp as returned by
time.time()
- static collect_logfiles() List[str] [source]
Collects all installation logfiles from
/var/log/cobbler/
. This will also collect gzipped logfiles.- Returns
List of absolute paths that are matching the filepattern
install.log
orinstall.log.x
, where x is a number equal or greater than zero.
- get_printable_results() str [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
.
- process_results() Dict[Any, Any] [source]
Look through all systems which were collected and update the status.
- Returns
Return
ip_data
of the object.
8.1.1.12. 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: CobblerAPI, verbose: bool = True, dhcp: Optional[DhcpManagerModule] = None, dns: Optional[DnsManagerModule] = None, tftpd: Optional[TftpManagerModule] = None)[source]
Bases:
object
Handles conversion of internal state to the tftpboot tree layout
- add_single_distro(distro_obj: Distro) None [source]
Sync adding a single distro.
- Parameters
name – The name of the distribution.
- add_single_image(image_obj: Image) None [source]
Sync adding a single image.
- Parameters
name – The name of the image.
- add_single_profile(profile: Profile, 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(system_obj: System) None [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(distro_obj: Distro) None [source]
Sync removing a single distro.
- Parameters
name – The name of the distribution.
- remove_single_image(image_obj: Image) None [source]
Sync removing a single image.
- Parameters
image_obj – The name of the image.
Sync removing a single menu.
- Parameters
rebuild_menu – Whether to rebuild the grub/… menu or not.
- remove_single_profile(profile_obj: Profile, rebuild_menu: bool = True) None [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(system_obj: System) None [source]
Sync removing a single system.
- Parameters
name – The name of the system.
- rsync_gen() None [source]
Generate rsync modules of all repositories and distributions
- Raises
OSError –
- run() None [source]
Syncs the current configuration file with the config tree. Using the
Check().run_
functions previously is recommended
8.1.1.13. 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.