commands/rdp: rdp_info cap if avail [GH-3832]

This commit is contained in:
Mitchell Hashimoto 2014-05-20 20:17:21 -07:00
parent d7fa60b5df
commit 4dbe534c02
2 changed files with 19 additions and 13 deletions

View File

@ -48,7 +48,7 @@ BUG FIXES:
PLUGIN AUTHOR CHANGES: PLUGIN AUTHOR CHANGES:
- Providers can now implement the `winrm_info` provider capability - Providers can now implement the `rdp_info` provider capability
to get proper info for `vagrant rdp` to function. to get proper info for `vagrant rdp` to function.
## 1.6.2 (May 12, 2014) ## 1.6.2 (May 12, 2014)

View File

@ -54,16 +54,25 @@ module VagrantPlugins
protected protected
def get_rdp_info(machine) def get_rdp_info(machine)
rdp_info = {}
if machine.provider.capability?(:rdp_info)
rdp_info = machine.provider.capability(:rdp_info)
end
ssh_info = machine.ssh_info ssh_info = machine.ssh_info
if !rdp_info[:username]
username = ssh_info[:username] username = ssh_info[:username]
if machine.config.vm.communicator == :winrm if machine.config.vm.communicator == :winrm
username = machine.config.winrm.username username = machine.config.winrm.username
end end
rdp_info[:username] = username
end
host = ssh_info[:host] rdp_info[:host] ||= ssh_info[:host]
port = machine.config.rdp.port rdp_info[:port] ||= machine.config.rdp.port
if host == "127.0.0.1" if rdp_info[:host] == "127.0.0.1"
# We need to find a forwarded port... # We need to find a forwarded port...
search_port = machine.config.rdp.search_port search_port = machine.config.rdp.search_port
ports = nil ports = nil
@ -81,14 +90,11 @@ module VagrantPlugins
ports = ports.invert ports = ports.invert
port = ports[search_port] port = ports[search_port]
rdp_info[:port] = port
return nil if !port return nil if !port
end end
return { return rdp_info
host: host,
port: port,
username: username,
}
end end
end end
end end