Sha256: 782ad1e35b789ae1e0cc5554abe487ad460e3d669567d994293e471769e9a298

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

require 'vagrant-vultr/helpers/client'

module VagrantPlugins
  module Vultr
    class Provider < Vagrant.plugin(2, :provider)
      include Helpers::Client

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

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

      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

      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
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
vagrant-vultr-0.1.3 lib/vagrant-vultr/provider.rb
vagrant-vultr_pro-0.2.3 lib/vagrant-vultr/provider.rb
vagrant-vultr_pro-0.2.2 lib/vagrant-vultr/provider.rb
vagrant-vultr_pro-0.2.1 lib/vagrant-vultr/provider.rb
vagrant-vultr2-0.1.4 lib/vagrant-vultr/provider.rb
vagrant-vultr-0.1.2 lib/vagrant-vultr/provider.rb
vagrant-vultr-0.1.1 lib/vagrant-vultr/provider.rb
vagrant-vultr-0.1.0 lib/vagrant-vultr/provider.rb