コード例 #1
0
    def copy_single_distro_files(self, d, dirtree, symlink_ok):
        distros = os.path.join(dirtree, "images")
        distro_dir = os.path.join(distros, d.name)
        utils.mkdir(distro_dir)
        kernel = utils.find_kernel(d.kernel)    # full path
        initrd = utils.find_initrd(d.initrd)    # full path

        if kernel is None:
            raise CX("kernel not found: %(file)s, distro: %(distro)s" % {"file": d.kernel, "distro": d.name})

        if initrd is None:
            raise CX("initrd not found: %(file)s, distro: %(distro)s" % {"file": d.initrd, "distro": d.name})

        # Koan manages remote kernel itself, but for consistent PXE
        # configurations the synchronization is still necessary
        if not utils.file_is_remote(kernel):
            b_kernel = os.path.basename(kernel)
            dst1 = os.path.join(distro_dir, b_kernel)
            utils.linkfile(kernel, dst1, symlink_ok=symlink_ok, api=self.api, logger=self.logger)
        else:
            b_kernel = os.path.basename(kernel)
            dst1 = os.path.join(distro_dir, b_kernel)
            utils.copyremotefile(kernel, dst1, api=None, logger=self.logger)

        if not utils.file_is_remote(initrd):
            b_initrd = os.path.basename(initrd)
            dst2 = os.path.join(distro_dir, b_initrd)
            utils.linkfile(initrd, dst2, symlink_ok=symlink_ok, api=self.api, logger=self.logger)
        else:
            b_initrd = os.path.basename(initrd)
            dst1 = os.path.join(distro_dir, b_initrd)
            utils.copyremotefile(initrd, dst1, api=None, logger=self.logger)
コード例 #2
0
ファイル: utils_test.py プロジェクト: openSUSE/cobbler
def test_find_kernel():
    # Arrange
    fake_env = "/dev/shm/fakekernelfolder"
    os.mkdir(fake_env)
    expected = os.path.join(fake_env, "vmlinuz")
    Path(expected).touch()

    # Act
    result = utils.find_kernel(fake_env)

    # Assert
    assert expected == result
コード例 #3
0
    def kernel(self, kernel: str):
        """
        Setter for the ``kernel`` property.

        :param kernel: The path to the kernel.
        :raises TypeError: If kernel was not of type str.
        :raises ValueError: If the kernel was not found.
        """
        if not isinstance(kernel, str):
            raise TypeError("kernel was not of type str")
        if not utils.find_kernel(kernel):
            raise ValueError("kernel not found: %s" % kernel)
        self._kernel = kernel
コード例 #4
0
ファイル: item_distro.py プロジェクト: ASyriy/cobbler
 def set_kernel(self, kernel):
     """
     Specifies a kernel.  The kernel parameter is a full path, a filename
     in the configured kernel directory (set in /etc/cobbler.conf) or a
     directory path that would contain a selectable kernel.  Kernel
     naming conventions are checked, see docs in the utils module
     for find_kernel.
     """
     if kernel is None or kernel == "":
         raise CX("kernel not specified")
     if utils.find_kernel(kernel):
         self.kernel = kernel
         return
     raise CX("kernel not found: %s" % kernel)
コード例 #5
0
 def set_kernel(self, kernel):
     """
     Specifies a kernel.  The kernel parameter is a full path, a filename
     in the configured kernel directory (set in /etc/cobbler.conf) or a
     directory path that would contain a selectable kernel.  Kernel
     naming conventions are checked, see docs in the utils module
     for find_kernel.
     """
     if kernel is None or kernel == "":
         raise CX("kernel not specified")
     if utils.find_kernel(kernel):
         self.kernel = kernel
         return
     raise CX("kernel not found: %s" % kernel)
コード例 #6
0
    def kernel(self, kernel: str):
        """
        Specifies a kernel. The kernel parameter is a full path, a filename in the configured kernel directory or a
        directory path that would contain a selectable kernel. Kernel naming conventions are checked, see docs in the
        utils module for ``find_kernel``.

        :param kernel: The path to the kernel.
        :raises TypeError: If kernel was not of type str.
        :raises ValueError: If the kernel was not found.
        """
        if not isinstance(kernel, str):
            raise TypeError("kernel was not of type str")
        if not utils.find_kernel(kernel):
            raise ValueError("kernel not found: %s" % kernel)
        self._kernel = kernel