Source code for cobbler.actions.dlcontent

"""
Downloads bootloader content for all arches for when the user doesn't want to supply their own.
"""

from builtins import object
import os

from cobbler import clogger
from cobbler import download_manager


[docs]class ContentDownloader(object): def __init__(self, collection_mgr, logger=None): """ Constructor """ self.collection_mgr = collection_mgr self.settings = collection_mgr.settings() if logger is None: logger = clogger.Logger() self.logger = logger
[docs] def run(self, force=False): """ Download bootloader content for all of the latest bootloaders, since the user has chosen to not supply their own. You may ask "why not get this from yum", we also want this to be able to work on Debian and further do not want folks to have to install a cross compiler. For those that don't like this approach they can still source their cross-arch bootloader content manually. """ content_server = "https://cobbler.github.io/loaders" dest = "/var/lib/cobbler/loaders" files = ( ("%s/README" % content_server, "%s/README" % dest), ("%s/COPYING.yaboot" % content_server, "%s/COPYING.yaboot" % dest), ("%s/COPYING.syslinux" % content_server, "%s/COPYING.syslinux" % dest), ("%s/yaboot-1.3.17" % content_server, "%s/yaboot" % dest), ("%s/pxelinux.0-3.86" % content_server, "%s/pxelinux.0" % dest), ("%s/menu.c32-3.86" % content_server, "%s/menu.c32" % dest), ("%s/grub-0.97-x86.efi" % content_server, "%s/grub-x86.efi" % dest), ("%s/grub-0.97-x86_64.efi" % content_server, "%s/grub-x86_64.efi" % dest), ) dlmgr = download_manager.DownloadManager(self.collection_mgr, self.logger) for src, dst in files: if os.path.exists(dst) and not force: self.logger.info("path %s already exists, not overwriting existing content, use --force if you wish to update" % dst) continue self.logger.info("downloading %s to %s" % (src, dst)) dlmgr.download_file(src, dst)
# EOF