module HashiCorp::VagrantVMwareDesktop::Action

Public Class Methods

action_destroy() click to toggle source

This action is called to destroy a VM.

# 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_halt() click to toggle source

This action is called to stop a running VM.

# 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_package() click to toggle source

This action is called to package a VM.

# 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_provision() click to toggle source

This action is called to provision a VM.

# 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_reload() click to toggle source

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

# 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_resume() click to toggle source

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

# 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_delete() click to toggle source

This action is called to delete a snapshot.

# 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_restore() click to toggle source

This action is called to restore a snapshot.

# 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_save() click to toggle source

This action is called to save a snapshot.

# 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_ssh() click to toggle source

This action is called to SSH into the machine.

# 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_run() click to toggle source

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

# 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_start() click to toggle source

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

# 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_suspend() click to toggle source

This action is called to stop a running VM.

# 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_up() click to toggle source

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

# 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