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('--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('--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')
|
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()
|
args = argparser.parse_args()
|
||||||
configfile = args.config
|
configfile = args.config
|
||||||
@ -150,8 +151,8 @@ def main_interactive():
|
|||||||
log.info('Status report: {}'.format(v.status()))
|
log.info('Status report: {}'.format(v.status()))
|
||||||
return True
|
return True
|
||||||
status = vagrant_isup(suite)
|
status = vagrant_isup(suite)
|
||||||
if status[0] is True and status[1] is None or args.stop or args.refresh:
|
if status[0] is True and status[1] is None or args.force_stop or args.refresh:
|
||||||
if args.stop is True:
|
if True in [args.stop, args.force_stop]:
|
||||||
log.info('Destroying machines ...')
|
log.info('Destroying machines ...')
|
||||||
v.destroy()
|
v.destroy()
|
||||||
if vagrant_isup(suite)[0] is False:
|
if vagrant_isup(suite)[0] is False:
|
||||||
@ -174,7 +175,7 @@ def main_interactive():
|
|||||||
log.exception(myerror)
|
log.exception(myerror)
|
||||||
_abort('Unhandled error')
|
_abort('Unhandled error')
|
||||||
|
|
||||||
if args.stop is False:
|
if args.stop is False and args.force_stop is False:
|
||||||
log.info('Launching {} ...'.format(suite))
|
log.info('Launching {} ...'.format(suite))
|
||||||
v.up()
|
v.up()
|
||||||
if vagrant_isup(suite)[0] is True:
|
if vagrant_isup(suite)[0] is True:
|
||||||
|
Loading…
Reference in New Issue
Block a user