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(:reload) { Vagrant::Command::Reload }
|
||||
Vagrant.commands.register(:resume) { Vagrant::Command::Resume }
|
||||
Vagrant.commands.register(:suspend) { Vagrant::Command::Suspend }
|
||||
Vagrant.commands.register(:up) { Vagrant::Command::Up }
|
||||
|
||||
# Register the built-in config keys
|
||||
|
|
|
@ -7,6 +7,7 @@ module Vagrant
|
|||
autoload :Provision, 'vagrant/command/provision'
|
||||
autoload :Reload, 'vagrant/command/reload'
|
||||
autoload :Resume, 'vagrant/command/resume'
|
||||
autoload :Suspend, 'vagrant/command/suspend'
|
||||
autoload :Up, 'vagrant/command/up'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,14 +1,27 @@
|
|||
require 'optparse'
|
||||
|
||||
module Vagrant
|
||||
module Command
|
||||
class SuspendCommand < NamedBase
|
||||
register "suspend", "Suspend a running Vagrant environment."
|
||||
|
||||
class Suspend < Base
|
||||
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?
|
||||
@logger.info("Suspending: #{vm.name}")
|
||||
vm.suspend
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue