def configure_tree_location(self, distro):
        """
        Once a distribution is identified, find the part of the distribution
        that has the URL in it that we want to use for automating the Linux
        distribution installation, and create a autoinstall_meta variable $tree
        that contains this.
        """

        base = self.rootdir

        # how we set the tree depends on whether an explicit network_root was specified
        if self.network_root is None:
            dest_link = os.path.join(self.settings.webdir, "links", distro.name)
            # create the links directory only if we are mirroring because with
            # SELinux Apache can't symlink to NFS (without some doing)
            if not os.path.exists(dest_link):
                try:
                    self.logger.info("trying symlink: %s -> %s" % (str(base), str(dest_link)))
                    os.symlink(base, dest_link)
                except:
                    # this shouldn't happen but I've seen it ... debug ...
                    self.logger.warning("symlink creation failed: %(base)s, %(dest)s" % {"base": base, "dest": dest_link})
            tree = "http://@@http_server@@/cblr/links/%s" % (distro.name)
            self.set_install_tree(distro, tree)
        else:
            # where we assign the automated installation file source is relative
            # to our current directory and the input start directory in the crawl.
            # We find the path segments between and tack them on the network source
            # path to find the explicit network path to the distro that Anaconda
            # can digest.
            tail = utils.path_tail(self.path, base)
            tree = self.network_root[:-1] + tail
            self.set_install_tree(distro, tree)
    def configure_tree_location(self, distro):
        """
        Once a distribution is identified, find the part of the distribution
        that has the URL in it that we want to use for kickstarting the
        distribution, and create a ksmeta variable $tree that contains this.
        """

        base = self.get_rootdir()

        if self.network_root is None:
            dest_link = os.path.join(self.settings.webdir, "links",
                                     distro.name)
            # create the links directory only if we are mirroring because with
            # SELinux Apache can't symlink to NFS (without some doing)
            if not os.path.exists(dest_link):
                try:
                    os.symlink(base, dest_link)
                except:
                    # this shouldn't happen but I've seen it ... debug ...
                    self.logger.warning(
                        "symlink creation failed: %(base)s, %(dest)s") % {
                            "base": base,
                            "dest": dest_link
                        }
            # how we set the tree depends on whether an explicit network_root was specified
            tree = "http://@@http_server@@/cblr/links/%s" % (distro.name)
            self.set_install_tree(distro, tree)
        else:
            # where we assign the kickstart source is relative to our current directory
            # and the input start directory in the crawl.  We find the path segments
            # between and tack them on the network source path to find the explicit
            # network path to the distro that Anaconda can digest.
            tail = utils.path_tail(self.path, base)
            tree = self.network_root[:-1] + tail
            self.set_install_tree(distro, tree)
    def configure_tree_location(self, distro):
        """
        Once a distribution is identified, find the part of the distribution
        that has the URL in it that we want to use for kickstarting the
        distribution, and create a ksmeta variable $tree that contains this.
        """

        base = self.get_rootdir()

        if self.network_root is None:
            dists_path = os.path.join(self.path, "dists")
            if os.path.isdir(dists_path):
                tree = "http://@@http_server@@/cblr/ks_mirror/%s" % (self.name)
            else:
                tree = "http://@@http_server@@/cblr/repo_mirror/%s" % (
                    distro.name)
            self.set_install_tree(distro, tree)
        else:
            # where we assign the kickstart source is relative to our current directory
            # and the input start directory in the crawl.  We find the path segments
            # between and tack them on the network source path to find the explicit
            # network path to the distro that Anaconda can digest.
            tail = utils.path_tail(self.path, base)
            tree = self.network_root[:-1] + tail
            self.set_install_tree(distro, tree)
    def get_tree_location(self, distro):
        """
        Once a distribution is identified, find the part of the distribution
        that has the URL in it that we want to use for kickstarting the
        distribution, and create a ksmeta variable $tree that contains this.
        """

        base = self.get_rootdir()

        if self.network_root is None:
            dists_path = os.path.join(self.path, "dists")
            if os.path.isdir(dists_path):
                tree = "http://@@http_server@@/cblr/ks_mirror/%s" % (self.name)
            else:
                tree = "http://@@http_server@@/cblr/repo_mirror/%s" % (distro.name)
            self.set_install_tree(distro, tree)
        else:
            # where we assign the kickstart source is relative to our current directory
            # and the input start directory in the crawl.  We find the path segments
            # between and tack them on the network source path to find the explicit
            # network path to the distro that Anaconda can digest.
            tail = utils.path_tail(self.path, base)
            tree = self.network_root[:-1] + tail
            self.set_install_tree(distro, tree)

        return
    def add_single_distro(self, name):
        # get the distro record
        distro = self.distros.find(name=name)
        if distro is None:
            return
        # copy image files to images/$name in webdir & tftpboot:
        self.sync.pxegen.copy_single_distro_files(distro, self.settings.webdir, True)
        self.tftpd.add_single_distro(distro)

        # create the symlink for this distro
        src_dir = utils.find_distro_path(self.settings, distro)
        dst_dir = os.path.join(self.settings.webdir, "links", name)
        if os.path.exists(dst_dir):
            self.logger.warning("skipping symlink, destination (%s) exists" % dst_dir)
        elif utils.path_tail(os.path.join(self.settings.webdir, "ks_mirror"), src_dir) == "":
            self.logger.warning("skipping symlink, the source (%s) is not in %s" % (src_dir, os.path.join(self.settings.webdir, "ks_mirror")))
        else:
            try:
                self.logger.info("trying symlink %s -> %s" % (src_dir, dst_dir))
                os.symlink(src_dir, dst_dir)
            except (IOError, OSError):
                self.logger.error("symlink failed (%s -> %s)" % (src_dir, dst_dir))

        # generate any templates listed in the distro
        self.sync.pxegen.write_templates(distro, write_file=True)
        # cascade sync
        kids = distro.get_children()
        for k in kids:
            self.add_single_profile(k.name, rebuild_menu=False)
        self.sync.pxegen.make_pxe_menu()
    def configure_tree_location(self, distro):
        """
        Once a distribution is identified, find the part of the distribution
        that has the URL in it that we want to use for kickstarting the
        distribution, and create a ksmeta variable $tree that contains this.
        """

        base = self.get_rootdir()

        if self.network_root is None:
            tree = self.get_install_tree(distro,base)
        else:
            # where we assign the kickstart source is relative to our current directory
            # and the input start directory in the crawl.  We find the path segments
            # between and tack them on the network source path to find the explicit
            # network path to the distro that Anaconda can digest.
            tail = utils.path_tail(self.path, base)
            tree = self.network_root[:-1] + tail

        self.set_install_tree( distro, tree)
