summaryrefslogtreecommitdiffstats
path: root/cobbler
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2006-12-14 12:41:37 -0500
committerJim Meyering <jim@meyering.net>2006-12-14 12:41:37 -0500
commit68969dc5a3a58688fd9fa6b7dbf3d68e7bd48633 (patch)
tree12dd48057e541749028d60adcec975b9a19303d6 /cobbler
parent0910ef6cb8da45ff55da808be5cb29d157726621 (diff)
downloadthird_party-cobbler-68969dc5a3a58688fd9fa6b7dbf3d68e7bd48633.tar.gz
third_party-cobbler-68969dc5a3a58688fd9fa6b7dbf3d68e7bd48633.tar.xz
third_party-cobbler-68969dc5a3a58688fd9fa6b7dbf3d68e7bd48633.zip
Add some rudimentary ability for "cobbler import" to get kickstart trees from http.
This uses wget right now, and is rather lame. Wget gets confused and can easily end up mirroring all of the mirror, and with --no-parent on, usually mirrors hardly anything. Repo mirroring, should we also support http, will not do it this way.
Diffstat (limited to 'cobbler')
-rw-r--r--cobbler/action_import.py43
1 files changed, 26 insertions, 17 deletions
diff --git a/cobbler/action_import.py b/cobbler/action_import.py
index 04bc6f5..06f63fc 100644
--- a/cobbler/action_import.py
+++ b/cobbler/action_import.py
@@ -88,26 +88,35 @@ class Importer:
if self.mirror_name is None:
raise cexceptions.CobblerException("import_failed","must specify --mirror-name")
print "This will take a while..."
- self.path = "/var/www/cobbler/ks_mirror/%s" % self.mirror_name
+ self.path = "%s/ks_mirror/%s" % (self.settings.webdir, self.mirror_name)
try:
os.makedirs(self.path)
except:
if not os.path.exists(self.path):
raise cexceptions.CobblerException("couldn't create: %s" % (self.path))
- spacer = ""
- if not self.mirror.startswith("rsync://"):
- spacer = ' -e "ssh" '
- cmd = "rsync -a %s %s /var/www/cobbler/ks_mirror/%s --exclude-from=/etc/cobbler/rsync.exclude --delete --delete-excluded --progress" % (spacer, self.mirror, self.mirror_name)
- sub_process.call(cmd,shell=True)
- update_file = open(os.path.join(self.path,"update.sh"),"w+")
- update_file.write("#!/bin/sh\n")
- update_file.write("%s\n" % cmd)
- # leave this commented out in the file because it will
- # erase user customizations ... it is needed to update the repodata, however.
- # FIXME: cobbler reposync might want to take care of this and then update.sh would
- # go away...
- update_file.write("#cobbler import --path=%s" % self.path)
- update_file.close()
+
+
+
+ if self.mirror.startswith("http://"):
+ # http mirrors are kind of primative. rsync is better.
+ try:
+ os.makedirs("%s/ks_mirror/%s" % (self.settings.webdir, self.mirror_name))
+ except:
+ print "- didn't create %s" % self.mirror_name
+ cmd = "wget --mirror --no-parent --no-host-directories --directory-prefix %s/%s %s" % (self.settings.webdir, self.mirror_name, self.mirror)
+ print "- %s" % cmd
+ sub_process.call(cmd,shell=True)
+ else:
+ # use rsync...
+
+ spacer = ""
+ if not self.mirror.startswith("rsync://"):
+ spacer = ' -e "ssh" '
+ cmd = "rsync -a %s %s %s/ks_mirror/%s --exclude-from=/etc/cobbler/rsync.exclude --delete --delete-excluded --progress" % (spacer, self.mirror, self.mirror_name, self.settings.webdir)
+ print "- %s" % cmd
+ sub_process.call(cmd,shell=True)
+
+
if self.path is not None:
processed_repos = {}
os.path.walk(self.path, self.walker, processed_repos)
@@ -161,7 +170,7 @@ class Importer:
if distro is None:
raise cexceptions.CobblerException("orphan_distro2",profile.name,profile.distro)
kpath = distro.kernel
- if not kpath.startswith("/var/www/cobbler/ks_mirror/"):
+ if not kpath.startswith("%s/ks_mirror/" % self.settings.webdir):
continue
for entry in MATCH_LIST:
(part, kickstart) = entry
@@ -175,7 +184,7 @@ class Importer:
tokens = dirname.split("/")
tokens = tokens[:-2]
base = "/".join(tokens)
- base = base.replace("/var/www/cobbler/","")
+ base = base.replace(self.settings.webdir,"")
tree = "tree=http://%s/%s" % (self.settings.server, base)
print "*** KICKSTART TREE = %s" % tree
profile.set_ksmeta(tree)