Shortcuts!
This commit is contained in:
parent
2116737989
commit
2e5e5920d7
1 changed files with 42 additions and 38 deletions
|
@ -27,18 +27,22 @@ end
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module LXC
|
module LXC
|
||||||
module Action
|
module Action
|
||||||
|
# Shortcuts
|
||||||
|
Builtin = Vagrant::Action::Builtin
|
||||||
|
Builder = Vagrant::Action::Builder
|
||||||
|
|
||||||
# This action is responsible for reloading the machine, which
|
# This action is responsible for reloading the machine, which
|
||||||
# brings it down, sucks in new configuration, and brings the
|
# brings it down, sucks in new configuration, and brings the
|
||||||
# machine back up with the new configuration.
|
# machine back up with the new configuration.
|
||||||
def self.action_reload
|
def self.action_reload
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Builder.new.tap do |b|
|
||||||
b.use Vagrant::Action::Builtin::Call, Created do |env1, b2|
|
b.use Builtin::Call, Created do |env1, b2|
|
||||||
if !env1[:result]
|
if !env1[:result]
|
||||||
b2.use Message, :not_created
|
b2.use Message, :not_created
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
b2.use Vagrant::Action::Builtin::ConfigValidate
|
b2.use Builtin::ConfigValidate
|
||||||
b2.use action_halt
|
b2.use action_halt
|
||||||
b2.use action_start
|
b2.use action_start
|
||||||
end
|
end
|
||||||
|
@ -48,35 +52,35 @@ module Vagrant
|
||||||
# This action boots the VM, assuming the VM is in a state that requires
|
# This action boots the VM, assuming the VM is in a state that requires
|
||||||
# a bootup (i.e. not saved).
|
# a bootup (i.e. not saved).
|
||||||
def self.action_boot
|
def self.action_boot
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Builder.new.tap do |b|
|
||||||
b.use Vagrant::Action::Builtin::Provision
|
b.use Builtin::Provision
|
||||||
b.use Vagrant::Action::Builtin::EnvSet, :port_collision_repair => true
|
b.use Builtin::EnvSet, :port_collision_repair => true
|
||||||
b.use Vagrant::Action::Builtin::HandleForwardedPortCollisions
|
b.use Builtin::HandleForwardedPortCollisions
|
||||||
b.use ShareFolders
|
b.use ShareFolders
|
||||||
b.use Vagrant::Action::Builtin::SetHostname
|
b.use Builtin::SetHostname
|
||||||
b.use ForwardPorts
|
b.use ForwardPorts
|
||||||
b.use Boot
|
b.use Boot
|
||||||
b.use Vagrant::Action::Builtin::WaitForCommunicator
|
b.use Builtin::WaitForCommunicator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# This action just runs the provisioners on the machine.
|
# This action just runs the provisioners on the machine.
|
||||||
def self.action_provision
|
def self.action_provision
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Builder.new.tap do |b|
|
||||||
b.use Vagrant::Action::Builtin::ConfigValidate
|
b.use Builtin::ConfigValidate
|
||||||
b.use Vagrant::Action::Builtin::Call, Created do |env1, b2|
|
b.use Builtin::Call, Created do |env1, b2|
|
||||||
if !env1[:result]
|
if !env1[:result]
|
||||||
b2.use Message, :not_created
|
b2.use Message, :not_created
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
b2.use Vagrant::Action::Builtin::Call, IsRunning do |env2, b3|
|
b2.use Builtin::Call, IsRunning do |env2, b3|
|
||||||
if !env2[:result]
|
if !env2[:result]
|
||||||
b3.use Message, :not_running
|
b3.use Message, :not_running
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
b3.use Vagrant::Action::Builtin::Provision
|
b3.use Builtin::Provision
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -85,9 +89,9 @@ module Vagrant
|
||||||
# This action starts a container, assuming it is already created and exists.
|
# This action starts a container, assuming it is already created and exists.
|
||||||
# A precondition of this action is that the container exists.
|
# A precondition of this action is that the container exists.
|
||||||
def self.action_start
|
def self.action_start
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Builder.new.tap do |b|
|
||||||
b.use Vagrant::Action::Builtin::ConfigValidate
|
b.use Builtin::ConfigValidate
|
||||||
b.use Vagrant::Action::Builtin::Call, IsRunning do |env, b2|
|
b.use Builtin::Call, IsRunning do |env, b2|
|
||||||
# If the VM is running, then our work here is done, exit
|
# If the VM is running, then our work here is done, exit
|
||||||
next if env[:result]
|
next if env[:result]
|
||||||
# TODO: Check if has been saved / frozen and resume
|
# TODO: Check if has been saved / frozen and resume
|
||||||
|
@ -99,12 +103,12 @@ module Vagrant
|
||||||
# This action brings the machine up from nothing, including creating the
|
# This action brings the machine up from nothing, including creating the
|
||||||
# container, configuring metadata, and booting.
|
# container, configuring metadata, and booting.
|
||||||
def self.action_up
|
def self.action_up
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Builder.new.tap do |b|
|
||||||
b.use Vagrant::Action::Builtin::ConfigValidate
|
b.use Builtin::ConfigValidate
|
||||||
b.use Vagrant::Action::Builtin::Call, Created do |env, b2|
|
b.use Builtin::Call, Created do |env, b2|
|
||||||
# If the VM is NOT created yet, then do the setup steps
|
# If the VM is NOT created yet, then do the setup steps
|
||||||
if !env[:result]
|
if !env[:result]
|
||||||
b2.use Vagrant::Action::Builtin::HandleBoxUrl
|
b2.use Builtin::HandleBoxUrl
|
||||||
b2.use HandleBoxMetadata
|
b2.use HandleBoxMetadata
|
||||||
b2.use Create
|
b2.use Create
|
||||||
end
|
end
|
||||||
|
@ -116,14 +120,14 @@ module Vagrant
|
||||||
# This is the action that is primarily responsible for halting
|
# This is the action that is primarily responsible for halting
|
||||||
# the virtual machine, gracefully or by force.
|
# the virtual machine, gracefully or by force.
|
||||||
def self.action_halt
|
def self.action_halt
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Builder.new.tap do |b|
|
||||||
b.use Vagrant::Action::Builtin::Call, Created do |env, b2|
|
b.use Builtin::Call, Created do |env, b2|
|
||||||
if env[:result]
|
if env[:result]
|
||||||
# TODO: Check vagrant version and use only if lower than 1.X
|
# TODO: Check vagrant version and use only if lower than 1.X
|
||||||
b2.use Disconnect
|
b2.use Disconnect
|
||||||
b2.use ClearForwardedPorts
|
b2.use ClearForwardedPorts
|
||||||
b2.use RemoveTemporaryFiles
|
b2.use RemoveTemporaryFiles
|
||||||
b2.use Vagrant::Action::Builtin::Call, Vagrant::Action::Builtin::GracefulHalt, :stopped, :running do |env2, b3|
|
b2.use Builtin::Call, Builtin::GracefulHalt, :stopped, :running do |env2, b3|
|
||||||
if !env2[:result]
|
if !env2[:result]
|
||||||
b3.use ForcedHalt
|
b3.use ForcedHalt
|
||||||
end
|
end
|
||||||
|
@ -138,22 +142,22 @@ module Vagrant
|
||||||
# This is the action that is primarily responsible for completely
|
# This is the action that is primarily responsible for completely
|
||||||
# freeing the resources of the underlying virtual machine.
|
# freeing the resources of the underlying virtual machine.
|
||||||
def self.action_destroy
|
def self.action_destroy
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Builder.new.tap do |b|
|
||||||
b.use Vagrant::Action::Builtin::Call, Created do |env1, b2|
|
b.use Builtin::Call, Created do |env1, b2|
|
||||||
if !env1[:result]
|
if !env1[:result]
|
||||||
b2.use Message, :not_created
|
b2.use Message, :not_created
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Use Vagrant's built in action
|
# TODO: Use Vagrant's built in action
|
||||||
b2.use Vagrant::Action::Builtin::Call, DestroyConfirm do |env2, b3|
|
b2.use Builtin::Call, DestroyConfirm do |env2, b3|
|
||||||
if env2[:result]
|
if env2[:result]
|
||||||
b3.use Vagrant::Action::Builtin::ConfigValidate
|
b3.use Builtin::ConfigValidate
|
||||||
b3.use Vagrant::Action::Builtin::EnvSet, :force_halt => true
|
b3.use Builtin::EnvSet, :force_halt => true
|
||||||
b3.use action_halt
|
b3.use action_halt
|
||||||
b3.use Destroy
|
b3.use Destroy
|
||||||
if Vagrant::LXC.vagrant_1_3_or_later
|
if Vagrant::LXC.vagrant_1_3_or_later
|
||||||
b3.use Vagrant::Action::Builtin::ProvisionerCleanup
|
b3.use Builtin::ProvisionerCleanup
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
b3.use Message, :will_not_destroy
|
b3.use Message, :will_not_destroy
|
||||||
|
@ -165,8 +169,8 @@ module Vagrant
|
||||||
|
|
||||||
# This action packages the virtual machine into a single box file.
|
# This action packages the virtual machine into a single box file.
|
||||||
def self.action_package
|
def self.action_package
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Builder.new.tap do |b|
|
||||||
b.use Vagrant::Action::Builtin::Call, Created do |env1, b2|
|
b.use Builtin::Call, Created do |env1, b2|
|
||||||
if !env1[:result]
|
if !env1[:result]
|
||||||
b2.use Message, :not_created
|
b2.use Message, :not_created
|
||||||
next
|
next
|
||||||
|
@ -183,8 +187,8 @@ module Vagrant
|
||||||
# This action is called to read the IP of the container. The IP found
|
# This action is called to read the IP of the container. The IP found
|
||||||
# is expected to be put into the `:machine_ip` key.
|
# is expected to be put into the `:machine_ip` key.
|
||||||
def self.action_fetch_ip
|
def self.action_fetch_ip
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Builder.new.tap do |b|
|
||||||
b.use Vagrant::Action::Builtin::ConfigValidate
|
b.use Builtin::ConfigValidate
|
||||||
b.use FetchIpWithLxcAttach
|
b.use FetchIpWithLxcAttach
|
||||||
b.use FetchIpFromDnsmasqLeases
|
b.use FetchIpFromDnsmasqLeases
|
||||||
end
|
end
|
||||||
|
@ -192,19 +196,19 @@ module Vagrant
|
||||||
|
|
||||||
# This is the action that will exec into an SSH shell.
|
# This is the action that will exec into an SSH shell.
|
||||||
def self.action_ssh
|
def self.action_ssh
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Builder.new.tap do |b|
|
||||||
b.use CheckCreated
|
b.use CheckCreated
|
||||||
b.use CheckRunning
|
b.use CheckRunning
|
||||||
b.use Vagrant::Action::Builtin::SSHExec
|
b.use Builtin::SSHExec
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# This is the action that will run a single SSH command.
|
# This is the action that will run a single SSH command.
|
||||||
def self.action_ssh_run
|
def self.action_ssh_run
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Builder.new.tap do |b|
|
||||||
b.use CheckCreated
|
b.use CheckCreated
|
||||||
b.use CheckRunning
|
b.use CheckRunning
|
||||||
b.use Vagrant::Action::Builtin::SSHRun
|
b.use Builtin::SSHRun
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue