hosts/darwin: rdp client support by subprocessing `open`

This commit is contained in:
Mitchell Hashimoto 2014-04-20 20:39:42 -07:00
parent ce08a37d5f
commit b0b445fcac
4 changed files with 66 additions and 2 deletions

View File

@ -2,10 +2,10 @@ require "vagrant"
module VagrantPlugins module VagrantPlugins
module HostBSD module HostBSD
# Represents a BSD host, such as FreeBSD and Darwin (Mac OS X). # Represents a BSD host, such as FreeBSD.
class Host < Vagrant.plugin("2", :host) class Host < Vagrant.plugin("2", :host)
def detect?(env) def detect?(env)
Vagrant::Util::Platform.darwin? || Vagrant::Util::Platform.bsd? Vagrant::Util::Platform.darwin?
end end
end end
end end

View File

@ -0,0 +1,33 @@
require "tempfile"
require "vagrant/util/subprocess"
module VagrantPlugins
module HostDarwin
module Cap
class RDP
def self.rdp_client(env, rdp_info)
config = nil
opts = {
"drivestoredirect:s" => "*",
"full address:s" => "#{rdp_info[:host]}:#{rdp_info[:port]}",
"prompt for credentials:i" => "1",
"username:s" => rdp_info[:username],
}
# Create the ".rdp" file
config = Tempfile.new(["vagrant-rdp", ".rdp"])
opts.each do |k, v|
config.puts("#{k}:#{v}")
end
config.close
# Launch it
Vagrant::Util::Subprocess.execute("open", config.path)
ensure
config.close if config
end
end
end
end
end

View File

@ -0,0 +1,11 @@
require "vagrant/util/platform"
module VagrantPlugins
module HostDarwin
class Host < Vagrant.plugin("2", :host)
def detect?(env)
Vagrant::Util::Platform.darwin?
end
end
end
end

View File

@ -0,0 +1,20 @@
require "vagrant"
module VagrantPlugins
module HostDarwin
class Plugin < Vagrant.plugin("2")
name "Mac OS X host"
description "Mac OS X host support."
host("darwin", "bsd") do
require_relative "host"
Host
end
host_capability("darwin", "rdp_client") do
require_relative "cap/rdp"
Cap::RDP
end
end
end
end