utils/cloneByDate.py | 36 ++++++++++++++++++++++++++++++++++-- utils/spacewalk-clone-by-date | 11 +++++++---- 2 files changed, 41 insertions(+), 6 deletions(-)
New commits: commit 56dda609234ca8dd810655518b93a92bb2b81170 Author: Justin Sherrill jsherril@redhat.com Date: Wed Feb 1 16:30:24 2012 -0500
errata date clone - adding repoclosure validation option
diff --git a/utils/cloneByDate.py b/utils/cloneByDate.py index 50927cd..89f2e3f 100644 --- a/utils/cloneByDate.py +++ b/utils/cloneByDate.py @@ -19,12 +19,11 @@
import sys -import time -import copy import shutil import tempfile import xmlrpclib import pprint +import subprocess
from depsolver import DepSolver @@ -58,6 +57,24 @@ def confirm(txt, options): sys.exit(0)
+def validate(channel_labels): + tmp_dirs = {} + for label in channel_labels: + dir = "%s/rhn/repodata/%s" % ( CFG.REPOMD_CACHE_MOUNT_POINT, label) + tmp = tempfile.mkdtemp() + tmp_dirs[label] = tmp + shutil.copytree(dir, "%s/repodata/" % tmp) + + cmd = ["repoclosure"] + for label, path in tmp_dirs.items(): + cmd.append("--repofrompath=%s,%s" %(label, path)) + subprocess.call(cmd) + + for tmp in tmp_dirs.values(): + shutil.rmtree(tmp, True) + + + def main(options): xmlrpc = RemoteApi(options.server, options.username, options.password) db = DBApi() @@ -69,12 +86,25 @@ def main(options): log_debug(0, "Started spacewalk-clone-by-date") log_clean(0, pprint.pformat(cleansed))
+ + + + cloners = [] needed_channels = [] for channel_list in options.channels: tree_cloner = ChannelTreeCloner(channel_list, xmlrpc, db, options.to_date, options.blacklist) cloners.append(tree_cloner) needed_channels += tree_cloner.needing_create().values() + + + if options.validate: + if len(needed_channels) > 0: + raise UserError("Cannot validate channels that do not exist %s", str(needed_channels)) + for channel_list in options.channels: + validate(channel_list) + return +
if len(needed_channels) > 0: print "\nBy continuing the following channels will be created: " @@ -444,6 +474,8 @@ class ChannelCloner: self.remote_api.remove_packages(self.to_label, found_ids)
+ +
class RemoteApi: diff --git a/utils/spacewalk-clone-by-date b/utils/spacewalk-clone-by-date index 0f7056f..070a538 100755 --- a/utils/spacewalk-clone-by-date +++ b/utils/spacewalk-clone-by-date @@ -100,6 +100,7 @@ def parse_args(): parser.add_option("-d", "--to_date", dest="to_date", help="Clone errata to the specified date (YYYY-MM-DD)") parser.add_option("-y", "--assumeyes", dest='assumeyes', action='store_true', help="Assume yes for any prompts (unattended).") parser.add_option("-m", "--sample-config", dest='sample', action='store_true', help="Print a sample full configuration file and exit.") + parser.add_option("-v", "--validate", dest='validate', action='store_true', help="Run repoclosure on the set of specified repositories.")
(options, args) = parser.parse_args()
@@ -121,14 +122,17 @@ def parse_args(): if options.channels == None or len(options.channels) == 0: raise UserError("No channels specified. See --help for details.")
+ + if not options.validate: + options.to_date = parse_time(options.to_date) + if not options.password: options.password = getpass.getpass()
- options.to_date = parse_time(options.to_date) + return options
- def parse_time(time_str): """We need to use datetime, but python 2.4 does not support strptime(), so we have to parse ourselves""" try: @@ -154,8 +158,7 @@ def main(): except KeyboardInterrupt: systemExit(0, "\nUser interrupted process.") except UserError, error: - print error - return -1 + systemExit(-1, "\n%s" % error) return 0
spacewalk-commits@lists.fedorahosted.org