From a72c34cae409841956d97b22e9102f723cb66d8e Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Thu, 6 Sep 2007 12:45:27 -0400 Subject: Ben Riggs patch to allow for reposyncs of explicit repos + tweak to repo object to ensure items get serialized as booleans. --- cobbler/action_reposync.py | 38 ++++++++++++++++++-------------------- cobbler/api.py | 4 ++-- cobbler/cobbler.py | 2 +- cobbler/item_repo.py | 9 ++++++++- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/cobbler/action_reposync.py b/cobbler/action_reposync.py index 8c7e242..ac2cff8 100644 --- a/cobbler/action_reposync.py +++ b/cobbler/action_reposync.py @@ -38,25 +38,33 @@ class RepoSync: """ Constructor """ - self.verbose = True - self.config = config - self.distros = config.distros() - self.profiles = config.profiles() - self.systems = config.systems() - self.settings = config.settings() - self.repos = config.repos() + self.verbose = True + self.config = config + self.distros = config.distros() + self.profiles = config.profiles() + self.systems = config.systems() + self.settings = config.settings() + self.repos = config.repos() - # ================================================================================== - def run(self,verbose=True): + # =================================================================== + + def run(self, args=[], verbose=True): """ Syncs the current repo configuration file with the filesystem. """ self.verbose = verbose for repo in self.repos: + if args != [] and repo.name not in args: + continue + elif args == [] and not repo.keep_updated: + print _("- %s is set to not be updated") % repo.name + continue + 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) @@ -67,7 +75,7 @@ class RepoSync: return True - # ================================================================================== + # ================================================================== def do_reposync(self,repo): @@ -92,13 +100,6 @@ class RepoSync: if repo.rpm_list != "": has_rpm_list = True - # user might have disabled repo updates in the config file for whatever reason. - # if so, don't update this one. - - if not repo.keep_updated: - print _("- %s is set to not be updated") % repo.name - return True - # create yum config file for use by reposync store_path = os.path.join(self.settings.webdir, "repo_mirror") dest_path = os.path.join(store_path, repo.name) @@ -188,9 +189,6 @@ class RepoSync: Handle copying of rsync:// and rsync-over-ssh repos. """ - if not repo.keep_updated: - print _("- %s is set to not be updated") % repo.name - return True if repo.rpm_list != "": print _("- warning: --rpm-list is not supported for rsync'd repositories") dest_path = os.path.join(self.settings.webdir, "repo_mirror", repo.name) diff --git a/cobbler/api.py b/cobbler/api.py index 1c9a445..c1063b5 100644 --- a/cobbler/api.py +++ b/cobbler/api.py @@ -189,13 +189,13 @@ class BootAPI: sync = action_sync.BootSync(self._config) return sync.run() - def reposync(self): + def reposync(self, args=[]): """ Take the contents of /var/lib/cobbler/repos and update them -- or create the initial copy if no contents exist yet. """ reposync = action_reposync.RepoSync(self._config) - return reposync.run() + return reposync.run(args) def status(self,mode): statusifier = action_status.BootStatusReport(self._config, mode) diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py index aeb8962..c982d76 100755 --- a/cobbler/cobbler.py +++ b/cobbler/cobbler.py @@ -581,7 +581,7 @@ class BootCLI: Sync the repo-specific portions of the config with the filesystem. 'cobbler reposync'. Intended to be run on cron. """ - self.api.reposync() + self.api.reposync(args) return True def validateks(self,args): diff --git a/cobbler/item_repo.py b/cobbler/item_repo.py index 447e057..c335eaa 100644 --- a/cobbler/item_repo.py +++ b/cobbler/item_repo.py @@ -47,6 +47,10 @@ class Repo(item.Item): self.rpm_list = self.load_item(seed_data, 'rpm_list') self.createrepo_flags = self.load_item(seed_data, 'createrepo_flags', '-c cache') self.depth = self.load_item(seed_data, 'depth', 2) + + # force this to be saved as a boolean + self.set_keep_updated(self.keep_updated) + return self def set_name(self,name): @@ -69,7 +73,10 @@ class Repo(item.Item): """ This allows the user to disable updates to a particular repo for whatever reason. """ - if not keep_updated.lower() in ["yes","y","yup","yeah","1"]: + if type(keep_updated) == bool: + self.keep_updated = keep_updated + return True + if not keep_updated.lower() in ["yes","y","yup","yeah","1","true"]: self.keep_updated = False else: self.keep_updated = True -- cgit