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 <mail@georg-pfuetzenreuter.net>
This commit is contained in:
parent
f110f92150
commit
5eb8acbe01
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user