summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2007-11-02 12:22:24 -0400
committerMichael DeHaan <mdehaan@redhat.com>2007-11-02 12:22:24 -0400
commit877358dab2b2ae58adc9a0e73a114c8e8f261c5b (patch)
tree481f465b9ec4d836d3342b889d4e02612104ca22
parentb05468107f6bbb82153d244acb0c72be47a81e94 (diff)
downloadthird_party-cobbler-877358dab2b2ae58adc9a0e73a114c8e8f261c5b.tar.gz
third_party-cobbler-877358dab2b2ae58adc9a0e73a114c8e8f261c5b.tar.xz
third_party-cobbler-877358dab2b2ae58adc9a0e73a114c8e8f261c5b.zip
Work on getting the repos to be templated, largely complete, pending more testing.
-rw-r--r--cobbler.spec2
-rw-r--r--cobbler/action_litesync.py8
-rw-r--r--cobbler/action_sync.py88
-rw-r--r--cobbler/item_repo.py21
-rw-r--r--docs/cobbler.pod8
-rw-r--r--setup.py4
6 files changed, 77 insertions, 54 deletions
diff --git a/cobbler.spec b/cobbler.spec
index 4c250d8..26a5d62 100644
--- a/cobbler.spec
+++ b/cobbler.spec
@@ -100,6 +100,8 @@ test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT
%dir /var/www/cobbler/kickstarts
%dir /var/www/cobbler/kickstarts_sys
%dir /var/www/cobbler/repo_mirror
+%dir /var/www/cobbler/repos_profile
+%dir /var/www/cobbler/repos_system
%dir /var/www/cobbler/ks_mirror
%dir /var/www/cobbler/ks_mirror/config
%dir /var/www/cobbler/images
diff --git a/cobbler/action_litesync.py b/cobbler/action_litesync.py
index a35d16c..0cd4318 100644
--- a/cobbler/action_litesync.py
+++ b/cobbler/action_litesync.py
@@ -78,12 +78,12 @@ class BootLiteSync:
raise CX(_("error in profile lookup"))
# rebuild profile_list YAML file in webdir
self.sync.write_listings()
- # rebuild the yum configuration files for any attached repos
- self.sync.retemplate_yum_repos(obj,is_profile)
# add profiles/$name YAML file in webdir
self.sync.write_profile_file(profile)
# generate kickstart for kickstarts/$name/ks.cfg in webdir
self.sync.validate_kickstart_for_specific_profile(profile)
+ # rebuild the yum configuration files for any attached repos
+ self.sync.retemplate_yum_repos(profile,True)
def remove_single_profile(self, name):
# rebuild profile_list YAML file in webdir
@@ -101,13 +101,13 @@ class BootLiteSync:
# rebuild system_list file in webdir
self.sync.regen_ethers() # /etc/ethers, for dnsmasq & rarpd
self.sync.regen_hosts() # /var/lib/cobbler/cobbler_hosts, pretty much for dnsmasq
- # rebuild the yum configuration files for any attached repos
- self.sync.retemplate_yum_repos(obj,is_profile)
self.sync.write_listings()
# write the PXE and YAML files for the system
self.sync.write_all_system_files(system)
# per system kickstarts
self.sync.validate_kickstart_for_specific_system(system)
+ # rebuild the yum configuration files for any attached repos
+ self.sync.retemplate_yum_repos(system,False)
def remove_single_system(self, name):
system_record = self.systems.find(name=name)
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py
index 76ad5b9..635fe65 100644
--- a/cobbler/action_sync.py
+++ b/cobbler/action_sync.py
@@ -78,6 +78,7 @@ class BootSync:
self.clean_trees()
self.copy_bootloaders()
self.copy_distros()
+ self.retemplate_all_yum_repos()
self.validate_kickstarts()
self.build_trees()
if self.settings.manage_dhcp:
@@ -266,10 +267,10 @@ class BootSync:
if not x.endswith(".py"):
self.rmfile(path)
if os.path.isdir(path):
- if not x in ["webui", "localmirror","repo_mirror","ks_mirror","kickstarts","kickstarts_sys","distros","images","systems","profiles","links"] :
+ if not x in ["webui", "localmirror","repo_mirror","ks_mirror","kickstarts","kickstarts_sys","distros","images","systems","profiles","links","repo_profile","repo_system"] :
# delete directories that shouldn't exist
self.rmtree(path)
- if x in ["kickstarts","kickstarts_sys","images","systems","distros","profiles"]:
+ if x in ["kickstarts","kickstarts_sys","images","systems","distros","profiles","repo_profile","repo_system"]:
# clean out directory contents
self.rmtree_contents(path)
self.rmtree_contents(os.path.join(self.settings.tftpboot, "pxelinux.cfg"))
@@ -410,6 +411,12 @@ class BootSync:
return buf
+ def get_repo_segname(self, is_profile):
+ if is_profile:
+ return "repos_profile"
+ else:
+ return "repos_system"
+
def generate_repo_stanza(self, obj, is_profile=True):
"""
@@ -420,18 +427,38 @@ class BootSync:
buf = ""
blended = utils.blender(self.api, False, obj)
- # for all yum repo templates we have rendered rendered ...
- globpath = os.path.join(self.settings.webdir, "repos_profile", blended["name"], "*")
- configs = glob.glob(globpath)
- # add a yum configuration line that makes the kickstart use them ...
+ configs = self.get_repo_filenames(obj,is_profile)
for c in configs:
name = c.split("/")[-1].replace(".repo","")
- url = c.replace(self.settings.webdir, "%s/cobbler" % blended["server"])
+ url = self.get_repo_baseurl(blended["server"], name)
buf = buf + "repo --name=%s --baseurl=%s\n" % (name, url)
return buf
+ def get_repo_baseurl(self, server, repo_name):
+ """
+ Construct the URL to a repo definition.
+ """
+ return "http://%s/cobbler/repo_mirror/%s" % (server, repo_name)
+
+ def get_repo_filenames(self, obj, is_profile=True):
+ """
+ For a given object, return the paths to repo configuration templates
+ that will be used to generate per-object repo configuration files and
+ baseurls
+ """
+
+ blended = utils.blender(self.api, False, obj)
+ urlseg = self.get_repo_segname(is_profile)
+
+ topdir = "%s/%s/%s/*.repo" % (self.settings.webdir, urlseg, blended["name"])
+ os.system("ls %s" % topdir)
+ files = glob.glob(topdir)
+
+ return files
+
+
def generate_config_stanza(self, obj, is_profile=True):
"""
@@ -442,31 +469,39 @@ class BootSync:
if self.settings.yum_core_mirror_from_server:
return
- if is_profile:
- urlseg = "repos_profile"
- else:
- urlseg = "repos_system"
+ urlseg = self.get_repo_segname(is_profile)
distro = obj.get_conceptual_parent()
if not is_profile:
distro = distro.get_conceptual_parent()
blended = utils.blender(self.api, False, obj)
- globpath = os.path.join(self.settings.webdir, "repos_profile", blended["name"], "*")
- configs = glob.glob(globpath)
-
+ configs = self.get_repo_filenames(obj, is_profile)
+ buf = ""
+
# for each kickstart template we have rendered ...
for c in configs:
+
name = c.split("/")[-1].replace(".repo","")
- url = c.replace(self.settings.webdir, "%s/cobbler" % blended["server"])
+ url = self.get_repo_baseurl(blended["server"], name)
buf = buf + "repo --name=%s --baseurl=%s\n" % (name, url)
# add the line to create the yum config file on the target box
- buf = buf + "wget http://%s/cblr/%s/%s/%s/config.repo --output-document=/etc/yum.repos.d/%s.repo\n" % (blended["server"], urlseg, blended["name"], name)
+ conf = self.get_repo_config_file(blended["server"],urlseg,blended["name"],name)
+ buf = buf + "wget %s --output-document=/etc/yum.repos.d/%s.repo\n" % (conf, name)
return buf
+ def get_repo_config_file(self,server,urlseg,obj_name,repo_name):
+ """
+ Construct the URL to a repo config file that is usable in kickstart
+ for use with yum. This is different than the templates cobbler reposync
+ creates, as this file will allow the server to migrate and have different
+ variables for different subnets/profiles/etc.
+ """
+ return "http://%s/cblr/%s/%s/%s.repo" % (server,urlseg,obj_name,repo_name)
+
def validate_kickstarts_per_system(self):
"""
PXE provisioning needs kickstarts evaluated per system.
@@ -617,13 +652,17 @@ class BootSync:
self.write_distro_file(d)
for p in self.profiles:
- self.retemplate_yum_repos(p,True)
self.write_profile_file(p)
for system in self.systems:
- self.retemplate_yum_repos(system,False)
self.write_all_system_files(system)
+ def retemplate_all_yum_repos(self):
+ for p in self.profiles:
+ self.retemplate_yum_repos(p,True)
+ for system in self.systems:
+ self.retemplate_yum_repos(system,False)
+
def retemplate_yum_repos(self,obj,is_profile):
# FIXME: blender could use caching for performance
# FIXME: make stanza generation code load stuff from the right place
@@ -639,9 +678,6 @@ class BootSync:
else:
outseg = "repos_system"
- confdir = os.path.join(self.settings.webdir, outseg)
- shutil.rmtree(confdir, ignore_errors=True, onerror=None)
-
input_files = []
# tack on all the install source repos IF there is more than one.
@@ -655,16 +691,18 @@ class BootSync:
input_files.append(os.path.join(self.settings.webdir, "repo_mirror", repo, "config.repo"))
for infile in input_files:
- dispname = infile.split("/")[-1].replace(".repo","")
- outdir = os.path.join(confdir, outseg, blended["name"])
+ dispname = infile.split("/")[-2]
+ confdir = os.path.join(self.settings.webdir, outseg)
+ outdir = os.path.join(confdir, blended["name"])
self.mkdir(outdir)
try:
infile_h = open(infile)
except:
- raise CX(_("cobbler reposync needs to be run on repo (%s) first" % dispname))
+ print _("WARNING: cobbler reposync needs to be run on repo (%s), then re-run cobbler sync") % dispname
+ continue
infile_data = infile_h.read()
infile_h.close()
- outfile = os.path.join(outdir, "config.repo")
+ outfile = os.path.join(outdir, "%s.repo" % dispname)
self.apply_template(infile_data, blended, outfile)
diff --git a/cobbler/item_repo.py b/cobbler/item_repo.py
index 106759d..3424d75 100644
--- a/cobbler/item_repo.py
+++ b/cobbler/item_repo.py
@@ -33,7 +33,6 @@ class Repo(item.Item):
self.name = None
self.mirror = (None, '<<inherit>>')[is_subobject]
self.keep_updated = ('y', '<<inherit>>')[is_subobject]
- self.local_filename = ("", '<<inherit>>')[is_subobject]
self.rpm_list = ("", '<<inherit>>')[is_subobject]
self.createrepo_flags = ("-c cache", '<<inherit>>')[is_subobject]
self.depth = 2 # arbitrary, as not really apart of the graph
@@ -44,7 +43,6 @@ class Repo(item.Item):
self.name = self.load_item(seed_data, 'name')
self.mirror = self.load_item(seed_data, 'mirror')
self.keep_updated = self.load_item(seed_data, 'keep_updated','y')
- self.local_filename = self.load_item(seed_data, 'local_filename')
self.rpm_list = self.load_item(seed_data, 'rpm_list')
self.createrepo_flags = self.load_item(seed_data, 'createrepo_flags', '-c cache')
self.arch = self.load_item(seed_data, 'arch')
@@ -84,22 +82,6 @@ class Repo(item.Item):
self.keep_updated = True
return True
- def set_local_filename(self,fname):
- """
- If this repo is to be automatically configured to be "in use" for profiles that reference it,
- the local filename must be specified. This allows, for instance, to define a repo foo and autocreate
- a foo.repo on the system that corresponds to it in /etc/yum.repos.d.
-
- You can overwrite default repos by doing this, so
- setting a value of something like "fedora-updates" has some significance. If you just name it foo, it's
- a bonus repo of your own special stuff. This is only used if the distro has set_repos() called on it
- with the name of this repo.
-
- NOTE: this should not contain the ".repo" in the filename. The kickstart will add that part.
- """
- self.local_filename = fname
- return True
-
def set_rpm_list(self,rpms):
"""
Rather than mirroring the entire contents of a repository (Fedora Extras, for instance,
@@ -147,7 +129,6 @@ class Repo(item.Item):
'name' : self.name,
'mirror' : self.mirror,
'keep_updated' : self.keep_updated,
- 'local_filename' : self.local_filename,
'rpm_list' : self.rpm_list,
'createrepo_flags' : self.createrepo_flags,
'arch' : self.arch,
@@ -159,7 +140,6 @@ class Repo(item.Item):
buf = _("repo : %s\n") % self.name
buf = buf + _("mirror : %s\n") % self.mirror
buf = buf + _("keep updated : %s\n") % self.keep_updated
- buf = buf + _("local filename : %s\n") % self.local_filename
buf = buf + _("rpm list : %s\n") % self.rpm_list
buf = buf + _("createrepo_flags : %s\n") % self.createrepo_flags
buf = buf + _("arch : %s\n") % self.arch
@@ -189,7 +169,6 @@ class Repo(item.Item):
'mirror-name' : self.set_name,
'mirror' : self.set_mirror,
'keep-updated' : self.set_keep_updated,
- 'local-filename' : self.set_local_filename,
'rpm-list' : self.set_rpm_list,
'createrepo-flags' : self.set_createrepo_flags
}
diff --git a/docs/cobbler.pod b/docs/cobbler.pod
index fb58a97..0ca8d85 100644
--- a/docs/cobbler.pod
+++ b/docs/cobbler.pod
@@ -274,7 +274,7 @@ on your network will result in faster, more up-to-date installations and faster
are only provisioning a home setup, this will probably be overkill, though it can be very useful
for larger setups (labs, datacenters, etc).
-B<cobbler repo add --mirror=url --name=string [--local-filename=string] [--rpmlist=list] [--creatrepo-flags=string] [--keep-updated=Y/N] [--arch=string]>
+B<cobbler repo add --mirror=url --name=string [--rpmlist=list] [--creatrepo-flags=string] [--keep-updated=Y/N] [--arch=string]>
=over
@@ -308,9 +308,9 @@ somewhat experimental.
This name is used as the save location for the mirror. If the mirror represented, say, Fedora Core
6 i386 updates, a good name would be "fc6i386updates". Again, be specific.
-This name corresponds with values given to the --repos parameter of "cobbler profile add". If a profile
-has a --repos value that matches the name here, that repo can be automatically set up during provisioning.
-This means that, if supported by Anaconda, the repo can be used during kickstart install -- and -- either way, it can be automatically configured for use by the provisioned clients (see --local-filename).
+This name corresponds with values given to the --repos parameter of "cobbler profile add". If a profile has a --repos value that matches the name given here, that repo can be automatically set up during provisioning (when supported) and installed systems will also use the boot server as a mirror (unless "yum_core_mirror_from_server" is disabled in the settings file).
+
+Distros that can make use of yum repositories during kickstart include FC6 and later, RHEL 5 and later, and derivative distributions.
See the documentation on "cobbler profile add" for more information.
diff --git a/setup.py b/setup.py
index 02e566c..a780c21 100644
--- a/setup.py
+++ b/setup.py
@@ -32,6 +32,8 @@ if __name__ == "__main__":
vw_kickstarts = "/var/www/cobbler/kickstarts"
vw_kickstarts_sys = "/var/www/cobbler/kickstarts_sys"
vw_repomirror = "/var/www/cobbler/repo_mirror"
+ vw_repoprofile = "/var/www/cobbler/repos_profile"
+ vw_reposystem = "/var/www/cobbler/repos_system"
vw_ksmirror = "/var/www/cobbler/ks_mirror"
vw_ksmirrorc = "/var/www/cobbler/ks_mirror/config"
vw_images = "/var/www/cobbler/images"
@@ -117,6 +119,8 @@ if __name__ == "__main__":
(vw_kickstarts, []),
(vw_kickstarts_sys, []),
(vw_repomirror, []),
+ (vw_repoprofile, []),
+ (vw_reposystem, []),
(vw_ksmirror, []),
(vw_ksmirrorc, []),
(vw_distros, []),