2014-05-22 17:20:45 +00:00
|
|
|
require "pathname"
|
|
|
|
require "tmpdir"
|
2014-04-12 22:44:39 +00:00
|
|
|
|
2014-05-21 03:47:32 +00:00
|
|
|
require "vagrant/util/subprocess"
|
2014-04-12 22:44:39 +00:00
|
|
|
|
|
|
|
module VagrantPlugins
|
|
|
|
module HostWindows
|
|
|
|
module Cap
|
|
|
|
class RDP
|
|
|
|
def self.rdp_client(env, rdp_info)
|
|
|
|
config = nil
|
|
|
|
opts = {
|
2014-04-12 23:22:35 +00:00
|
|
|
"full address:s" => "#{rdp_info[:host]}:#{rdp_info[:port]}",
|
2014-04-12 22:44:39 +00:00
|
|
|
"prompt for credentials:i" => "1",
|
|
|
|
"username:s" => rdp_info[:username],
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create the ".rdp" file
|
2014-05-22 17:20:45 +00:00
|
|
|
config_path = Pathname.new(Dir.tmpdir).join(
|
|
|
|
"vagrant-rdp-#{Time.now.to_i}-#{rand(10000)}.rdp")
|
|
|
|
config_path.open("w+") do |f|
|
|
|
|
opts.each do |k, v|
|
2014-06-03 04:57:14 +00:00
|
|
|
f.puts("#{k}:#{v}")
|
2014-05-22 17:20:45 +00:00
|
|
|
end
|
2014-04-12 22:44:39 +00:00
|
|
|
end
|
|
|
|
|
2014-05-08 01:32:20 +00:00
|
|
|
# Build up the args to mstsc
|
2014-06-03 04:57:14 +00:00
|
|
|
args = [config_path.to_s]
|
2014-05-08 01:32:20 +00:00
|
|
|
if rdp_info[:extra_args]
|
|
|
|
args = rdp_info[:extra_args] + args
|
|
|
|
end
|
|
|
|
|
2014-04-12 22:44:39 +00:00
|
|
|
# Launch it
|
2014-05-21 03:47:32 +00:00
|
|
|
Vagrant::Util::Subprocess.execute("mstsc", *args)
|
2014-04-12 22:44:39 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|