Exemple #7
0
    def add_single_distro(self, name):
        # get the distro record
        distro = self.distros.find(name=name)
        if distro is None:
            return
        # copy image files to images/$name in webdir & tftpboot:
        self.sync.tftpgen.copy_single_distro_files(distro,
                                                   self.settings.webdir, True)
        self.tftpd.add_single_distro(distro)

        # create the symlink for this distro
        src_dir = utils.find_distro_path(self.settings, distro)
        dst_dir = os.path.join(self.settings.webdir, "links", name)
        if os.path.exists(dst_dir):
            self.logger.warning("skipping symlink, destination (%s) exists" %
                                dst_dir)
        elif utils.path_tail(
                os.path.join(self.settings.webdir, "distro_mirror"),
                src_dir) == "":
            self.logger.warning(
                "skipping symlink, the source (%s) is not in %s" %
                (src_dir, os.path.join(self.settings.webdir, "distro_mirror")))
        else:
            try:
                self.logger.info("trying symlink %s -> %s" %
                                 (src_dir, dst_dir))
                os.symlink(src_dir, dst_dir)
            except (IOError, OSError):
                self.logger.error("symlink failed (%s -> %s)" %
                                  (src_dir, dst_dir))

        # generate any templates listed in the distro
        self.sync.tftpgen.write_templates(distro, write_file=True)
        # cascade sync
        kids = distro.get_children()
        for k in kids:
            self.add_single_profile(k.name, rebuild_menu=False)
        self.sync.tftpgen.make_pxe_menu()
    def replicate_data(self):

        self.local_data = {}
        self.remote_data = {}
        self.remote_settings = self.remote.get_settings()

        self.logger.info("Querying Both Servers")
        for what in OBJ_TYPES:
            self.remote_data[what] = self.remote.get_items(what)
            self.local_data[what] = self.local.get_items(what)

        self.generate_include_map()

        if self.prune:
            self.logger.info("Removing Objects Not Stored On Master")
            obj_types = OBJ_TYPES[:]
            if len(self.system_patterns) == 0 and "system" in obj_types:
                obj_types.remove("system")
            for what in obj_types:
                self.remove_objects_not_on_master(what)
        else:
            self.logger.info("*NOT* Removing Objects Not Stored On Master")

        if not self.omit_data:
            self.logger.info("Rsyncing distros")
            for distro in self.must_include["distro"].keys():
                if self.must_include["distro"][distro] == 1:
                    self.logger.info("Rsyncing distro %s" % distro)
                    target = self.remote.get_distro(distro)
                    target_webdir = os.path.join(self.remote_settings["webdir"], "distro_mirror")
                    tail = utils.path_tail(target_webdir, target["kernel"])
                    if tail != "":
                        try:
                            # path_tail(a,b) returns something that looks like
                            # an absolute path, but it's really the sub-path
                            # from a that is contained in b. That means we want
                            # the first element of the path
                            dest = os.path.join(self.settings.webdir, "distro_mirror", tail.split("/")[1])
                            self.rsync_it("distro-%s" % target["name"], dest)
                        except:
                            self.logger.error("Failed to rsync distro %s" % distro)
                            continue
                    else:
                        self.logger.warning("Skipping distro %s, as it doesn't appear to live under distro_mirror" % distro)

            self.logger.info("Rsyncing repos")
            for repo in self.must_include["repo"].keys():
                if self.must_include["repo"][repo] == 1:
                    self.rsync_it("repo-%s" % repo, os.path.join(self.settings.webdir, "repo_mirror", repo), "repo")

            self.logger.info("Rsyncing distro repo configs")
            self.rsync_it("cobbler-distros/config/", os.path.join(self.settings.webdir, "distro_mirror", "config"))
            self.logger.info("Rsyncing automatic installation templates & snippets")
            self.rsync_it("cobbler-autoinstalls", "/var/lib/cobbler/autoinstall_templates")
            self.rsync_it("cobbler-snippets", "/var/lib/cobbler/autoinstall_snippets")
            self.logger.info("Rsyncing triggers")
            self.rsync_it("cobbler-triggers", "/var/lib/cobbler/triggers")
            self.logger.info("Rsyncing scripts")
            self.rsync_it("cobbler-scripts", "/var/lib/cobbler/scripts")
        else:
            self.logger.info("*NOT* Rsyncing Data")

        self.logger.info("Removing Objects Not Stored On Local")
        for what in OBJ_TYPES:
            self.add_objects_not_on_local(what)

        self.logger.info("Updating Objects Newer On Remote")
        for what in OBJ_TYPES:
            self.replace_objects_newer_on_remote(what)
 def get_name_from_path(self,dirname):
     return self.mirror_name + "-".join(utils.path_tail(os.path.dirname(self.path),dirname).split("/"))