Class: VagrantPlugins::ESXi::Provider

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-vmware-esxi/provider.rb

Overview

Provider class

Instance Method Summary collapse

Constructor Details

#initialize(machine) ⇒ Provider

Returns a new instance of Provider.



8
9
10
11
# File 'lib/vagrant-vmware-esxi/provider.rb', line 8

def initialize(machine)
  @machine = machine
  @logger = Log4r::Logger.new('vagrant_vmware_esxi::action::provider')
end

Instance Method Details

#action(name) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/vagrant-vmware-esxi/provider.rb', line 13

def action(name)
  method = "action_#{name}"
  if Action.respond_to? method
    Action.send(method)
  else
    # the specified action is not supported
    nil
  end
end

#ssh_infoObject



42
43
44
45
# File 'lib/vagrant-vmware-esxi/provider.rb', line 42

def ssh_info
  env = @machine.action('read_ssh_info')
  env[:machine_ssh_info]
end

#stateObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vagrant-vmware-esxi/provider.rb', line 23

def state
  env = @machine.action('read_state')
  state_id = env[:machine_state]

  # Get the short and long description
  @logger.info("vagrant-vmware-esxi, boot: state_id: #{env[:state_id]}")

  short = I18n.t("vagrant_vmware_esxi.states.#{state_id}.short")
  long  = I18n.t("vagrant_vmware_esxi.states.#{state_id}.long")

  # If we're not created, then specify the special ID flag
  if state_id == :not_created
    state_id = Vagrant::MachineState::NOT_CREATED_ID
  end

  # Return the MachineState object
  Vagrant::MachineState.new(state_id, short, long)
end