diff options
author | elijah <elijah@riseup.net> | 2012-11-27 15:01:56 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2012-11-27 15:01:56 -0800 |
commit | c91b94d10ae5540c5d4128f8ca8748bd897f2cfb (patch) | |
tree | 76dd24fa119a3faf3502c5c7cd6146f8075adda5 | |
parent | 0280f03eaf304c46593d0fd4ade90574acb3a7bd (diff) | |
download | leap_cli-c91b94d10ae5540c5d4128f8ca8748bd897f2cfb.tar.gz leap_cli-c91b94d10ae5540c5d4128f8ca8748bd897f2cfb.tar.bz2 |
improved vagrant (support for node-filter, default to running on all local nodes if no argument is given)
-rw-r--r-- | lib/leap_cli/commands/vagrant.rb | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/lib/leap_cli/commands/vagrant.rb b/lib/leap_cli/commands/vagrant.rb index 157793e..eaf070f 100644 --- a/lib/leap_cli/commands/vagrant.rb +++ b/lib/leap_cli/commands/vagrant.rb @@ -4,10 +4,10 @@ require 'fileutils' module LeapCli; module Commands desc "Manage local virtual machines" - long_desc "This command provides a convient way to manage Vagrant-based virtual machines. The Vagrantfile is automatically generated in test/Vagrantfile." + long_desc "This command provides a convient way to manage Vagrant-based virtual machines. If node-filter argument is missing, the command runs on all local virtual machines. The Vagrantfile is automatically generated in 'test/Vagrantfile'. If you want to run vagrant commands manually, cd to 'test'." command :local do |c| - c.desc 'Starts up the virtual machine' - c.arg_name 'node-name', :optional => false #, :multiple => false + c.desc 'Starts up the virtual machine(s)' + c.arg_name 'node-filter', :optional => true #, :multiple => false c.command :start do |c| c.action do |global_options,options,args| vagrant_setup @@ -15,8 +15,8 @@ module LeapCli; module Commands end end - c.desc 'Shuts down the virtual machine' - c.arg_name 'node-name', :optional => false #, :multiple => false + c.desc 'Shuts down the virtual machine(s)' + c.arg_name 'node-filter', :optional => true #, :multiple => false c.command :stop do |c| c.action do |global_options,options,args| vagrant_setup @@ -24,8 +24,8 @@ module LeapCli; module Commands end end - c.desc 'Resets virtual machine to a pristine state' - c.arg_name 'node-name', :optional => false #, :multiple => false + c.desc 'Resets virtual machine(s) to a pristine state' + c.arg_name 'node-filter', :optional => true #, :multiple => false c.command :reset do |c| c.action do |global_options,options,args| vagrant_setup @@ -33,8 +33,8 @@ module LeapCli; module Commands end end - c.desc 'Destroys the virtual machine, reclaiming the disk space' - c.arg_name 'node-name', :optional => false #, :multiple => false + c.desc 'Destroys the virtual machine(s), reclaiming the disk space' + c.arg_name 'node-filter', :optional => true #, :multiple => false c.command :destroy do |c| c.action do |global_options,options,args| vagrant_setup @@ -42,8 +42,8 @@ module LeapCli; module Commands end end - c.desc 'Print the status of local virtual machine' - c.arg_name 'node-name', :optional => false #, :multiple => false + c.desc 'Print the status of local virtual machine(s)' + c.arg_name 'node-filter', :optional => true #, :multiple => false c.command :status do |c| c.action do |global_options,options,args| vagrant_setup @@ -80,12 +80,18 @@ module LeapCli; module Commands def vagrant_command(cmds, args) cmds = cmds.to_a assert_config! 'provider.vagrant.network' - nodes = manager.filter(args)[:local => true].field(:name) + if args.empty? + nodes = [""] + else + nodes = manager.filter(args)[:local => true].field(:name) + end if nodes.any? vagrant_dir = File.dirname(Path.named_path(:vagrantfile)) exec = ["cd #{vagrant_dir}"] cmds.each do |cmd| - exec << "vagrant #{cmd} #{nodes.join(' ')}" + nodes.each do |node| + exec << "vagrant #{cmd} #{node}" + end end execute exec.join('; ') else |