Commit 1c1854fc authored by Noe Nieto's avatar Noe Nieto 💬
Browse files

The up/start command now accepts a list of hostnames

parent 6f7c21d3
......@@ -275,6 +275,7 @@ COMMANDS = {
'status': "Prints the status of all the boxes' managed by box",
'create': 'Creates a new box using either libvirt(default) or Digital Ocean',
'up': 'Start box',
'start': 'Start box',
'halt': 'Stop/shutdown a box',
'restart': 'Restarts the box',
'destroy': 'Destroy the box and do cleanup',
......@@ -287,8 +288,8 @@ COMMANDS = {
if __name__ == '__main__':
cmd_parser = argparse.ArgumentParser(
prog='box',
description="This utility helps you mange virtual boxes'ith Vagrant without dealing with configuration details",
prog='shipwright box',
description="This utility helps you mange virtual boxes with Vagrant without dealing directly with configuration details",
)
cmd_parser.add_argument('command', choices=COMMANDS,)
cmd_args = cmd_parser.parse_args(sys.argv[1:2])
......@@ -298,10 +299,11 @@ if __name__ == '__main__':
ensure_plugins()
if cmd_args.command == 'status':
VagrantDB.prune()
print_status()
sys.exit()
sub_parser = argparse.ArgumentParser(prog='box',)
sub_parser = argparse.ArgumentParser()
if cmd_args.command == 'create':
sub_parser.usage = 'box create <hostname> [--ram RAM] [--cpus CPUS] [--provider libvirt|digital_ocean] [--token]'
sub_parser.add_argument('hostname', help='This is the hostname for the new the box')
......@@ -317,8 +319,8 @@ if __name__ == '__main__':
box_create(sub_args.hostname, sub_args.ram, sub_args.cpus, sub_args.provider, sub_args.token)
sys.exit()
sub_parser.add_argument('hostname', help='This is the hostname of the box')
if cmd_args.command == 'playbook':
sub_parser.add_argument('hostname', help='This is the hostname of the box')
sub_parser.usage = 'box playbook hostname path/to/playbook.yml'
sub_parser.add_argument('playbook', help='The path to the playbook file')
sub_parser.add_argument('--retry', help='The path to the playbook retry file.', required=False)
......@@ -326,15 +328,20 @@ if __name__ == '__main__':
run_playbook(sub_args.hostname, sub_args.playbook, sub_args.retry)
sys.exit()
if cmd_args.command in ['up', 'start']:
sub_parser.add_argument('hostnames', help='The hostname(s) of the boxes to start', nargs='+')
sub_args = sub_parser.parse_args(sys.argv[2:])
for hostname in sub_args.hostnames:
box_start(hostname)
sub_parser.add_argument('hostname', help='This is the hostname of the box')
sub_args = sub_parser.parse_args(sys.argv[2:])
if cmd_args.command == 'up':
box_start(sub_args.hostname)
elif cmd_args.command == 'halt':
if cmd_args.command in ['halt', 'stop']:
box_halt(sub_args.hostname)
elif cmd_args.command == 'restart':
box_halt(sub_args.hostname)
box_start(sub_args.hostname)
elif cmd_args.command == 'destroy':
elif cmd_args.command in ['destroy', 'rm']:
box_destroy(sub_args.hostname)
elif cmd_args.command == 'ssh':
box_ssh_connect(sub_args.hostname)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment