From af6a8570c69b165f4349eb335d356daf716f2aec Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Wed, 17 Jun 2009 01:41:37 -0400 Subject: [PATCH] Implement mass migrate. Signed-off-by: Edward Z. Yang --- TODO | 3 +++ lib/wizard/__init__.py | 2 +- lib/wizard/command/massmigrate.py | 16 ++++++++++++++-- lib/wizard/command/migrate.py | 4 ++-- lib/wizard/command/summary.py | 1 + 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index 0528498..284c088 100644 --- a/TODO +++ b/TODO @@ -21,6 +21,9 @@ NOTES: We will then nop update some installs, but this will prevent us from having to migrate and update concurrently. +- summary and info are still not using loggers. Maybe they should, + maybe they shouldn't + OVERALL PLAN: * Some parts of the infrastructure will not be touched, although I plan diff --git a/lib/wizard/__init__.py b/lib/wizard/__init__.py index b0c216c..309b86c 100644 --- a/lib/wizard/__init__.py +++ b/lib/wizard/__init__.py @@ -31,4 +31,4 @@ class WizardOptionParser(optparse.OptionParser): default=False, help="Turns on verbose output") def parse_all(self, argv, logger): options, numeric_args = self.parse_args(argv) - return options, numeric_args, makeLogger(options) + return options, numeric_args, logger and logger or makeLogger(options) diff --git a/lib/wizard/command/massmigrate.py b/lib/wizard/command/massmigrate.py index 51aea1f..070945f 100644 --- a/lib/wizard/command/massmigrate.py +++ b/lib/wizard/command/massmigrate.py @@ -34,5 +34,17 @@ output going to stdout/stderr.""" base_args = [] if options.verbose: base_args.append("--verbose") if options.dry_run: base_args.append("--dry-run") - logger.info(app) - raise NotImplementedError + deploys = [] + for line in wd.getInstallLines(global_options): + try: + deploy = wd.Deployment.parse(line) + except wd.DeploymentParseError, wd.NoSuchApplication: + continue + name = deploy.getApplication().name + if name != app: continue + deploys.append(deploy) + # parallelization code would go here + for deploy in deploys: + sub_argv = base_args + [deploy.location] + logger.info("$ wizard migrate " + " ".join(sub_argv)) + migrate.migrate(sub_argv, global_options, logger) diff --git a/lib/wizard/command/migrate.py b/lib/wizard/command/migrate.py index dc5f5aa..09e6ff8 100644 --- a/lib/wizard/command/migrate.py +++ b/lib/wizard/command/migrate.py @@ -107,10 +107,10 @@ what repository and tag to use.""" else: if os.path.isdir(".git"): logger.warning("Force removing .git directory") - shutil.rmtree(".git") + if not options.dry_run: shutil.rmtree(".git") if os.path.isdir(".scripts"): logger.warning("Force removing .scripts directory") - shutil.rmtree(".scripts") + if not options.dry_run: shutil.rmtree(".scripts") try: deploy = wd.Deployment.fromDir(".") version = deploy.getAppVersion() diff --git a/lib/wizard/command/summary.py b/lib/wizard/command/summary.py index c84348b..2672403 100644 --- a/lib/wizard/command/summary.py +++ b/lib/wizard/command/summary.py @@ -2,6 +2,7 @@ import optparse import wizard.deploy as wd import sys +# XXX: Migrate this to use logger class Printer(object): def __init__(self, quiet, verbose): self.i = 0 -- 2.45.2