Module: HashiCorp::VagrantVMwareDesktop::Action

Includes:
Vagrant::Action::Builtin, Vagrant::Action::General
Defined in:
lib/vagrant-vmware-desktop/action.rb,
lib/vagrant-vmware-desktop/action/boot.rb,
lib/vagrant-vmware-desktop/action/halt.rb,
lib/vagrant-vmware-desktop/action/common.rb,
lib/vagrant-vmware-desktop/action/export.rb,
lib/vagrant-vmware-desktop/action/import.rb,
lib/vagrant-vmware-desktop/action/created.rb,
lib/vagrant-vmware-desktop/action/destroy.rb,
lib/vagrant-vmware-desktop/action/network.rb,
lib/vagrant-vmware-desktop/action/running.rb,
lib/vagrant-vmware-desktop/action/suspend.rb,
lib/vagrant-vmware-desktop/action/suspended.rb,
lib/vagrant-vmware-desktop/action/checkpoint.rb,
lib/vagrant-vmware-desktop/action/vmx_modify.rb,
lib/vagrant-vmware-desktop/action/check_vmware.rb,
lib/vagrant-vmware-desktop/action/machine_lock.rb,
lib/vagrant-vmware-desktop/action/compatibility.rb,
lib/vagrant-vmware-desktop/action/forward_ports.rb,
lib/vagrant-vmware-desktop/action/share_folders.rb,
lib/vagrant-vmware-desktop/action/snapshot_save.rb,
lib/vagrant-vmware-desktop/action/base_mac_to_ip.rb,
lib/vagrant-vmware-desktop/action/snapshot_delete.rb,
lib/vagrant-vmware-desktop/action/set_display_name.rb,
lib/vagrant-vmware-desktop/action/snapshot_restore.rb,
lib/vagrant-vmware-desktop/action/wait_for_address.rb,
lib/vagrant-vmware-desktop/action/prune_nfs_exports.rb,
lib/vagrant-vmware-desktop/action/wait_for_vmx_halt.rb,
lib/vagrant-vmware-desktop/action/fix_old_machine_id.rb,
lib/vagrant-vmware-desktop/action/message_not_created.rb,
lib/vagrant-vmware-desktop/action/message_not_running.rb,
lib/vagrant-vmware-desktop/action/package_vagrantfile.rb,
lib/vagrant-vmware-desktop/action/clear_shared_folders.rb,
lib/vagrant-vmware-desktop/action/prepare_nfs_settings.rb,
lib/vagrant-vmware-desktop/action/prune_forwarded_ports.rb,
lib/vagrant-vmware-desktop/action/check_existing_network.rb,
lib/vagrant-vmware-desktop/action/discard_suspended_state.rb,
lib/vagrant-vmware-desktop/action/message_already_running.rb,
lib/vagrant-vmware-desktop/action/wait_for_communicator_compat.rb,
lib/vagrant-vmware-desktop/action/prepare_synced_folder_cleanup.rb,
lib/vagrant-vmware-desktop/action/prepare_forwarded_port_collision_params.rb

Defined Under Namespace

Modules: Common Classes: BaseMacToIp, Boot, CheckExistingNetwork, CheckVMware, Checkpoint, ClearSharedFolders, Compatibility, Created, Destroy, DiscardSuspendedState, Export, FixOldMachineID, ForwardPorts, Halt, Import, MachineLock, MessageAlreadyRunning, MessageNotCreated, MessageNotRunning, Network, PackageVagrantfile, PrepareForwardedPortCollisionParams, PrepareNFSSettings, PrepareSyncedFolderCleanup, PruneForwardedPorts, PruneNFSExports, Running, SetDisplayName, ShareFolders, SnapshotDelete, SnapshotRestore, SnapshotSave, Suspend, Suspended, VMXModify, WaitForAddress, WaitForCommunicatorCompat, WaitForVMXHalt

Class Method Summary collapse

Class Method Details

.action_destroyObject

