2012-07-27 05:39:27 +00:00
|
|
|
require "vagrant/action/builder"
|
|
|
|
|
|
|
|
module VagrantPlugins
|
|
|
|
module ProviderVirtualBox
|
|
|
|
module Action
|
2012-08-14 03:03:35 +00:00
|
|
|
autoload :Boot, File.expand_path("../action/boot", __FILE__)
|
2012-07-27 05:39:27 +00:00
|
|
|
autoload :CheckAccessible, File.expand_path("../action/check_accessible", __FILE__)
|
2012-08-05 20:45:24 +00:00
|
|
|
autoload :CheckCreated, File.expand_path("../action/check_created", __FILE__)
|
2012-08-14 03:03:35 +00:00
|
|
|
autoload :CheckPortCollisions, File.expand_path("../action/check_port_collisions", __FILE__)
|
2012-08-05 20:45:24 +00:00
|
|
|
autoload :CheckRunning, File.expand_path("../action/check_running", __FILE__)
|
2012-07-27 05:39:27 +00:00
|
|
|
autoload :CheckVirtualbox, File.expand_path("../action/check_virtualbox", __FILE__)
|
2012-08-14 06:31:12 +00:00
|
|
|
autoload :CleanMachineFolder, File.expand_path("../action/clean_machine_folder", __FILE__)
|
2012-07-27 06:56:47 +00:00
|
|
|
autoload :Created, File.expand_path("../action/created", __FILE__)
|
2012-08-14 06:31:12 +00:00
|
|
|
autoload :Destroy, File.expand_path("../action/destroy", __FILE__)
|
2012-07-29 02:58:10 +00:00
|
|
|
autoload :DestroyConfirm, File.expand_path("../action/destroy_confirm", __FILE__)
|
2012-08-14 06:31:12 +00:00
|
|
|
autoload :DestroyUnusedNetworkInterfaces, File.expand_path("../action/destroy_unused_network_interfaces", __FILE__)
|
2012-08-04 18:16:31 +00:00
|
|
|
autoload :DiscardState, File.expand_path("../action/discard_state", __FILE__)
|
|
|
|
autoload :Halt, File.expand_path("../action/halt", __FILE__)
|
2012-07-28 17:43:16 +00:00
|
|
|
autoload :MessageNotCreated, File.expand_path("../action/message_not_created", __FILE__)
|
2012-07-29 02:58:10 +00:00
|
|
|
autoload :MessageWillNotDestroy, File.expand_path("../action/message_will_not_destroy", __FILE__)
|
2012-08-14 06:31:12 +00:00
|
|
|
autoload :ProvisionerCleanup, File.expand_path("../action/provisioner_cleanup", __FILE__)
|
|
|
|
autoload :PruneNFSExports, File.expand_path("../action/prune_nfs_exports", __FILE__)
|
2012-08-14 03:03:35 +00:00
|
|
|
autoload :Resume, File.expand_path("../action/resume", __FILE__)
|
2012-08-14 02:30:41 +00:00
|
|
|
autoload :Suspend, File.expand_path("../action/suspend", __FILE__)
|
2012-07-27 06:56:47 +00:00
|
|
|
|
|
|
|
# Include the built-in modules so that we can use them as top-level
|
|
|
|
# things.
|
|
|
|
include Vagrant::Action::Builtin
|
2012-07-27 05:39:27 +00:00
|
|
|
|
|
|
|
# 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
|
2012-07-28 02:34:46 +00:00
|
|
|
b.use Call, Created do |env1, b2|
|
2012-07-28 17:43:16 +00:00
|
|
|
if !env1[:result]
|
|
|
|
b2.use MessageNotCreated
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
2012-07-29 02:58:10 +00:00
|
|
|
b2.use Call, DestroyConfirm do |env2, b3|
|
2012-07-28 17:43:16 +00:00
|
|
|
if env2[:result]
|
|
|
|
b3.use Vagrant::Action::General::Validate
|
|
|
|
b3.use CheckAccessible
|
2012-08-14 06:18:50 +00:00
|
|
|
b3.use EnvSet, :force => true
|
|
|
|
b3.use action_halt
|
2012-08-14 06:31:12 +00:00
|
|
|
b3.use ProvisionerCleanup
|
|
|
|
b3.use PruneNFSExports
|
|
|
|
b3.use Destroy
|
|
|
|
b3.use CleanMachineFolder
|
|
|
|
b3.use DestroyUnusedNetworkInterfaces
|
2012-07-28 17:43:16 +00:00
|
|
|
else
|
2012-07-29 02:58:10 +00:00
|
|
|
b3.use MessageWillNotDestroy
|
2012-07-28 02:29:40 +00:00
|
|
|
end
|
2012-07-28 17:43:16 +00:00
|
|
|
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
|
2012-07-28 02:29:40 +00:00
|
|
|
else
|
2012-07-28 17:43:16 +00:00
|
|
|
b2.use MessageNotCreated
|
2012-07-27 06:56:47 +00:00
|
|
|
end
|
|
|
|
end
|
2012-07-27 05:39:27 +00:00
|
|
|
end
|
|
|
|
end
|
2012-08-05 20:45:24 +00:00
|
|
|
|
2012-08-14 03:03:35 +00:00
|
|
|
# This is the action that is primarily responsible for resuming
|
|
|
|
# suspended machines.
|
|
|
|
def self.action_resume
|
|
|
|
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 CheckPortCollisions
|
|
|
|
b2.use Resume
|
|
|
|
else
|
|
|
|
b2.use MessageNotCreated
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-08-05 20:45:24 +00:00
|
|
|
# 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
|
2012-08-10 07:57:23 +00:00
|
|
|
|
|
|
|
# This is the action that will run a single SSH command.
|
|
|
|
def self.action_ssh_run
|
|
|
|
Vagrant::Action::Builder.new.tap do |b|
|
|
|
|
b.use CheckVirtualbox
|
|
|
|
b.use CheckCreated
|
|
|
|
b.use CheckAccessible
|
|
|
|
b.use CheckRunning
|
|
|
|
b.use SSHRun
|
|
|
|
end
|
|
|
|
end
|
2012-08-14 02:30:41 +00:00
|
|
|
|
|
|
|
# This is the action that is primarily responsible for suspending
|
|
|
|
# the virtual machine.
|
|
|
|
def self.action_suspend
|
|
|
|
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 Suspend
|
|
|
|
else
|
|
|
|
b2.use MessageNotCreated
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-07-27 05:39:27 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|