Added the dry-run option

This commit is contained in:
Anders Ingemann 2013-10-27 18:37:43 +01:00
parent 1db38ec7dd
commit cf3c861a27
2 changed files with 7 additions and 4 deletions

View file

@ -17,6 +17,8 @@ def get_args():
help='Print debugging information')
parser.add_argument('--pause-on-error', action='store_true',
help='Pause on error, before rollback')
parser.add_argument('--dry-run', action='store_true',
help='Dont\'t actually run the tasks')
parser.add_argument('manifest', help='Manifest file to use for bootstrapping', metavar='MANIFEST')
return parser.parse_args()
@ -35,7 +37,7 @@ def run(args):
bootstrap_info = BootstrapInformation(manifest=manifest, debug=args.debug)
try:
tasklist.run(bootstrap_info)
tasklist.run(info=bootstrap_info, dry_run=args.dry_run)
log.info('Successfully completed bootstrapping')
except (Exception, KeyboardInterrupt) as e:
log.exception(e)
@ -48,5 +50,5 @@ def run(args):
rollback_tasks = getattr(plugin, 'rollback_tasks', None)
if callable(rollback_tasks):
plugin.rollback_tasks(rollback_tasklist, tasklist.tasks_completed, manifest)
rollback_tasklist.run(bootstrap_info)
rollback_tasklist.run(info=bootstrap_info, dry_run=args.dry_run)
log.info('Successfully completed rollback')

View file

@ -16,7 +16,7 @@ class TaskList(object):
for task in args:
self.tasks.discard(task)
def run(self, bootstrap_info):
def run(self, info={}, dry_run=False):
task_list = self.create_list(self.tasks)
log.debug('Tasklist:\n\t{list}'.format(list='\n\t'.join(repr(task) for task in task_list)))
@ -26,7 +26,8 @@ class TaskList(object):
log.info(task.description)
else:
log.info('Running {task}'.format(task=task))
task.run(bootstrap_info)
if not dry_run:
task.run(info)
self.tasks_completed.append(task)
def create_list(self, tasks):