commands/rdp: no need fo rthe guest cap
This commit is contained in:
parent
617cf630b1
commit
5b960efcb1
|
@ -25,12 +25,7 @@ module VagrantPlugins
|
|||
raise Vagrant::Errors::VMNotCreatedError
|
||||
end
|
||||
|
||||
if !machine.guest.capability?(:rdp_info)
|
||||
raise Errors::GuestUnsupported,
|
||||
name: machine.guest.name.to_s
|
||||
end
|
||||
|
||||
rdp_info = machine.guest.capability(:rdp_info)
|
||||
rdp_info = get_rdp_info(machine)
|
||||
if !rdp_info
|
||||
raise Errors::RDPUndetected
|
||||
end
|
||||
|
@ -38,6 +33,46 @@ module VagrantPlugins
|
|||
@env.host.capability(:rdp_client, rdp_info)
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def get_rdp_info(machine)
|
||||
ssh_info = machine.ssh_info
|
||||
username = ssh_info[:username]
|
||||
if machine.config.vm.communicator == :winrm
|
||||
username = machine.config.winrm.username
|
||||
end
|
||||
|
||||
host = ssh_info[:host]
|
||||
port = 3389
|
||||
|
||||
if host == "127.0.0.1"
|
||||
# We need to find a forwarded port...
|
||||
search_port = 3389
|
||||
ports = nil
|
||||
if machine.provider.capability?(:forwarded_ports)
|
||||
ports = machine.provider.capability(:forwarded_ports)
|
||||
else
|
||||
ports = {}.tap do |result|
|
||||
machine.config.vm.networks.each do |type, netopts|
|
||||
next if type != :forwarded_port
|
||||
next if !netopts[:host]
|
||||
result[netopts[:host]] = netopts[:guest]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ports = ports.invert
|
||||
port = ports[search_port]
|
||||
return nil if !port
|
||||
end
|
||||
|
||||
return {
|
||||
host: host,
|
||||
port: port,
|
||||
username: username,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,10 +6,6 @@ module VagrantPlugins
|
|||
error_namespace("vagrant_rdp.errors")
|
||||
end
|
||||
|
||||
class GuestUnsupported < RDPError
|
||||
error_key(:guest_unsupported)
|
||||
end
|
||||
|
||||
class HostUnsupported < RDPError
|
||||
error_key(:host_unsupported)
|
||||
end
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
module VagrantPlugins
|
||||
module GuestWindows
|
||||
module Cap
|
||||
class RDP
|
||||
def self.rdp_info(machine)
|
||||
ssh_info = machine.ssh_info
|
||||
username = ssh_info[:username]
|
||||
if machine.config.vm.communicator == :winrm
|
||||
username = machine.config.winrm.username
|
||||
end
|
||||
|
||||
host = ssh_info[:host]
|
||||
port = 3389
|
||||
|
||||
if host == "127.0.0.1"
|
||||
# We need to find a forwarded port...
|
||||
search_port = 3389
|
||||
ports = nil
|
||||
if machine.provider.capability?(:forwarded_ports)
|
||||
ports = machine.provider.capability(:forwarded_ports)
|
||||
else
|
||||
ports = {}.tap do |result|
|
||||
machine.config.vm.networks.each do |type, netopts|
|
||||
next if type != :forwarded_port
|
||||
next if !netopts[:host]
|
||||
result[netopts[:host]] = netopts[:guest]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ports = ports.invert
|
||||
port = ports[search_port]
|
||||
return nil if !port
|
||||
end
|
||||
|
||||
return {
|
||||
host: host,
|
||||
port: port,
|
||||
username: username,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -49,11 +49,6 @@ module VagrantPlugins
|
|||
Cap::MountSharedFolder
|
||||
end
|
||||
|
||||
guest_capability(:windows, :rdp_info) do
|
||||
require_relative "cap/rdp"
|
||||
Cap::RDP
|
||||
end
|
||||
|
||||
guest_capability(:windows, :wait_for_reboot) do
|
||||
require_relative "cap/reboot"
|
||||
Cap::Reboot
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
en:
|
||||
vagrant_rdp:
|
||||
errors:
|
||||
guest_unsupported: |-
|
||||
The guest OS detected by Vagrant ('%{name}') is reporting
|
||||
that it does not supported RDP connections. If this is an
|
||||
error, it is because Vagrant does not know how to connect
|
||||
via RDP to this guest.
|
||||
|
||||
Please open an issue documenting how to connect via RDP
|
||||
to this guest OS and we can fix this.
|
||||
|
||||
host_unsupported: |-
|
||||
Vagrant doesn't support running an RDP client on your
|
||||
host OS. Currently only Windows is supported for RDP
|
||||
|
|
Loading…
Reference in New Issue