vagrant/plugins/kernel_v2/config/ssh.rb

37 lines
1.0 KiB
Ruby
Raw Normal View History

2012-11-07 05:28:44 +00:00
require "vagrant"
module VagrantPlugins
module Kernel_V2
class SSHConfig < Vagrant.plugin("2", :config)
attr_accessor :username
attr_accessor :password
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 :shell
def validate(machine)
errors = []
[:username, :max_tries, :timeout].each do |field|
2012-11-07 05:28:44 +00:00
value = instance_variable_get("@#{field}".to_sym)
errors << I18n.t("vagrant.config.common.error_empty", :field => field) if !value
2012-11-07 05:28:44 +00:00
end
if private_key_path && \
!File.file?(File.expand_path(private_key_path, machine.env.root_path))
errors << I18n.t("vagrant.config.ssh.private_key_missing", :path => private_key_path)
2012-11-07 05:28:44 +00:00
end
# Return the errors
{ "ssh" => errors }
2012-11-07 05:28:44 +00:00
end
end
end
end