Exemplo n.º 1
0
    def __init__(self, collection_mgr, tries=1, nofail=False, logger=None):
        """
        Constructor

        :param collection_mgr: The object which holds all information in Cobbler.
        :param tries: The number of tries before the operation fails.
        :param nofail: This sets the strictness of the reposync result handling.
        :param logger: The logger to audit all actions with.
        """
        self.verbose = True
        self.api = collection_mgr.api
        self.collection_mgr = collection_mgr
        self.distros = collection_mgr.distros()
        self.profiles = collection_mgr.profiles()
        self.systems = collection_mgr.systems()
        self.settings = collection_mgr.settings()
        self.repos = collection_mgr.repos()
        self.rflags = self.settings.reposync_flags
        self.tries = tries
        self.nofail = nofail
        self.logger = logger
        self.dlmgr = download_manager.DownloadManager(self.collection_mgr, self.logger)

        if logger is None:
            self.logger = clogger.Logger()

        self.logger.info("hello, reposync")
Exemplo n.º 2
0
    def signature_update(self, logger):
        try:
            url = self.settings().signature_url
            dlmgr = download_manager.DownloadManager(self._collection_mgr,
                                                     self.logger)
            # write temp json file
            tmpfile = tempfile.NamedTemporaryFile()
            sigjson = dlmgr.urlread(url)
            tmpfile.write(sigjson.text.encode())
            tmpfile.flush()
            logger.debug("Successfully got file from %s" %
                         self.settings().signature_url)
            # test the import without caching it
            try:
                utils.load_signatures(tmpfile.name, cache=False)
            except:
                logger.error(
                    "Downloaded signatures failed test load (tempfile = %s)" %
                    tmpfile.name)

            # rewrite the real signature file and import it for real
            f = open(self.settings().signature_path, "w")
            f.write(sigjson.text)
            f.close()

            utils.load_signatures(self.settings().signature_path)
        except:
            utils.log_exc(logger)
Exemplo n.º 3
0
    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.

        :param force: If the target path should be overwritten, even if there are already files present.
        :type force: bool
        """

        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)
Exemplo n.º 4
0
 def __init__(self, server=None, req=None):
     self.server = server
     self.remote = None
     self.req = req
     self.collection_mgr = manager.CollectionManager(self)
     self.logger = None
     self.dlmgr = download_manager.DownloadManager(self.collection_mgr,
                                                   self.logger)
Exemplo n.º 5
0
    def __init__(self, server=None, req=None):
        """
        Default constructor which sets up everything to be ready.

        :param server: The domain to run at.
        :param req: This parameter is unused.
        """
        # ToDo: Remove req attribute.
        self.server = server
        self.remote = None
        self.req = req
        self.collection_mgr = manager.CollectionManager(self)
        self.dlmgr = download_manager.DownloadManager(self.collection_mgr)
Exemplo n.º 6
0
    def __init__(self, collection_mgr, tries=1, nofail=False, logger=None):
        """
        Constructor
        """
        self.verbose = True
        self.api = collection_mgr.api
        self.collection_mgr = collection_mgr
        self.distros = collection_mgr.distros()
        self.profiles = collection_mgr.profiles()
        self.systems = collection_mgr.systems()
        self.settings = collection_mgr.settings()
        self.repos = collection_mgr.repos()
        self.rflags = self.settings.reposync_flags
        self.tries = tries
        self.nofail = nofail
        self.logger = logger
        self.dlmgr = download_manager.DownloadManager(self.collection_mgr,
                                                      self.logger)

        if logger is None:
            self.logger = clogger.Logger()

        self.logger.info("hello, reposync")