Update SSH config to be more modern

This commit is contained in:
Mitchell Hashimoto 2013-04-03 12:49:59 -07:00
parent 932f15665b
commit 749b7b7d70
2 changed files with 34 additions and 10 deletions

View File

@ -1,6 +1,4 @@
Vagrant.configure("2") do |config|
config.downloader.insecure = false
config.vagrant.host = :detect
config.ssh.username = "vagrant"

View File

@ -3,21 +3,47 @@ require "vagrant"
module VagrantPlugins
module Kernel_V2
class SSHConfig < Vagrant.plugin("2", :config)
attr_accessor :username
attr_accessor :host
attr_accessor :port
attr_accessor :guest_port
attr_accessor :max_tries
attr_accessor :timeout
attr_accessor :private_key_path
attr_accessor :forward_agent
attr_accessor :forward_x11
attr_accessor :guest_port
attr_accessor :host
attr_accessor :max_tries
attr_accessor :port
attr_accessor :private_key_path
attr_accessor :shell
attr_accessor :timeout
attr_accessor :username
def initialize
@forward_agent = UNSET_VALUE
@forward_x11 = UNSET_VALUE
@guest_port = UNSET_VALUE
@host = UNSET_VALUE
@max_tries = UNSET_VALUE
@port = UNSET_VALUE
@private_key_path = UNSET_VALUE
@shell = UNSET_VALUE
@timeout = UNSET_VALUE
@username = UNSET_VALUE
end
def finalize!
@forward_agent = false if @forward_agent == UNSET_VALUE
@forward_x11 = false if @forward_x11 == UNSET_VALUE
@guest_port = nil if @guest_port == UNSET_VALUE
@host = nil if @host == UNSET_VALUE
@max_tries = nil if @max_tries == UNSET_VALUE
@port = nil if @port == UNSET_VALUE
@private_key_path = nil if @private_key_path == UNSET_VALUE
@shell = nil if @shell == UNSET_VALUE
@timeout = nil if @timeout == UNSET_VALUE
@username = nil if @username == UNSET_VALUE
end
def validate(machine)
errors = []
[:username, :max_tries, :timeout].each do |field|
[:max_tries, :timeout].each do |field|
value = instance_variable_get("@#{field}".to_sym)
errors << I18n.t("vagrant.config.common.error_empty", :field => field) if !value
end