This action is called to destroy a VM.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/vagrant-vmware-desktop/action.rb', line 57

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility

    if Vagrant::VERSION < "1.6.0"
      b.use MachineLock
    end

    b.use FixOldMachineID
    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 ProvisionerCleanup, :before if defined?(ProvisionerCleanup)
          b3.use EnvSet, :force_halt => env2.key?(:force_halt) ? env2[:force_halt] : true
          b3.use action_halt
          b3.use Destroy
          b3.use PruneForwardedPorts

          if Vagrant::VERSION < "1.4.0"
            b3.use PruneNFSExports
          else
            b3.use PrepareSyncedFolderCleanup
            b3.use SyncedFolderCleanup
          end
        end
      end
    end
    b.use Checkpoint
  end
end

.action_haltObject

This action is called to stop a running VM.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/vagrant-vmware-desktop/action.rb', line 95

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility
    b.use ConfigValidate
    b.use FixOldMachineID
    b.use CheckVMware

    if Vagrant::VERSION < "1.6.0"
      b.use MachineLock
    end

    b.use Call, Created do |env1, b2|
      if !env1[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use DiscardSuspendedState
      b2.use Call, Running do |env2, b3|
        if env2[:result]
          b3.use Call, GracefulHalt, :not_running, :running do |env3, b4|
            if !env3[:result]
              b4.use DiscardSuspendedState
              b4.use Halt
            end

            b4.use WaitForVMXHalt
          end
        end
      end
    end
    b.use Checkpoint
  end
end

.action_packageObject

This action is called to package a VM.



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/vagrant-vmware-desktop/action.rb', line 131

def self.action_package
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility
    b.use ConfigValidate
    b.use FixOldMachineID

    b.use Call, Created do |env1, b2|
      if !env1[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use PackageSetupFolders
      b2.use PackageSetupFiles
      b2.use action_halt
      b2.use PruneForwardedPorts
      b2.use PrepareSyncedFolderCleanup
      b2.use SyncedFolderCleanup
      b2.use Package
      b2.use Export
      b2.use PackageVagrantfile
    end
    b.use Checkpoint
  end
end

.action_provisionObject

This action is called to provision a VM.



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/vagrant-vmware-desktop/action.rb', line 158

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility
    b.use ConfigValidate
    b.use FixOldMachineID

    b.use Call, Created do |env1, b2|
      if !env1[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use Call, Running do |env2, b3|
        if !env2[:result]
          raise Vagrant::Errors::VMNotRunningError
        end

        b3.use Provision
      end
    end
    b.use Checkpoint
  end
end

.action_reloadObject

This action is called when the VM is to be stopped then started.



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/vagrant-vmware-desktop/action.rb', line 183

def self.action_reload
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility
    b.use FixOldMachineID
    b.use Call, Created do |env1, b2|
      if !env1[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use action_halt
      b2.use action_start
    end
    b.use Checkpoint
  end
end

.action_resumeObject

This action is called when the VM is to be resumed.



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/vagrant-vmware-desktop/action.rb', line 201

def self.action_resume
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility
    b.use ConfigValidate
    b.use FixOldMachineID
    b.use CheckVMware
    b.use Call, Created do |env1, b2|
      if !env1[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use action_start
    end
    b.use Checkpoint
  end
end

.action_snapshot_deleteObject

This action is called to delete a snapshot.



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/vagrant-vmware-desktop/action.rb', line 220

def self.action_snapshot_delete
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility
    b.use ConfigValidate
    b.use FixOldMachineID
    b.use CheckVMware

    b.use Call, Created do |env1, b2|
      if !env1[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use SnapshotDelete
    end
    b.use Checkpoint
  end
end

.action_snapshot_restoreObject

This action is called to restore a snapshot.



240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/vagrant-vmware-desktop/action.rb', line 240

def self.action_snapshot_restore
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility
    b.use ConfigValidate
    b.use FixOldMachineID
    b.use CheckVMware

    b.use Call, Created do |env1, b2|
      if !env1[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use SnapshotRestore
      b2.use action_start
    end
    b.use Checkpoint
  end
end

.action_snapshot_saveObject

This action is called to save a snapshot.



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/vagrant-vmware-desktop/action.rb', line 261

def self.action_snapshot_save
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility
    b.use ConfigValidate
    b.use FixOldMachineID
    b.use CheckVMware

    b.use Call, Created do |env1, b2|
      if !env1[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use SnapshotSave
    end
    b.use Checkpoint
  end
end

.action_sshObject

This action is called to SSH into the machine.



281
282
283
284
285
286
287
288
289
290
# File 'lib/vagrant-vmware-desktop/action.rb', line 281

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility
    b.use ConfigValidate
    b.use FixOldMachineID
    b.use CheckVMware
    b.use SSHExec
    b.use Checkpoint
  end
end

.action_ssh_runObject

This action is called that will run a single SSH command.



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/vagrant-vmware-desktop/action.rb', line 293

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility
    b.use ConfigValidate
    b.use FixOldMachineID
    b.use CheckVMware
    b.use Call, Created do |env1, b2|
      if !env1[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use Call, Running do |env2, b3|
        if !env2[:result]
          raise Vagrant::Errors::VMNotRunningError
        end

        b3.use SSHRun
      end
    end
    b.use Checkpoint
  end
end

.action_startObject

This action starts the VM, from whatever state it may be.



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# File 'lib/vagrant-vmware-desktop/action.rb', line 318

def self.action_start
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility
    b.use FixOldMachineID

    if Vagrant::VERSION >= "1.5.0"
      b.use BoxCheckOutdated
    end

    b.use Call, Running do |env, b2|
      if env[:result]
        b2.use MessageAlreadyRunning
        next
      end

      b2.use CheckExistingNetwork
      b2.use PruneForwardedPorts
      b2.use Call, Suspended do |env2, b3|
        # If it is suspended then the following have no effect
        if !env2[:result]
          if Vagrant::VERSION < "1.6.0"
            b3.use MachineLock
          end

          b3.use Provision

          if Vagrant::VERSION < "1.4.0"
            b3.use PruneNFSExports
            b3.use NFS
            b3.use ClearSharedFolders
            b3.use ShareFolders
          else
            b3.use PrepareSyncedFolderCleanup
            b3.use SyncedFolderCleanup
            b3.use SyncedFolders
          end

          b3.use PrepareNFSSettings
          b3.use Network
          b3.use BaseMacToIp
          b3.use SetHostname
        end

        Vagrant::Util::Experimental.guard_with(:disks) do
          b3.use CleanupDisks
          b3.use Disk
        end
        b3.use VMXModify
        b3.use PrepareForwardedPortCollisionParams
        b3.use HandleForwardedPortCollisions
        b3.use Boot
        b3.use WaitForAddress
        b3.use ForwardPorts

        if Vagrant::VERSION < "1.3.0"
          b3.use WaitForCommunicatorCompat
        else
          b3.use WaitForCommunicator
        end
      end
    end
    b.use Checkpoint
  end
end

.action_suspendObject

This action is called to stop a running VM.



384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/vagrant-vmware-desktop/action.rb', line 384

def self.action_suspend
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility
    b.use ConfigValidate
    b.use FixOldMachineID
    b.use CheckVMware
    b.use Call, Created do |env1, b2|
      if !env1[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use Suspend
    end
    b.use Checkpoint
  end
end

.action_upObject

This action is called to bring the box up from nothing.



403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/vagrant-vmware-desktop/action.rb', line 403

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use Compatibility
    b.use ConfigValidate
    b.use FixOldMachineID
    b.use CheckVMware

    if Vagrant::VERSION < "1.6.0"
      b.use MachineLock
    end


    b.use Call, Created do |env1, b2|
      if !env1[:result]
        # If it is not created, then we need to grab the box,
        # import it, and so on.
        if Vagrant::VERSION < "1.5.0"
          b2.use HandleBoxUrl
        else
          b2.use HandleBox
        end

        # Vagrant 1.8 added config.vm.clone. We do some things
        # to get ready for it here.
        if Vagrant::VERSION >= "1.8.0"
          b2.use PrepareClone
        end

        b2.use Import
        b2.use SetDisplayName
      end

      b2.use action_start
    end
    b.use Checkpoint
  end
end