Class: VagrantPlugins::VCenter::Provider

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

Overview

Initialize Vagrant Provider.

Instance Method Summary collapse

Constructor Details

#initialize(machine) ⇒ Provider

Returns a new instance of Provider.



8
9
10
# File 'lib/vagrant-vcenter/provider.rb', line 8

def initialize(machine)
  @machine = machine
end

Instance Method Details

#action(name) ⇒ Object



12
13
14
15
16
# File 'lib/vagrant-vcenter/provider.rb', line 12

def action(name)
  action_method = "action_#{name}"
  return Action.send(action_method) if Action.respond_to?(action_method)
  nil
end

#ssh_infoObject

Read and return SSH info



19
20
21
22
# File 'lib/vagrant-vcenter/provider.rb', line 19

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

#stateVagrant::MachineState

Read state and return the current MachineState object

Returns:

  • (Vagrant::MachineState)


27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/vagrant-vcenter/provider.rb', line 27

def state
  env = @machine.action('read_state')

  state_id = env[:machine_state_id]

  # Translate into short/long descriptions
  short = state_id.to_s.gsub('_', ' ')
  long  = I18n.t("vagrant_vcenter.states.#{state_id}")

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

#to_sObject



40
41
42
43
# File 'lib/vagrant-vcenter/provider.rb', line 40

def to_s
  id = @machine.id.nil? ? 'new' : @machine.id
  "vCenter (#{id})"
end