From 5eb8acbe010d3c5744e60521e1d8f4cad44d64e5 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Sat, 20 May 2023 18:52:21 +0200 Subject: [PATCH] Implement force-stop argument By default, the running-detection is good enough, and avoids a useless Vagrant "destroy" call with a misleading informational message if "--stop" is used. However if the deployment was interupted and is in an inconsistent state, the running-detection returns false results - in such cases, "--force-stop" can be used to issue a "destroy" call without considering the detected status. Signed-off-by: Georg Pfuetzenreuter --- scullery.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scullery.py b/scullery.py index bbbbfb5..c430064 100755 --- a/scullery.py +++ b/scullery.py @@ -31,6 +31,7 @@ arggroup.add_argument('--stop', help='Stop running machines', action='store_true arggroup.add_argument('--test', help='Start machines and run tests', action='store_true') arggroup.add_argument('--status', help='Get Vagrant deployment status', action='store_true') arggroup.add_argument('--refresh', help='Re-sync files and re-run bootstrap scripts', action='store_true') +argparser.add_argument('--force-stop', help='Invoke Vagrant destruction without having detected any running VM\'s', action='store_true') args = argparser.parse_args() configfile = args.config @@ -150,8 +151,8 @@ def main_interactive(): log.info('Status report: {}'.format(v.status())) return True status = vagrant_isup(suite) - if status[0] is True and status[1] is None or args.stop or args.refresh: - if args.stop is True: + if status[0] is True and status[1] is None or args.force_stop or args.refresh: + if True in [args.stop, args.force_stop]: log.info('Destroying machines ...') v.destroy() if vagrant_isup(suite)[0] is False: @@ -174,7 +175,7 @@ def main_interactive(): log.exception(myerror) _abort('Unhandled error') - if args.stop is False: + if args.stop is False and args.force_stop is False: log.info('Launching {} ...'.format(suite)) v.up() if vagrant_isup(suite)[0] is True: