aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/leap_cli/commands/vagrant.rb32
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