module VagrantPlugins::OpenNebulaProvider::Action

Public Class Methods

check_state() click to toggle source
# File lib/opennebula-provider/action.rb, line 136
def self.check_state
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use CheckState
  end
end
destroy() click to toggle source
# File lib/opennebula-provider/action.rb, line 18
def self.destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, CheckState do |env, b1|
      case env[:machine_state]
      when :active, :error, :suspended, :inactive, :stopped
        b1.use Call, DestroyConfirm do |env1, b2|
          if env1[:result]
            b2.use Destroy
            b2.use ProvisionerCleanup if defined?(ProvisionerCleanup)
          else
            b2.use MessageWillNotDestroy
          end
        end
      when :not_created
        b1.use MessageNotCreated
        next
      end
    end
  end
end
halt() click to toggle source
# File lib/opennebula-provider/action.rb, line 65
def self.halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, CheckState do |env1, b1|
      case env1[:machine_state]
      when :active
        b1.use Stop
        b1.use WaitForState, :stopped
      when :suspended
        b1.use MessageSuspended
      when :stopped
        b1.use MessageAlreadyHalted
      when :not_created, :inactive
        b1.use MessageNotCreated
      end
    end
  end
end
provision() click to toggle source
# File lib/opennebula-provider/action.rb, line 143
def self.provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, CheckState do |env1, b1|
      case env1[:machine_state]
      when :not_created, :inactive
        b1.use MessageNotCreated
      when :suspended
        b1.use MessageSuspended
      when :stopped
        b1.use MessageHalted
      else
        b1.use Provision
      end
    end
  end
end
read_ssh_info() click to toggle source
# File lib/opennebula-provider/action.rb, line 161
def self.read_ssh_info
  Vagrant::Action::Builder.new.tap do |b|
    b.use ReadSSHInfo
  end
end
reload() click to toggle source
# File lib/opennebula-provider/action.rb, line 120
def self.reload
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, CheckState do |env1, b1|
      case env1[:machine_state]
      when :not_created
        b1.use MessageNotCreated
        next
      end

      b1.use halt
      b1.use up
    end
  end
end
resume() click to toggle source
# File lib/opennebula-provider/action.rb, line 102
def self.resume
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, CheckState do |env1, b1|
      case env1[:machine_state]
      when :suspended
        # TODO: uncomment this with patching fog
        # b1.use Resume
        # b1.use WaitForState, :active
      when :stopped
        b1.use MessageHalted
      when :not_created, :inactive
        b1.use MessageNotCreated
      end
    end
  end
end
ssh() click to toggle source
# File lib/opennebula-provider/action.rb, line 185
def self.ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, CheckState do |env1, b1|
      case env1[:machine_state]
      when :not_created, :inactive
        b1.use MessageNotCreated
      when :suspended
        b1.use MessageSuspended
      when :stopped
        b1.use MessageStopped
      else
        b1.use SSHExec
      end
    end
  end
end
ssh_run() click to toggle source
# File lib/opennebula-provider/action.rb, line 167
def self.ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, CheckState do |env1, b1|
      case env1[:machine_state]
      when :not_created, :inactive
        b1.use MessageNotCreated
      when :suspended
        b1.use MessageSuspended
      when :stopped
        b1.use MessageStopped
      else
        b1.use SSHRun
      end
    end
  end
end
suspend() click to toggle source
# File lib/opennebula-provider/action.rb, line 84
def self.suspend
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, CheckState do |env1, b1|
      case env1[:machine_state]
      when :active
        # TODO: uncomment this with patching fog
        # b1.use Suspend
        # b1.use WaitForState, :suspended
      when :suspended
        b1.use MessageAlreadySuspended
      when :not_created, :inactive
        b1.use MessageNotCreated
      end
    end
  end
end
up() click to toggle source
# File lib/opennebula-provider/action.rb, line 40
def self.up
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, CheckState do |env, b1|
      case env[:machine_state]
      when :active
        b1.use MessageAlreadyCreated
        next
      when :suspended
        # TODO: uncomment this with patching fog
        # b1.use Resume
      when :stopped
        b1.use Start
      when :not_created, :inactive
        b1.use Create
      when :error    # in state FAILED
        b1.use MessageInErrorState
        next
      end
      b1.use WaitForCommunicator, [:pending, :prolog, :boot, :active]
      b1.use SyncedFolders
    end
  end
end