Suspend command
This commit is contained in:
parent
91d19b91e4
commit
bdc39aa2e0
|
@ -99,6 +99,7 @@ Vagrant.commands.register(:halt) { Vagrant::Command::Halt }
|
||||||
Vagrant.commands.register(:provision) { Vagrant::Command::Provision }
|
Vagrant.commands.register(:provision) { Vagrant::Command::Provision }
|
||||||
Vagrant.commands.register(:reload) { Vagrant::Command::Reload }
|
Vagrant.commands.register(:reload) { Vagrant::Command::Reload }
|
||||||
Vagrant.commands.register(:resume) { Vagrant::Command::Resume }
|
Vagrant.commands.register(:resume) { Vagrant::Command::Resume }
|
||||||
|
Vagrant.commands.register(:suspend) { Vagrant::Command::Suspend }
|
||||||
Vagrant.commands.register(:up) { Vagrant::Command::Up }
|
Vagrant.commands.register(:up) { Vagrant::Command::Up }
|
||||||
|
|
||||||
# Register the built-in config keys
|
# Register the built-in config keys
|
||||||
|
|
|
@ -7,6 +7,7 @@ module Vagrant
|
||||||
autoload :Provision, 'vagrant/command/provision'
|
autoload :Provision, 'vagrant/command/provision'
|
||||||
autoload :Reload, 'vagrant/command/reload'
|
autoload :Reload, 'vagrant/command/reload'
|
||||||
autoload :Resume, 'vagrant/command/resume'
|
autoload :Resume, 'vagrant/command/resume'
|
||||||
|
autoload :Suspend, 'vagrant/command/suspend'
|
||||||
autoload :Up, 'vagrant/command/up'
|
autoload :Up, 'vagrant/command/up'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,14 +1,27 @@
|
||||||
|
require 'optparse'
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Command
|
module Command
|
||||||
class SuspendCommand < NamedBase
|
class Suspend < Base
|
||||||
register "suspend", "Suspend a running Vagrant environment."
|
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
target_vms.each do |vm|
|
options = {}
|
||||||
|
|
||||||
|
opts = OptionParser.new do |opts|
|
||||||
|
opts.banner = "Usage: vagrant suspend [vm-name]"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Parse the options
|
||||||
|
argv = parse_options(opts)
|
||||||
|
return if !argv
|
||||||
|
|
||||||
|
@logger.debug("'suspend' each target VM...")
|
||||||
|
with_target_vms(argv[0]) do |vm|
|
||||||
if vm.created?
|
if vm.created?
|
||||||
|
@logger.info("Suspending: #{vm.name}")
|
||||||
vm.suspend
|
vm.suspend
|
||||||
else
|
else
|
||||||
vm.env.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
@logger.info("Not created: #{vm.name}. Not suspending.")
|
||||||
|
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue