From 8962f0761a0a0962afd1efdcb4928de29e658ebf Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Thu, 5 Apr 2007 12:03:12 -0400 Subject: Some cleanup/fixing in the reposync code. --- TODO | 8 +++----- cobbler/action_reposync.py | 28 ++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/TODO b/TODO index 8542380..7fafb16 100644 --- a/TODO +++ b/TODO @@ -5,12 +5,12 @@ always: 2 - better documentation (particularly online articles) core: -1 - re-support repo add taking http:// urls, which will use repotrack/reposync -1 - import over http://, ftp:// in addition to existing file and rsync:// and ssh:// 5 - "check" should check if services (esp httpd) are started +1 - better tracking solution. RHEL4 doesn't do syslog, and RHEL4 server doesn't work w/ the current soln. user interface: -5 - "cobbler add" should be distinguished from "edit" so as to not overwrite +3 - "cobbler add" should be distinguished from "edit" so as to not overwrite + ex: "cobbler edit profile --name=asdf --kickstart=foo" should just change the kickstart. 5 - GTK (or Web) UI for Cobbler ? 5 - have -v or --version @@ -30,9 +30,7 @@ ideas: 3 - explore use cases for pykickstart "plugin" concept 5 - mDNS discovery of server from koan 1 - (stateless) scripts triggered on profile/system/distro add -1 - (stateless) support for diskless object w/o dummy profile/distro small bugs: 3 - no logrotate or cleanup for /var/log/cobbler (kickstart tracking) -3 - add warning if kernel arg length is exceeded 3 - relax detection of kernel/initrd to accept any file diff --git a/cobbler/action_reposync.py b/cobbler/action_reposync.py index 9ff1753..fc01061 100644 --- a/cobbler/action_reposync.py +++ b/cobbler/action_reposync.py @@ -51,14 +51,14 @@ class RepoSync: self.verbose = verbose for repo in self.repos: - print "considering: %s" % repo repo_path = os.path.join(self.settings.webdir, "repo_mirror", repo.name) mirror = repo.mirror if not os.path.isdir(repo_path) and not repo.mirror.lower().startswith("rhn://"): os.makedirs(repo_path) # if path contains http:// or ftp://, use with yum's reposync. # else do rsync - if mirror.lower().find("http://") != -1 or mirror.lower().find("ftp://") or mirror.lower().find("rhn://") != -1: + lower = mirror.lower() + if lower.startswith("http://") or lower.startswith("ftp://") or lower.startswith("rhn://"): self.do_reposync(repo) else: self.do_rsync(repo) @@ -72,6 +72,13 @@ class RepoSync: FIXME: support for mirrorlist? """ + if not os.path.exists("/usr/bin/reposync"): + raise cexceptions.CobblerException("no /usr/bin/reposync found, please install yum-utils") + + is_rhn = False + if repo.mirror.lower().startswith("rhn://"): + is_rhn = True + if not repo.keep_updated: print "- %s is set to not be updated" % repo.name return True @@ -80,25 +87,30 @@ class RepoSync: store_path = os.path.join(self.settings.webdir, "repo_mirror") dest_path = os.path.join(store_path, repo.name) temp_path = os.path.join(store_path, ".origin") - if not os.path.isdir(temp_path) and not repo.mirror.lower().startswith("rhn://"): + if not os.path.isdir(temp_path) and not is_rhn: + # if doing the rhn sync, reposync will make the directory os.makedirs(temp_path) - if not repo.mirror.lower().startswith("rhn://"): - cmd = "/usr/bin/reposync --repoid=%s --download_path=%s" % (repo.name, store_path) + if not is_rhn: + # rhn sync takes different params + temp_file = self.create_local_file(repo, temp_path, output=False) + cmd = "/usr/bin/reposync --config=%s --repoid=%s --download_path=%s" % (temp_file, repo.name, store_path) print "- %s" % cmd else: + # this requires that you have entitlements for the server and you give the mirror as rhn://$channelname rest = repo.mirror[6:] cmd = "/usr/bin/reposync -r %s --download_path=%s" % (rest, store_path) print "- %s" % cmd # downloads using -r use the value given for -r as part of the output dir, so create a symlink with the name the user - # gave such that everything still works as intended. - print "- %s" % dest_path + # gave such that everything still works as intended and the sync code still works if not os.path.exists(dest_path): from1 = os.path.join(self.settings.webdir, "repo_mirror", rest) print "- symlink: %s -> %s" % (from1, dest_path) os.symlink(from1, dest_path) rc = sub_process.call(cmd, shell=True) - temp_file = self.create_local_file(repo, temp_path, output=False) + if is_rhn: + # now that the directory exists, we can create the config file. this is different from the normal case. + temp_file = self.create_local_file(repo, temp_path, output=False) if rc !=0: raise cexceptions.CobblerException("cobbler reposync failed") arg = None -- cgit