Beispiel #1
0
    def printable(self):
        """
	Human-readable representation.
	"""
        kstr = utils.find_kernel(self.kernel)
        istr = utils.find_initrd(self.initrd)
        buf = _("distro               : %s\n") % self.name
        buf = buf + _("architecture         : %s\n") % self.arch
        buf = buf + _("breed                : %s\n") % self.breed
        buf = buf + _("created              : %s\n") % time.ctime(self.ctime)
        buf = buf + _("comment              : %s\n") % self.comment
        buf = buf + _("initrd               : %s\n") % istr
        buf = buf + _("kernel               : %s\n") % kstr
        buf = buf + _("kernel options       : %s\n") % self.kernel_options
        buf = buf + _("ks metadata          : %s\n") % self.ks_meta
        if self.tree_build_time != -1:
            buf = buf + _("tree build time      : %s\n") % time.ctime(self.tree_build_time)
        else:
            buf = buf + _("tree build time      : %s\n") % "N/A"
        buf = buf + _("modified             : %s\n") % time.ctime(self.mtime)
        buf = buf + _("mgmt classes         : %s\n") % self.mgmt_classes
        buf = buf + _("os version           : %s\n") % self.os_version
        buf = buf + _("owners               : %s\n") % self.owners
        buf = buf + _("post kernel options  : %s\n") % self.kernel_options_post
        buf = buf + _("redhat mgmt key      : %s\n") % self.redhat_management_key
        buf = buf + _("redhat mgmt server   : %s\n") % self.redhat_management_server
        buf = buf + _("template files       : %s\n") % self.template_files
        return buf
Beispiel #2
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 })

        # Kernels referenced by remote URL are passed through to koan directly,
        # no need for copying the kernel locally:
        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)

        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)
Beispiel #3
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 utils.find_kernel(kernel):
            self.kernel = kernel
            return True
        raise CX(_("kernel not found"))
Beispiel #4
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)

        if "nexenta" == d.breed:
            try:
                os.makedirs(os.path.join(distro_dir, 'platform', 'i86pc', 'kernel', 'amd64'))
                os.makedirs(os.path.join(distro_dir, 'platform', 'i86pc', 'amd64'))
            except OSError:
                pass
            b_kernel = os.path.basename(kernel)
            utils.linkfile(kernel, os.path.join(distro_dir, 'platform', 'i86pc', 'kernel', 'amd64', b_kernel),
                           symlink_ok=symlink_ok, api=self.api, logger=self.logger)
            b_initrd = os.path.basename(initrd)
            utils.linkfile(initrd, os.path.join(distro_dir, 'platform', 'i86pc', 'amd64', b_initrd),
                           symlink_ok=symlink_ok, api=self.api, logger=self.logger)

            # the [:-7] removes the architecture
            if os.path.isdir(os.path.join('/var', 'www', 'cobbler', 'links', d.name, 'install_profiles')):
                shutil.rmtree(os.path.join('/var', 'www', 'cobbler', 'links', d.name, 'install_profiles'))
            shutil.copytree(os.path.join('/var', 'lib', 'cobbler', 'kickstarts', 'install_profiles'),
                            os.path.join('/var', 'www', 'cobbler', 'links', d.name, 'install_profiles'))
Beispiel #5
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)

        if "nexenta" == d.breed:
            try:
                os.makedirs(os.path.join(distro_dir, 'platform', 'i86pc', 'kernel', 'amd64'))
                os.makedirs(os.path.join(distro_dir, 'platform', 'i86pc', 'amd64'))
            except OSError:
                pass
            b_kernel = os.path.basename(kernel)
            utils.linkfile(kernel, os.path.join(distro_dir, 'platform', 'i86pc', 'kernel', 'amd64', b_kernel),
                           symlink_ok=symlink_ok, api=self.api, logger=self.logger)
            b_initrd = os.path.basename(initrd)
            utils.linkfile(initrd, os.path.join(distro_dir, 'platform', 'i86pc', 'amd64', b_initrd),
                           symlink_ok=symlink_ok, api=self.api, logger=self.logger)

            # the [:-7] removes the architecture
            if os.path.isdir(os.path.join('/var', 'www', 'cobbler', 'links', d.name, 'install_profiles')):
                shutil.rmtree(os.path.join('/var', 'www', 'cobbler', 'links', d.name, 'install_profiles'))
            shutil.copytree(os.path.join('/var', 'lib', 'cobbler', 'kickstarts', 'install_profiles'),
                            os.path.join('/var', 'www', 'cobbler', 'links', d.name, 'install_profiles'))
Beispiel #6
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 True
     raise CX("kernel not found: %s" % kernel)
Beispiel #7
0
    def copy_single_distro_files(self, d):
        for dirtree in [self.bootloc, self.settings.webdir]: 
            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 or not os.path.isfile(kernel):
                raise CX("kernel not found: %(file)s, distro: %(distro)s" % { "file" : d.kernel, "distro" : d.name })
            if initrd is None or not os.path.isfile(initrd):
                raise CX("initrd not found: %(file)s, distro: %(distro)s" % { "file" : d.initrd, "distro" : d.name })
            b_kernel = os.path.basename(kernel)
            b_initrd = os.path.basename(initrd)
            allow_symlink=False
            if dirtree == self.settings.webdir:
                allow_symlink=True
            dst1 = os.path.join(distro_dir, b_kernel)
            dst2 = os.path.join(distro_dir, b_initrd)
            utils.linkfile(kernel, dst1, symlink_ok=allow_symlink, api=self.api, logger=self.logger)

            utils.linkfile(initrd, dst2, symlink_ok=allow_symlink, api=self.api, logger=self.logger)
Beispiel #8
0
 def test_kernel_scan(self):
     self.assertTrue(utils.find_kernel(self.fk_kernel))
     self.assertFalse(utils.find_kernel("filedoesnotexist"))
     self._expeq(self.fk_kernel, utils.find_kernel(self.topdir))