module VagrantPlugins::OVirtProvider::Action

Public Class Methods

action_destroy() click to toggle source
# File lib/vagrant-ovirt4/action.rb, line 46
def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if !env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use ConnectOVirt
      b2.use ProvisionerCleanup, :before if defined?(ProvisionerCleanup)
      b2.use HaltVM
      b2.use WaitTillDown
      b2.use DestroyVM
      b2.use DisconnectOVirt
    end
  end
end
action_halt() click to toggle source
# File lib/vagrant-ovirt4/action.rb, line 146
def self.action_halt
  with_ovirt do |env, b|
    b.use Call, IsRunning do |env2, b2|
      if env[:machine_state_id] == :powering_up
        b2.use MessagePoweringUp
        next
      end
      if !env2[:result]
        b2.use MessageNotUp
        next
      end
      b2.use HaltVM
      b2.use WaitTillDown
    end
  end
end
action_provision() click to toggle source
# File lib/vagrant-ovirt4/action.rb, line 65
def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if !env[:result]
        b2.use MessageNotCreated
        next
      end
      b2.use Provision
      b2.use SyncFolders
    end
  end
end
action_read_ssh_info() click to toggle source

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.

# File lib/vagrant-ovirt4/action.rb, line 94
def self.action_read_ssh_info
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOVirt
    b.use ReadSSHInfo
    b.use DisconnectOVirt
  end
end
action_read_state() click to toggle source

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.

# File lib/vagrant-ovirt4/action.rb, line 81
def self.action_read_state
  Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use ConnectOVirt
    b.use ReadState
    b.use DisconnectOVirt
  end
end
action_reload() click to toggle source
# File lib/vagrant-ovirt4/action.rb, line 163
def self.action_reload
  with_ovirt do |env, b|
    b.use action_halt
    b.use action_up
  end
end
action_resume() click to toggle source
# File lib/vagrant-ovirt4/action.rb, line 187
def self.action_resume
  with_ovirt do |env, b|
    if env[:machine_state_id] == :saving_state
      b.use MessageSavingState
      next
    end
    if env[:machine_state_id] != :suspended
      b.use MessageNotSuspended
      next
    end
    b.use action_up
  end
end
action_snapshot_delete() click to toggle source
# File lib/vagrant-ovirt4/action.rb, line 213
def self.action_snapshot_delete
  with_ovirt do |env, b|
    b.use SnapshotDelete
  end
end
action_snapshot_list() click to toggle source
# File lib/vagrant-ovirt4/action.rb, line 201
def self.action_snapshot_list
  with_ovirt do |env, b|
    b.use SnapshotList
  end
end
action_snapshot_save() click to toggle source
# File lib/vagrant-ovirt4/action.rb, line 207
def self.action_snapshot_save
  with_ovirt do |env, b|
    b.use SnapshotSave
  end
end
action_ssh() click to toggle source
# File lib/vagrant-ovirt4/action.rb, line 103
def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOVirt
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use MessageNotCreated
        next
      end
      if env[:machine_state_id] != :up
        b2.use MessageNotUp
        next
      end

      raise Errors::NoIPError if env[:ip_address].nil?
      b2.use SSHExec
    end
    b.use DisconnectOVirt
  end
end
action_ssh_run() click to toggle source
# File lib/vagrant-ovirt4/action.rb, line 124
def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOVirt
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use MessageNotCreated
        next
      end
      if env[:machine_state_id] != :up
        b2.use MessageNotUp
        next
      end

      raise Errors::NoIPError if env[:ip_address].nil?
      b2.use SSHRun
    end
    b.use DisconnectOVirt
  end
end
action_suspend() click to toggle source
# File lib/vagrant-ovirt4/action.rb, line 170
def self.action_suspend
  with_ovirt do |env, b|
    b.use Call, IsRunning do |env2, b2|
      if env[:machine_state_id] == :powering_up
        b2.use MessagePoweringUp
        next
      end
      if !env2[:result]
        b2.use MessageNotUp
        next
      end
      b2.use SuspendVM
      b2.use WaitTilSuspended
    end
  end
end
action_up() click to toggle source

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

# File lib/vagrant-ovirt4/action.rb, line 10
def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use ConnectOVirt
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :up
        b2.use SyncFolders
        b2.use MessageAlreadyUp
        next
      end

      if env[:machine_state_id] == :saving_state
        b2.use MessageSavingState
        next
      end

      if env[:machine_state_id] == :not_created
        b2.use SetNameOfDomain
        b2.use CreateVM
        b2.use ResizeDisk

        b2.use Provision
        b2.use CreateNetworkInterfaces

        b2.use SetHostname
      end

      b2.use StartVM
      b2.use WaitTillUp
      b2.use SyncFolders
    end
    b.use DisconnectOVirt
  end
end

Private Class Methods

with_ovirt() { |env, b2| ... } click to toggle source
# File lib/vagrant-ovirt4/action.rb, line 250
def self.with_ovirt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOVirt
    b.use Call, ReadState do |env, b2|
      if !env[:machine_state_id] == :not_created
        b2.use MessageNotCreated
        next
      end
      yield env, b2
    end
    b.use DisconnectOVirt
  end
end