Class: VagrantPlugins::Vultr::Provider

Inherits:
Object
  • Object
show all
Includes:
Helpers::Client
Defined in:
lib/vagrant-vultr/provider.rb

Instance Method Summary collapse

Methods included from Helpers::Client

#client

Constructor Details

#initialize(machine) ⇒ Provider

Returns a new instance of Provider.



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

def initialize(machine)
  @machine = machine
  @client = client
end

Instance Method Details

#action(name) ⇒ Object



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

def action(name)
  return unless Action.respond_to?(name)
  Action.__send__(name)
end

#ssh_infoObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/vagrant-vultr/provider.rb', line 35

def ssh_info
  server = @client.server(@machine.id)
  return if server['status'] != 'active' && server['power_status'] != 'running'

  {
    host: server['main_ip'],
    port: '22',
    username: 'root',
    PasswordAuthentication: 'no'
  }
end

#stateObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant-vultr/provider.rb', line 18

def state
  server = @client.server(@machine.id)

  if server
    if server['status'] == 'active' && server['power_status'] == 'running'
      state = :active
    else
      state = :off
    end
  else
    state = :not_created
  end

  long = short = state.to_s
  Vagrant::MachineState.new(state, short, long)
end