From 0e43d8b55f6ee7e7dd5958d5984e99afdc306a57 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 24 Aug 2010 23:10:58 -0700 Subject: [PATCH] `vagrant halt` --- lib/vagrant/command/destroy.rb | 2 +- lib/vagrant/command/halt.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 lib/vagrant/command/halt.rb diff --git a/lib/vagrant/command/destroy.rb b/lib/vagrant/command/destroy.rb index 8f7c3f726..3a68eb301 100644 --- a/lib/vagrant/command/destroy.rb +++ b/lib/vagrant/command/destroy.rb @@ -1,7 +1,7 @@ module Vagrant module Command class DestroyCommand < Base - desc "Destroy the environment, deleting the created virtual machines." + desc "Destroy the environment, deleting the created virtual machines" register "destroy" def execute diff --git a/lib/vagrant/command/halt.rb b/lib/vagrant/command/halt.rb new file mode 100644 index 000000000..a1df59a4b --- /dev/null +++ b/lib/vagrant/command/halt.rb @@ -0,0 +1,19 @@ +module Vagrant + module Command + class HaltCommand < Base + desc "Halt the running VMs in the environment" + class_option :force, :type => :boolean, :default => false, :aliases => "-f" + register "halt" + + def execute + target_vms.each do |vm| + if vm.created? + vm.halt(options) + else + vm.env.ui.info "VM not created. Moving on..." + end + end + end + end + end +end