From 749b7b7d706cdc099bfc461698434519bde843bb Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 3 Apr 2013 12:49:59 -0700 Subject: [PATCH] Update SSH config to be more modern --- config/default.rb | 2 -- plugins/kernel_v2/config/ssh.rb | 42 ++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/config/default.rb b/config/default.rb index b86db2b6c..e38414480 100644 --- a/config/default.rb +++ b/config/default.rb @@ -1,6 +1,4 @@ Vagrant.configure("2") do |config| - config.downloader.insecure = false - config.vagrant.host = :detect config.ssh.username = "vagrant" diff --git a/plugins/kernel_v2/config/ssh.rb b/plugins/kernel_v2/config/ssh.rb index 689a2ea5c..e57bc3ba0 100644 --- a/plugins/kernel_v2/config/ssh.rb +++ b/plugins/kernel_v2/config/ssh.rb @@ -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