Module: Vagrant::LXC::Action
- Defined in:
- lib/vagrant-lxc/action.rb,
lib/vagrant-lxc/action/boot.rb,
lib/vagrant-lxc/action/create.rb,
lib/vagrant-lxc/action/destroy.rb,
lib/vagrant-lxc/action/forced_halt.rb,
lib/vagrant-lxc/action/forward_ports.rb,
lib/vagrant-lxc/action/warn_networks.rb,
lib/vagrant-lxc/action/compress_rootfs.rb,
lib/vagrant-lxc/action/destroy_confirm.rb,
lib/vagrant-lxc/action/private_networks.rb,
lib/vagrant-lxc/action/handle_box_metadata.rb,
lib/vagrant-lxc/action/setup_package_files.rb,
lib/vagrant-lxc/action/prepare_nfs_settings.rb,
lib/vagrant-lxc/action/clear_forwarded_ports.rb,
lib/vagrant-lxc/action/prepare_nfs_valid_ids.rb,
lib/vagrant-lxc/action/fetch_ip_with_lxc_attach.rb,
lib/vagrant-lxc/action/gc_private_network_bridges.rb,
lib/vagrant-lxc/action/fetch_ip_from_dnsmasq_leases.rb
Defined Under Namespace
Classes: Boot, ClearForwardedPorts, CompressRootFS, Create, Destroy, DestroyConfirm, FetchIpFromDnsmasqLeases, FetchIpWithLxcAttach, ForcedHalt, ForwardPorts, GcPrivateNetworkBridges, HandleBoxMetadata, PrepareNFSSettings, PrepareNFSValidIds, PrivateNetworks, SetupPackageFiles, WarnNetworks
Constant Summary collapse
Class Method Summary collapse
-
.action_boot ⇒ Object
This action boots the VM, assuming the VM is in a state that requires a bootup (i.e. not saved).
-
.action_destroy ⇒ Object
This is the action that is primarily responsible for completely freeing the resources of the underlying virtual machine.
-
.action_halt ⇒ Object
This is the action that is primarily responsible for halting the virtual machine, gracefully or by force.
-
.action_package ⇒ Object
This action packages the virtual machine into a single box file.
-
.action_provision ⇒ Object
This action just runs the provisioners on the machine.
-
.action_reload ⇒ Object
This action is responsible for reloading the machine, which brings it down, sucks in new configuration, and brings the machine back up with the new configuration.
-
.action_ssh ⇒ Object
This is the action that will exec into an SSH shell.
-
.action_ssh_ip ⇒ Object
This action is called to read the IP of the container.
-
.action_ssh_run ⇒ Object
This is the action that will run a single SSH command.
-
.action_start ⇒ Object
This action starts a container, assuming it is already created and exists.
-
.action_up ⇒ Object
This action brings the machine up from nothing, including creating the container, configuring metadata, and booting.
Class Method Details
.action_boot ⇒ Object
This action boots the VM, assuming the VM is in a state that requires a bootup (i.e. not saved).
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/vagrant-lxc/action.rb', line 46 def self.action_boot Builder.new.tap do |b| b.use Builtin::Provision b.use Builtin::EnvSet, :port_collision_repair => true b.use Builtin::HandleForwardedPortCollisions b.use PrepareNFSValidIds b.use Builtin::SyncedFolderCleanup b.use Builtin::SyncedFolders b.use PrepareNFSSettings b.use Builtin::SetHostname b.use WarnNetworks b.use ForwardPorts b.use PrivateNetworks b.use Boot b.use Builtin::WaitForCommunicator end end |
.action_destroy ⇒ Object
This is the action that is primarily responsible for completely freeing the resources of the underlying virtual machine.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/vagrant-lxc/action.rb', line 140 def self.action_destroy Builder.new.tap do |b| b.use Builtin::Call, Builtin::IsState, :not_created do |env1, b2| if env1[:result] b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created") next end b2.use Builtin::Call, DestroyConfirm do |env2, b3| if env2[:result] b3.use Builtin::ConfigValidate b3.use Builtin::EnvSet, :force_halt => true b3.use action_halt b3.use Destroy b3.use Builtin::ProvisionerCleanup else b3.use Builtin::Message, I18n.t("vagrant_lxc.messages.will_not_destroy") end end end end end |
.action_halt ⇒ Object
This is the action that is primarily responsible for halting the virtual machine, gracefully or by force.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/vagrant-lxc/action.rb', line 119 def self.action_halt Builder.new.tap do |b| b.use Builtin::Call, Builtin::IsState, :not_created do |env, b2| if env[:result] b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created") next end b2.use ClearForwardedPorts b2.use GcPrivateNetworkBridges b2.use Builtin::Call, Builtin::GracefulHalt, :stopped, :running do |env2, b3| if !env2[:result] b3.use ForcedHalt end end end end end |
.action_package ⇒ Object
This action packages the virtual machine into a single box file.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/vagrant-lxc/action.rb', line 164 def self.action_package Builder.new.tap do |b| b.use Builtin::Call, Builtin::IsState, :not_created do |env1, b2| if env1[:result] b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created") next end b2.use action_halt b2.use CompressRootFS b2.use SetupPackageFiles b2.use Vagrant::Action::General::Package end end end |
.action_provision ⇒ Object
This action just runs the provisioners on the machine.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/vagrant-lxc/action.rb', line 65 def self.action_provision Builder.new.tap do |b| b.use Builtin::ConfigValidate b.use Builtin::Call, Builtin::IsState, :not_created do |env1, b2| if env1[:result] b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created") next end b2.use Builtin::Call, Builtin::IsState, :running do |env2, b3| if !env2[:result] b3.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_running") next end b3.use Builtin::Provision end end end end |
.action_reload ⇒ Object
This action is responsible for reloading the machine, which brings it down, sucks in new configuration, and brings the machine back up with the new configuration.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vagrant-lxc/action.rb', line 29 def self.action_reload Builder.new.tap do |b| b.use Builtin::Call, Builtin::IsState, :not_created do |env1, b2| if env1[:result] b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created") next end b2.use Builtin::ConfigValidate b2.use action_halt b2.use action_start end end end |
.action_ssh ⇒ Object
This is the action that will exec into an SSH shell.
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/vagrant-lxc/action.rb', line 192 def self.action_ssh Builder.new.tap do |b| b.use Builtin::ConfigValidate b.use Builtin::Call, Builtin::IsState, :not_created do |env, b2| if env[:result] b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created") next end b2.use Builtin::Call, Builtin::IsState, :running do |env1, b3| if !env1[:result] b3.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_running") next end b3.use Builtin::SSHExec end end end end |
.action_ssh_ip ⇒ Object
This action is called to read the IP of the container. The IP found is expected to be put into the ‘:machine_ip` key.
182 183 184 185 186 187 188 189 |
# File 'lib/vagrant-lxc/action.rb', line 182 def self.action_ssh_ip Builder.new.tap do |b| b.use Builtin::Call, Builtin::ConfigValidate do |env, b2| b2.use FetchIpWithLxcAttach if env[:machine].provider.driver.supports_attach? b2.use FetchIpFromDnsmasqLeases end end end |
.action_ssh_run ⇒ Object
This is the action that will run a single SSH command.
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/vagrant-lxc/action.rb', line 214 def self.action_ssh_run Builder.new.tap do |b| b.use Builtin::ConfigValidate b.use Builtin::Call, Builtin::IsState, :not_created do |env, b2| if env[:result] b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created") next end b2.use Builtin::Call, Builtin::IsState, :running do |env1, b3| if !env1[:result] raise Vagrant::Errors::VMNotRunningError next end b3.use Builtin::SSHRun end end end end |
.action_start ⇒ Object
This action starts a container, assuming it is already created and exists. A precondition of this action is that the container exists.
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/vagrant-lxc/action.rb', line 88 def self.action_start Builder.new.tap do |b| b.use Builtin::ConfigValidate b.use Builtin::BoxCheckOutdated b.use Builtin::Call, Builtin::IsState, :running do |env, b2| # If the VM is running, then our work here is done, exit next if env[:result] b2.use action_boot end end end |
.action_up ⇒ Object
This action brings the machine up from nothing, including creating the container, configuring metadata, and booting.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/vagrant-lxc/action.rb', line 102 def self.action_up Builder.new.tap do |b| b.use Builtin::ConfigValidate b.use Builtin::Call, Builtin::IsState, :not_created do |env, b2| # If the VM is NOT created yet, then do the setup steps if env[:result] b2.use Builtin::HandleBox b2.use HandleBoxMetadata b2.use Create end end b.use action_start end end |