mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Added the dry-run option
This commit is contained in:
parent
1db38ec7dd
commit
cf3c861a27
2 changed files with 7 additions and 4 deletions
|
@ -17,6 +17,8 @@ def get_args():
|
||||||
help='Print debugging information')
|
help='Print debugging information')
|
||||||
parser.add_argument('--pause-on-error', action='store_true',
|
parser.add_argument('--pause-on-error', action='store_true',
|
||||||
help='Pause on error, before rollback')
|
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')
|
parser.add_argument('manifest', help='Manifest file to use for bootstrapping', metavar='MANIFEST')
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
@ -35,7 +37,7 @@ def run(args):
|
||||||
bootstrap_info = BootstrapInformation(manifest=manifest, debug=args.debug)
|
bootstrap_info = BootstrapInformation(manifest=manifest, debug=args.debug)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tasklist.run(bootstrap_info)
|
tasklist.run(info=bootstrap_info, dry_run=args.dry_run)
|
||||||
log.info('Successfully completed bootstrapping')
|
log.info('Successfully completed bootstrapping')
|
||||||
except (Exception, KeyboardInterrupt) as e:
|
except (Exception, KeyboardInterrupt) as e:
|
||||||
log.exception(e)
|
log.exception(e)
|
||||||
|
@ -48,5 +50,5 @@ def run(args):
|
||||||
rollback_tasks = getattr(plugin, 'rollback_tasks', None)
|
rollback_tasks = getattr(plugin, 'rollback_tasks', None)
|
||||||
if callable(rollback_tasks):
|
if callable(rollback_tasks):
|
||||||
plugin.rollback_tasks(rollback_tasklist, tasklist.tasks_completed, manifest)
|
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')
|
log.info('Successfully completed rollback')
|
||||||
|
|
|
@ -16,7 +16,7 @@ class TaskList(object):
|
||||||
for task in args:
|
for task in args:
|
||||||
self.tasks.discard(task)
|
self.tasks.discard(task)
|
||||||
|
|
||||||
def run(self, bootstrap_info):
|
def run(self, info={}, dry_run=False):
|
||||||
task_list = self.create_list(self.tasks)
|
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)))
|
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)
|
log.info(task.description)
|
||||||
else:
|
else:
|
||||||
log.info('Running {task}'.format(task=task))
|
log.info('Running {task}'.format(task=task))
|
||||||
task.run(bootstrap_info)
|
if not dry_run:
|
||||||
|
task.run(info)
|
||||||
self.tasks_completed.append(task)
|
self.tasks_completed.append(task)
|
||||||
|
|
||||||
def create_list(self, tasks):
|
def create_list(self, tasks):
|
||||||
|
|
Loading…
Add table
Reference in a new issue