2014-03-11 05:38:31 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module CommunicatorWinRM
|
|
|
|
class Config < 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
|
2014-06-03 04:03:07 +00:00
|
|
|
attr_accessor :ssl
|
2014-03-11 05:38:31 +00:00
|
|
|
|
|
|
|
def initialize
|
2014-07-22 22:28:50 +00:00
|
|
|
@username = UNSET_VALUE
|
|
|
|
@password = UNSET_VALUE
|
|
|
|
@host = UNSET_VALUE
|
|
|
|
@port = UNSET_VALUE
|
|
|
|
@guest_port = UNSET_VALUE
|
|
|
|
@max_tries = UNSET_VALUE
|
|
|
|
@timeout = UNSET_VALUE
|
|
|
|
@ssl = UNSET_VALUE
|
|
|
|
@ssl_peer_verification = UNSET_VALUE
|
2014-03-11 05:38:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def finalize!
|
|
|
|
@username = "vagrant" if @username == UNSET_VALUE
|
|
|
|
@password = "vagrant" if @password == UNSET_VALUE
|
|
|
|
@host = nil if @host == UNSET_VALUE
|
2014-06-03 04:26:40 +00:00
|
|
|
@port = (@ssl ? 5986 : 5985) if @port == UNSET_VALUE
|
|
|
|
@guest_port = (@ssl ? 5986 : 5985) if @guest_port == UNSET_VALUE
|
2014-03-11 05:38:31 +00:00
|
|
|
@max_tries = 20 if @max_tries == UNSET_VALUE
|
|
|
|
@timeout = 1800 if @timeout == UNSET_VALUE
|
2014-06-03 04:03:07 +00:00
|
|
|
@ssl = false if @ssl == UNSET_VALUE
|
2014-07-22 22:28:50 +00:00
|
|
|
@ssl_peer_verification = true if @ssl_peer_verification == UNSET_VALUE
|
2014-03-11 05:38:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def validate(machine)
|
|
|
|
errors = []
|
|
|
|
|
2014-03-11 05:54:02 +00:00
|
|
|
errors << "winrm.username cannot be nil." if @username.nil?
|
|
|
|
errors << "winrm.password cannot be nil." if @password.nil?
|
|
|
|
errors << "winrm.port cannot be nil." if @port.nil?
|
|
|
|
errors << "winrm.guest_port cannot be nil." if @guest_port.nil?
|
|
|
|
errors << "winrm.max_tries cannot be nil." if @max_tries.nil?
|
|
|
|
errors << "winrm.timeout cannot be nil." if @timeout.nil?
|
2014-07-22 22:28:50 +00:00
|
|
|
unless @ssl_peer_verification == true || @ssl_peer_verification == false
|
|
|
|
errors << "winrm.ssl_peer_verification must be a boolean."
|
|
|
|
end
|
2014-03-11 05:38:31 +00:00
|
|
|
|
|
|
|
{ "WinRM" => errors }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|