2013-04-09 03:50:15 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module Kernel_V2
|
|
|
|
class SSHConnectConfig < Vagrant.plugin("2", :config)
|
|
|
|
attr_accessor :host
|
|
|
|
attr_accessor :port
|
|
|
|
attr_accessor :private_key_path
|
|
|
|
attr_accessor :username
|
2014-01-03 17:48:35 +00:00
|
|
|
attr_accessor :password
|
2014-01-03 19:13:21 +00:00
|
|
|
attr_accessor :insert_key
|
2016-05-29 21:58:44 +00:00
|
|
|
attr_accessor :keys_only
|
|
|
|
attr_accessor :paranoid
|
2013-04-09 03:50:15 +00:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
@host = UNSET_VALUE
|
|
|
|
@port = UNSET_VALUE
|
|
|
|
@private_key_path = UNSET_VALUE
|
|
|
|
@username = UNSET_VALUE
|
2014-01-03 17:48:35 +00:00
|
|
|
@password = UNSET_VALUE
|
2014-01-03 19:13:21 +00:00
|
|
|
@insert_key = UNSET_VALUE
|
2016-05-29 21:58:44 +00:00
|
|
|
@keys_only = UNSET_VALUE
|
|
|
|
@paranoid = UNSET_VALUE
|
2013-04-09 03:50:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def finalize!
|
|
|
|
@host = nil if @host == UNSET_VALUE
|
|
|
|
@port = nil if @port == UNSET_VALUE
|
|
|
|
@private_key_path = nil if @private_key_path == UNSET_VALUE
|
|
|
|
@username = nil if @username == UNSET_VALUE
|
2014-01-03 17:48:35 +00:00
|
|
|
@password = nil if @password == UNSET_VALUE
|
2014-01-03 19:13:21 +00:00
|
|
|
@insert_key = true if @insert_key == UNSET_VALUE
|
2016-05-29 21:58:44 +00:00
|
|
|
@keys_only = true if @keys_only == UNSET_VALUE
|
|
|
|
@paranoid = false if @paranoid == UNSET_VALUE
|
2013-11-25 23:45:39 +00:00
|
|
|
|
|
|
|
if @private_key_path && !@private_key_path.is_a?(Array)
|
|
|
|
@private_key_path = [@private_key_path]
|
|
|
|
end
|
2013-04-09 03:50:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# NOTE: This is _not_ a valid config validation method, since it
|
|
|
|
# returns an _array_ of strings rather than a Hash. This is meant to
|
|
|
|
# be used with a subclass that handles this.
|
|
|
|
#
|
|
|
|
# @return [Array<String>]
|
|
|
|
def validate(machine)
|
|
|
|
errors = _detected_errors
|
|
|
|
|
2013-11-25 23:45:39 +00:00
|
|
|
if @private_key_path
|
|
|
|
@private_key_path.each do |raw_path|
|
|
|
|
path = File.expand_path(raw_path, machine.env.root_path)
|
|
|
|
if !File.file?(path)
|
|
|
|
errors << I18n.t(
|
|
|
|
"vagrant.config.ssh.private_key_missing",
|
|
|
|
path: raw_path)
|
|
|
|
end
|
|
|
|
end
|
2013-04-09 03:50:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
errors
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|