Module: VagrantPlugins::ProviderKvm::Action
- Includes:
- Vagrant::Action::Builtin
- Defined in:
- lib/vagrant-kvm/action.rb,
lib/vagrant-kvm/action/boot.rb,
lib/vagrant-kvm/action/export.rb,
lib/vagrant-kvm/action/import.rb,
lib/vagrant-kvm/action/resume.rb,
lib/vagrant-kvm/action/created.rb,
lib/vagrant-kvm/action/destroy.rb,
lib/vagrant-kvm/action/network.rb,
lib/vagrant-kvm/action/package.rb,
lib/vagrant-kvm/action/suspend.rb,
lib/vagrant-kvm/action/is_saved.rb,
lib/vagrant-kvm/action/set_name.rb,
lib/vagrant-kvm/action/check_box.rb,
lib/vagrant-kvm/action/check_kvm.rb,
lib/vagrant-kvm/action/customize.rb,
lib/vagrant-kvm/action/is_paused.rb,
lib/vagrant-kvm/action/is_running.rb,
lib/vagrant-kvm/action/forced_halt.rb,
lib/vagrant-kvm/action/check_created.rb,
lib/vagrant-kvm/action/check_running.rb,
lib/vagrant-kvm/action/forward_ports.rb,
lib/vagrant-kvm/action/share_folders.rb,
lib/vagrant-kvm/action/resume_network.rb,
lib/vagrant-kvm/action/destroy_confirm.rb,
lib/vagrant-kvm/action/init_storage_pool.rb,
lib/vagrant-kvm/action/match_mac_address.rb,
lib/vagrant-kvm/action/prepare_kvmconfig.rb,
lib/vagrant-kvm/action/message_not_created.rb,
lib/vagrant-kvm/action/message_not_running.rb,
lib/vagrant-kvm/action/package_vagrantfile.rb,
lib/vagrant-kvm/action/setup_package_files.rb,
lib/vagrant-kvm/action/prepare_nfs_settings.rb,
lib/vagrant-kvm/action/clear_forwarded_ports.rb,
lib/vagrant-kvm/action/prepare_nfs_valid_ids.rb,
lib/vagrant-kvm/action/reset_image_permission.rb,
lib/vagrant-kvm/action/message_will_not_destroy.rb
Defined Under Namespace
Classes: Boot, CheckBox, CheckCreated, CheckKvm, CheckRunning, ClearForwardedPorts, Created, Customize, Destroy, DestroyConfirm, Export, ForcedHalt, ForwardPorts, Import, InitStoragePool, IsPaused, IsRunning, IsSaved, MatchMACAddress, MessageNotCreated, MessageNotRunning, MessageWillNotDestroy, Network, Package, PackageVagrantfile, PrepareKvmConfig, PrepareNFSSettings, PrepareNFSValidIds, ResetImagePermission, Resume, ResumeNetwork, SetName, SetupPackageFiles, ShareFolders, Suspend
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_resume ⇒ Object
This is the action that is primarily responsible for resuming suspended machines.
-
.action_ssh ⇒ Object
This is the action that will exec into an SSH shell.
-
.action_ssh_run ⇒ Object
This is the action that will run a single SSH command.
-
.action_start ⇒ Object
This action starts a VM, assuming it is already imported and exists.
-
.action_suspend ⇒ Object
This is the action that is primarily responsible for suspending the virtual machine.
-
.action_up ⇒ Object
This action brings the machine up from nothing, including importing the box, 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).
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vagrant-kvm/action.rb', line 14 def self.action_boot Vagrant::Action::Builder.new.tap do |b| b.use Provision b.use Vagrant::Action::Builtin::HandleForwardedPortCollisions b.use PrepareNFSValidIds b.use SyncedFolderCleanup b.use SyncedFolders b.use PrepareNFSSettings b.use SetHostname b.use Customize, "pre-boot" b.use ForwardPorts b.use Boot if Vagrant::VERSION >= "1.3.0" b.use WaitForCommunicator, [:running] end b.use ShareFolders b.use Customize, "post-boot" end end |
.action_destroy ⇒ Object
This is the action that is primarily responsible for completely freeing the resources of the underlying virtual machine.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/vagrant-kvm/action.rb', line 36 def self.action_destroy Vagrant::Action::Builder.new.tap do |b| b.use CheckKvm 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 ConfigValidate b3.use EnvSet, :force_halt => true b3.use action_halt b3.use PrepareNFSSettings b3.use PrepareNFSValidIds b3.use SyncedFolderCleanup b3.use PrepareNFSSettings b3.use InitStoragePool b3.use Destroy else b3.use MessageWillNotDestroy 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.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/vagrant-kvm/action.rb', line 66 def self.action_halt Vagrant::Action::Builder.new.tap do |b| b.use CheckKvm b.use Call, Created do |env, b2| if env[:result] b2.use Call, IsPaused do |env2, b3| next if !env2[:result] b3.use Resume end b2.use ClearForwardedPorts b2.use Call, GracefulHalt, :shutoff, :running do |env2, b3| if !env2[:result] b3.use ForcedHalt end b3.use ResetImagePermission end else b2.use MessageNotCreated end end end end |
.action_package ⇒ Object
This action packages the virtual machine into a single box file.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/vagrant-kvm/action.rb', line 91 def self.action_package Vagrant::Action::Builder.new.tap do |b| b.use CheckKvm b.use Call, Created do |env1, b2| if !env1[:result] b2.use MessageNotCreated next end b2.use SetupPackageFiles b2.use action_halt b2.use PrepareNFSSettings b2.use PrepareNFSValidIds b2.use SyncedFolderCleanup b2.use PrepareNFSSettings b2.use Export b2.use PackageVagrantfile b2.use Package end end end |
.action_provision ⇒ Object
This action just runs the provisioners on the machine.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/vagrant-kvm/action.rb', line 114 def self.action_provision Vagrant::Action::Builder.new.tap do |b| b.use CheckKvm b.use ConfigValidate b.use Call, Created do |env1, b2| if !env1[:result] b2.use MessageNotCreated next end b2.use Call, IsRunning do |env2, b3| if !env2[:result] b3.use MessageNotRunning next end b3.use 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.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/vagrant-kvm/action.rb', line 139 def self.action_reload Vagrant::Action::Builder.new.tap do |b| b.use CheckKvm b.use Call, Created do |env1, b2| if !env1[:result] b2.use MessageNotCreated next end b2.use ConfigValidate b2.use action_halt b2.use action_start end end end |
.action_resume ⇒ Object
This is the action that is primarily responsible for resuming suspended machines.
157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/vagrant-kvm/action.rb', line 157 def self.action_resume Vagrant::Action::Builder.new.tap do |b| b.use CheckKvm b.use Call, Created do |env, b2| if env[:result] b2.use ResumeNetwork b2.use Resume else b2.use MessageNotCreated end end end end |
.action_ssh ⇒ Object
This is the action that will exec into an SSH shell.
172 173 174 175 176 177 178 179 |
# File 'lib/vagrant-kvm/action.rb', line 172 def self.action_ssh Vagrant::Action::Builder.new.tap do |b| b.use CheckKvm b.use CheckCreated b.use CheckRunning b.use SSHExec end end |
.action_ssh_run ⇒ Object
This is the action that will run a single SSH command.
182 183 184 185 186 187 188 189 |
# File 'lib/vagrant-kvm/action.rb', line 182 def self.action_ssh_run Vagrant::Action::Builder.new.tap do |b| b.use CheckKvm b.use CheckCreated b.use CheckRunning b.use SSHRun end end |
.action_start ⇒ Object
This action starts a VM, assuming it is already imported and exists. A precondition of this action is that the VM exists.
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/vagrant-kvm/action.rb', line 193 def self.action_start Vagrant::Action::Builder.new.tap do |b| b.use CheckKvm b.use ConfigValidate b.use Call, IsRunning do |env, b2| # If the VM is running, then our work here is done, exit next if env[:result] b2.use Call, IsSaved do |env2, b3| if env2[:result] # The VM is saved, so just resume it b3.use action_resume next end b3.use Call, IsPaused do |env3, b4| if env3[:result] b4.use ResumeNetwork b4.use Resume next end # The VM is not saved, so we must have to boot it up # like normal. Boot! b4.use PrepareKvmConfig b4.use action_boot end end end end end |
.action_suspend ⇒ Object
This is the action that is primarily responsible for suspending the virtual machine.
227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/vagrant-kvm/action.rb', line 227 def self.action_suspend Vagrant::Action::Builder.new.tap do |b| b.use CheckKvm b.use Call, Created do |env, b2| if env[:result] b2.use Suspend else b2.use MessageNotCreated end end end end |
.action_up ⇒ Object
This action brings the machine up from nothing, including importing the box, configuring metadata, and booting.
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/vagrant-kvm/action.rb', line 242 def self.action_up Vagrant::Action::Builder.new.tap do |b| b.use CheckKvm b.use ConfigValidate b.use InitStoragePool b.use Call, Created do |env, b2| # If the VM is NOT created yet, then do the setup steps if !env[:result] if Vagrant::VERSION < "1.5.0" b2.use CheckBox else b2.use HandleBox end b2.use SetName b2.use Customize, "pre-import" # we need to init storage again after driver is reloaded # XXX there must be a better way b2.use InitStoragePool b2.use Import b2.use MatchMACAddress b2.use Network end end b.use action_start end end |