This works by now calling the `:ssh` action on the provider. This action is allowed to do whatever it pleases, but should at some point probably call the `SSHExec` built-in middleware. The `SSHExec` built-in middleware was added. This uses the information returned by `Machine#ssh_info` and uses the `Vagrant::Util::SSH` helper to exec into the remote machine. The provider should do any work upfront in verifying that the machine is ready to be SSHed into.
74 lines
2.6 KiB
Ruby
74 lines
2.6 KiB
Ruby
require "vagrant/action/builder"
|
|
|
|
module VagrantPlugins
|
|
module ProviderVirtualBox
|
|
module Action
|
|
autoload :CheckAccessible, File.expand_path("../action/check_accessible", __FILE__)
|
|
autoload :CheckCreated, File.expand_path("../action/check_created", __FILE__)
|
|
autoload :CheckRunning, File.expand_path("../action/check_running", __FILE__)
|
|
autoload :CheckVirtualbox, File.expand_path("../action/check_virtualbox", __FILE__)
|
|
autoload :Created, File.expand_path("../action/created", __FILE__)
|
|
autoload :DestroyConfirm, File.expand_path("../action/destroy_confirm", __FILE__)
|
|
autoload :DiscardState, File.expand_path("../action/discard_state", __FILE__)
|
|
autoload :Halt, File.expand_path("../action/halt", __FILE__)
|
|
autoload :MessageNotCreated, File.expand_path("../action/message_not_created", __FILE__)
|
|
autoload :MessageWillNotDestroy, File.expand_path("../action/message_will_not_destroy", __FILE__)
|
|
|
|
# Include the built-in modules so that we can use them as top-level
|
|
# things.
|
|
include Vagrant::Action::Builtin
|
|
|
|
# This is the action that is primarily responsible for completely
|
|
# freeing the resources of the underlying virtual machine.
|
|
def self.action_destroy
|
|
Vagrant::Action::Builder.new.tap do |b|
|
|
b.use CheckVirtualbox
|
|
b.use Call, Created do |env1, b2|
|
|
if !env1[:result]
|
|
b2.use MessageNotCreated
|
|
next
|
|
end
|
|
|
|
b2.use Call, DestroyConfirm do |env2, b3|
|
|
if env2[:result]
|
|
b3.use Vagrant::Action::General::Validate
|
|
b3.use CheckAccessible
|
|
else
|
|
b3.use MessageWillNotDestroy
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
# This is the action that is primarily responsible for halting
|
|
# the virtual machine, gracefully or by force.
|
|
def self.action_halt
|
|
Vagrant::Action::Builder.new.tap do |b|
|
|
b.use CheckVirtualbox
|
|
b.use Call, Created do |env, b2|
|
|
if env[:result]
|
|
b2.use CheckAccessible
|
|
b2.use DiscardState
|
|
b2.use Halt
|
|
else
|
|
b2.use MessageNotCreated
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
# This is the action that will exec into an SSH shell.
|
|
def self.action_ssh
|
|
Vagrant::Action::Builder.new.tap do |b|
|
|
b.use CheckVirtualbox
|
|
b.use CheckCreated
|
|
b.use CheckAccessible
|
|
b.use CheckRunning
|
|
b.use SSHExec
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|