module VagrantPlugins::Openstack::Action

Public Class Methods

action_destroy() click to toggle source

This action is called to destroy the remote machine.

# File lib/vagrant-openstack-provider/action.rb, line 12
def self.action_destroy
  new_builder.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      else
        b2.use(ProvisionerCleanup, :before)
        b2.use DeleteServer
        b2.use DeleteStack
      end
    end
  end
end
action_halt() click to toggle source
# File lib/vagrant-openstack-provider/action.rb, line 139
def self.action_halt
  new_builder.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      else
        b2.use StopServer
      end
    end
  end
end
action_provision() click to toggle source

This action is called when `vagrant provision` is called.

# File lib/vagrant-openstack-provider/action.rb, line 29
def self.action_provision
  new_builder.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      else
        if env[:machine].provider_config.meta_args_support
          b2.use ProvisionWrapper
        else
          b2.use Provision
        end
        b2.use SyncFolders
      end
    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-openstack-provider/action.rb, line 51
def self.action_read_ssh_info
  new_builder.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use ReadSSHInfo
  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-openstack-provider/action.rb, line 62
def self.action_read_state
  new_builder.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use ReadState
  end
end
action_reload() click to toggle source
# File lib/vagrant-openstack-provider/action.rb, line 195
def self.action_reload
  new_builder.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      case env[:machine_state_id]
      when :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      when :suspended
        b2.use Resume
        b2.use WaitForServerToBeActive
        b2.use StopServer
        b2.use WaitForServerToStop
        b2.use StartServer
      when :shutoff
        b2.use StartServer
      else
        b2.use StopServer
        b2.use WaitForServerToStop
        b2.use StartServer
      end
    end
  end
end
action_resume() click to toggle source

This is the action that is primarily responsible for resuming suspended machines. Vm cannot be resumed when the machine_state_id is not suspended.

# File lib/vagrant-openstack-provider/action.rb, line 178
def self.action_resume
  new_builder.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      case env[:machine_state_id]
      when :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      when :suspended
        b2.use Resume
      else
        b2.use Message, I18n.t('vagrant_openstack.not_suspended')
      end
    end
  end
end
action_ssh() click to toggle source
# File lib/vagrant-openstack-provider/action.rb, line 70
def self.action_ssh
  new_builder.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      else
        b2.use SSHExec
      end
    end
  end
end
action_ssh_run() click to toggle source
# File lib/vagrant-openstack-provider/action.rb, line 84
def self.action_ssh_run
  new_builder.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      else
        b2.use SSHRun
      end
    end
  end
end
action_suspend() click to toggle source

This is the action that is primarily responsible for suspending the virtual machine. Vm cannot be suspended when the machine_state_id is not “active” (typically a task is ongoing)

# File lib/vagrant-openstack-provider/action.rb, line 156
def self.action_suspend
  new_builder.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      case env[:machine_state_id]
      when :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      when :suspended
        b2.use Message, I18n.t('vagrant_openstack.already_suspended')
      when :active
        b2.use Suspend
      else
        b2.use Message, I18n.t('vagrant_openstack.ongoing_task')
      end
    end
  end
end
action_up() click to toggle source
# File lib/vagrant-openstack-provider/action.rb, line 98
def self.action_up
  new_builder.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack

    b.use Call, ReadState do |env, b2|
      case env[:machine_state_id]
      when :not_created
        ssh_disabled = env[:machine].provider_config.ssh_disabled
        unless ssh_disabled
          if env[:machine].provider_config.meta_args_support
            b2.use ProvisionWrapper
          else
            b2.use Provision
          end
        end
        b2.use SyncFolders
        b2.use CreateStack
        b2.use CreateServer
        b2.use Message, I18n.t('vagrant_openstack.ssh_disabled_provisioning') if ssh_disabled
        unless ssh_disabled
          # Handle legacy ssh_timeout option
          timeout = env[:machine].provider_config.ssh_timeout
          unless timeout.nil?
            env[:machine].ui.warn I18n.t('vagrant_openstack.config.ssh_timeout_deprecated')
            env[:machine].config.vm.boot_timeout = timeout
          end

          b2.use WaitForCommunicator
        end
      when :shutoff
        b2.use StartServer
      when :suspended
        b2.use Resume
      else
        b2.use Message, I18n.t('vagrant_openstack.already_created')
      end
    end
  end
end
get_ssh_info(env) click to toggle source
# File lib/vagrant-openstack-provider/action/read_ssh_info.rb, line 67
def self.get_ssh_info(env)
  SSHInfoHolder.instance.ssh_info[env[:machine].id.to_sym]
end

Private Class Methods

new_builder() click to toggle source
# File lib/vagrant-openstack-provider/action.rb, line 241
def self.new_builder
  Vagrant::Action::Builder.new
end