Module: VagrantPlugins::Skytap::Action
- Includes:
- Vagrant::Action::Builtin
- Defined in:
- lib/vagrant-skytap/action.rb,
lib/vagrant-skytap/action/run_vm.rb,
lib/vagrant-skytap/action/stop_vm.rb,
lib/vagrant-skytap/action/delete_vm.rb,
lib/vagrant-skytap/action/set_up_vm.rb,
lib/vagrant-skytap/action/is_running.rb,
lib/vagrant-skytap/action/is_stopped.rb,
lib/vagrant-skytap/action/read_state.rb,
lib/vagrant-skytap/action/suspend_vm.rb,
lib/vagrant-skytap/action/is_suspended.rb,
lib/vagrant-skytap/action/set_hostname.rb,
lib/vagrant-skytap/action/forward_ports.rb,
lib/vagrant-skytap/action/initial_state.rb,
lib/vagrant-skytap/action/read_ssh_info.rb,
lib/vagrant-skytap/action/existence_check.rb,
lib/vagrant-skytap/action/is_parallelized.rb,
lib/vagrant-skytap/action/run_environment.rb,
lib/vagrant-skytap/action/timed_provision.rb,
lib/vagrant-skytap/action/update_hardware.rb,
lib/vagrant-skytap/action/message_resuming.rb,
lib/vagrant-skytap/action/stop_environment.rb,
lib/vagrant-skytap/action/store_extra_data.rb,
lib/vagrant-skytap/action/fetch_environment.rb,
lib/vagrant-skytap/action/create_environment.rb,
lib/vagrant-skytap/action/delete_environment.rb,
lib/vagrant-skytap/action/message_not_created.rb,
lib/vagrant-skytap/action/mixin_machine_index.rb,
lib/vagrant-skytap/action/suspend_environment.rb,
lib/vagrant-skytap/action/prepare_nfs_settings.rb,
lib/vagrant-skytap/action/add_vm_to_environment.rb,
lib/vagrant-skytap/action/clear_forwarded_ports.rb,
lib/vagrant-skytap/action/initialize_api_client.rb,
lib/vagrant-skytap/action/prepare_nfs_valid_ids.rb,
lib/vagrant-skytap/action/wait_for_communicator.rb,
lib/vagrant-skytap/action/message_already_created.rb,
lib/vagrant-skytap/action/message_already_running.rb,
lib/vagrant-skytap/action/message_environment_url.rb,
lib/vagrant-skytap/action/message_will_not_destroy.rb,
lib/vagrant-skytap/action/prepare_forwarded_port_collision_params.rb
Defined Under Namespace
Modules: MixinMachineIndex Classes: AddVmToEnvironment, ClearForwardedPorts, CreateEnvironment, DeleteEnvironment, DeleteVm, ExistenceCheck, FetchEnvironment, ForwardPorts, InitialState, InitializeAPIClient, IsParallelized, IsRunning, IsStopped, IsSuspended, MessageAlreadyCreated, MessageAlreadyRunning, MessageEnvironmentUrl, MessageNotCreated, MessageResuming, MessageWillNotDestroy, PrepareForwardedPortCollisionParams, PrepareNFSSettings, PrepareNFSValidIds, ReadSSHInfo, ReadState, RunEnvironment, RunVm, SetHostname, SetUpVm, StopEnvironment, StopVm, StoreExtraData, SuspendEnvironment, SuspendVm, TimedProvision, UpdateHardware, WaitForCommunicator
Class Method Summary collapse
-
.action_create ⇒ Object
The Skytap provider has a modified “vagrant up” command which takes advantage of parallel runstate operations on Skytap environments.
-
.action_destroy ⇒ Object
This action is called to terminate the remote machine.
- .action_fetch_environment ⇒ Object
- .action_forward_ports ⇒ Object
-
.action_halt ⇒ Object
This action is called to halt the remote machine.
-
.action_prepare_boot ⇒ Object
Note: Provision and SyncedFolders perform actions before and after calling the next middleware in the sequence.
-
.action_provision ⇒ Object
This action is called when ‘vagrant provision` is called.
-
.action_read_ssh_info ⇒ Object
This action is called to read the SSH info of the machine.
-
.action_read_state ⇒ Object
This action is called to read the state of the machine.
- .action_reload ⇒ Object
- .action_resume ⇒ Object
- .action_run_vm ⇒ Object
-
.action_ssh ⇒ Object
This action is called to SSH into the machine.
- .action_ssh_run ⇒ Object
-
.action_suspend ⇒ Object
This action is called to suspend the remote machine.
- .action_update_hardware ⇒ Object
Class Method Details
.action_create ⇒ Object
The Skytap provider has a modified “vagrant up” command which takes advantage of parallel runstate operations on Skytap environments. The create and update_hardware actions are separated from the run_vm action, so we can pass in the ids and initial states for all machines to be run, potentially with a single REST call.
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/vagrant-skytap/action.rb', line 194 def self.action_create Vagrant::Action::Builder.new.tap do |b| b.use HandleBox b.use action_fetch_environment b.use Call, ExistenceCheck do |env, b1| case result = env[:result] when :missing_environment b1.use CreateEnvironment b1.use MessageEnvironmentUrl when :no_vms, :missing_vm b1.use AddVmToEnvironment else next end b1.use StoreExtraData b1.use SetUpVm end end end |
.action_destroy ⇒ Object
This action is called to terminate the remote machine.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/vagrant-skytap/action.rb', line 42 def self.action_destroy Vagrant::Action::Builder.new.tap do |b| b.use action_fetch_environment b.use Call, ExistenceCheck do |env, b1| case existence_state = env[:result] when :missing_environment, :no_vms b1.use MessageNotCreated b1.use DeleteEnvironment next when :missing_vm b1.use MessageNotCreated b1.use DeleteVm next end b1.use Call, DestroyConfirm do |env2, b2| if env2[:result] case existence_state when :one_of_many_vms b2.use DeleteVm else b2.use DeleteEnvironment end b2.use ProvisionerCleanup if defined?(ProvisionerCleanup) else b2.use MessageWillNotDestroy end end end b.use ClearForwardedPorts b.use PrepareNFSValidIds b.use SyncedFolderCleanup end end |
.action_fetch_environment ⇒ Object
281 282 283 284 285 286 287 |
# File 'lib/vagrant-skytap/action.rb', line 281 def self.action_fetch_environment Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate b.use InitializeAPIClient b.use FetchEnvironment end end |
.action_forward_ports ⇒ Object
289 290 291 292 293 294 295 296 297 |
# File 'lib/vagrant-skytap/action.rb', line 289 def self.action_forward_ports Vagrant::Action::Builder.new.tap do |b| b.use ClearForwardedPorts b.use EnvSet, port_collision_repair: true b.use PrepareForwardedPortCollisionParams b.use HandleForwardedPortCollisions b.use ForwardPorts end end |
.action_halt ⇒ Object
This action is called to halt the remote machine.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/vagrant-skytap/action.rb', line 10 def self.action_halt Vagrant::Action::Builder.new.tap do |b| b.use action_fetch_environment b.use Call, ExistenceCheck do |env1, b1| case result = env1[:result] when :missing_environment, :missing_vm, :no_vms b1.use MessageNotCreated else b1.use ClearForwardedPorts b1.use StopVm end end end end |
.action_prepare_boot ⇒ Object
Note: Provision and SyncedFolders perform actions before and after calling the next middleware in the sequence. Both require that the machine be booted before those calls return. This requirement can be satisfied by putting the WaitForCommunicator middleware later in the sequence.
163 164 165 166 167 168 169 170 171 |
# File 'lib/vagrant-skytap/action.rb', line 163 def self.action_prepare_boot Vagrant::Action::Builder.new.tap do |b| b.use PrepareNFSSettings b.use PrepareNFSValidIds b.use Provision b.use SyncedFolderCleanup b.use SyncedFolders end end |
.action_provision ⇒ Object
This action is called when ‘vagrant provision` is called.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/vagrant-skytap/action.rb', line 77 def self.action_provision Vagrant::Action::Builder.new.tap do |b| b.use action_fetch_environment b.use Call, ExistenceCheck do |env, b1| case result = env[:result] when :missing_environment, :missing_vm, :no_vms b1.use MessageNotCreated next end b1.use Call, IsStopped do |env2, b2| b2.use Call, IsRunning do |env3, b3| unless env3[:result] b3.use RunVm b3.use WaitForCommunicator end end was_stopped = env2[:result] if was_stopped b2.use PrepareNFSSettings b2.use PrepareNFSValidIds end b2.use Provision if was_stopped b2.use SyncedFolders end end end end end |
.action_read_ssh_info ⇒ Object
This action is called to read the SSH info of the machine. The resulting state is expected to be put into the ‘:machine_ssh_info` key.
111 112 113 114 115 116 |
# File 'lib/vagrant-skytap/action.rb', line 111 def self.action_read_ssh_info Vagrant::Action::Builder.new.tap do |b| b.use action_fetch_environment b.use ReadSSHInfo end end |
.action_read_state ⇒ Object
This action is called to read the state of the machine. The resulting state is expected to be put into the ‘:machine_state_id` key.
121 122 123 124 125 126 127 |
# File 'lib/vagrant-skytap/action.rb', line 121 def self.action_read_state Vagrant::Action::Builder.new.tap do |b| b.use action_fetch_environment #TODO:NLA Can this whole action be removed? b.use ReadState end end |
.action_reload ⇒ Object
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/vagrant-skytap/action.rb', line 262 def self.action_reload Vagrant::Action::Builder.new.tap do |b| b.use action_fetch_environment b.use Call, ExistenceCheck do |env, b1| case env[:result] when :missing_environment, :missing_vm, :no_vms b1.use MessageNotCreated else b1.use action_halt b1.use action_update_hardware # We don't need to store the initial states # before calling run_vm, because the default # behavior is to treat the VMs as powered off. b1.use action_run_vm end end end end |
.action_resume ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/vagrant-skytap/action.rb', line 173 def self.action_resume Vagrant::Action::Builder.new.tap do |b| b.use action_fetch_environment b.use Call, IsSuspended do |env, b1| if env[:result] b1.use MessageResuming b1.use RunVm b1.use WaitForCommunicator b1.use action_forward_ports end end end end |
.action_run_vm ⇒ Object
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/vagrant-skytap/action.rb', line 227 def self.action_run_vm Vagrant::Action::Builder.new.tap do |b| b.use InitializeAPIClient b.use FetchEnvironment # The "up" command stores the pre-run states to # avoid a race condition when running multiple # VMs in parallel -- we need to know which VMs # are actually being powered on and need to # have folders synced and provisioning run. b.use Call, InitialState do |env, b1| case env[:result] when :running b1.use MessageAlreadyRunning next when :suspended b1.use MessageResuming else b1.use action_prepare_boot end b1.use Call, IsParallelized do |env2, b2| if env2[:result] # Note: RunEnvironment is a no-op after # the first invocation. b2.use RunEnvironment else b2.use RunVm end end end b.use WaitForCommunicator b.use action_forward_ports end end |
.action_ssh ⇒ Object
This action is called to SSH into the machine.
130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/vagrant-skytap/action.rb', line 130 def self.action_ssh Vagrant::Action::Builder.new.tap do |b| b.use action_fetch_environment b.use Call, ExistenceCheck do |env1, b1| case result = env1[:result] when :missing_environment, :missing_vm, :no_vms b1.use MessageNotCreated else b1.use SSHExec end end end end |
.action_ssh_run ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/vagrant-skytap/action.rb', line 144 def self.action_ssh_run Vagrant::Action::Builder.new.tap do |b| b.use action_fetch_environment b.use Call, ExistenceCheck do |env1, b1| case result = env1[:result] when :missing_environment, :missing_vm, :no_vms b1.use MessageNotCreated else b1.use SSHRun end end end end |
.action_suspend ⇒ Object
This action is called to suspend the remote machine.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vagrant-skytap/action.rb', line 26 def self.action_suspend Vagrant::Action::Builder.new.tap do |b| b.use action_fetch_environment b.use Call, ExistenceCheck do |env1, b1| case result = env1[:result] when :missing_environment, :missing_vm, :no_vms b1.use MessageNotCreated else b1.use ClearForwardedPorts b1.use SuspendVm end end end end |
.action_update_hardware ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/vagrant-skytap/action.rb', line 214 def self.action_update_hardware Vagrant::Action::Builder.new.tap do |b| b.use InitializeAPIClient b.use FetchEnvironment b.use Call, IsStopped do |env, b1| if env[:result] b1.use UpdateHardware b1.use SetHostname end end end end |