From 0fa07637f9920bf029fbb8ec1828d7ce9a18c4ed Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 12 Apr 2014 15:51:07 -0700 Subject: [PATCH] commands/rdp: execute propre capabilities --- plugins/commands/rdp/command.rb | 12 ++++++++++++ plugins/commands/rdp/errors.rb | 4 ++++ templates/locales/command_rdp.yml | 9 +++++++++ templates/locales/en.yml | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/plugins/commands/rdp/command.rb b/plugins/commands/rdp/command.rb index 4fd252f6f..c06872134 100644 --- a/plugins/commands/rdp/command.rb +++ b/plugins/commands/rdp/command.rb @@ -21,6 +21,18 @@ module VagrantPlugins # Execute RDP if we can with_target_vms(argv, single_target: true) do |machine| + if !machine.communicate.ready? + raise Vagrant::Errors::VMNotCreatedError + end + + if !machine.guest.capability?(:rdp_info) + raise Errors::GuestUnsupported, + name: machine.guest.name.to_s + end + + @env.host.capability( + :rdp_client, + machine.guest.capability(:rdp_info)) end end end diff --git a/plugins/commands/rdp/errors.rb b/plugins/commands/rdp/errors.rb index 0e58b4808..5bc4fea33 100644 --- a/plugins/commands/rdp/errors.rb +++ b/plugins/commands/rdp/errors.rb @@ -6,6 +6,10 @@ module VagrantPlugins error_namespace("vagrant_rdp.errors") end + class GuestUnsupported < RDPError + error_key(:guest_unsupported) + end + class HostUnsupported < RDPError error_key(:host_unsupported) end diff --git a/templates/locales/command_rdp.yml b/templates/locales/command_rdp.yml index da597f485..aeabd699e 100644 --- a/templates/locales/command_rdp.yml +++ b/templates/locales/command_rdp.yml @@ -1,6 +1,15 @@ 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 diff --git a/templates/locales/en.yml b/templates/locales/en.yml index c46ab73dc..07ba05167 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -950,7 +950,7 @@ en: taking too long to reboot. First, try reloading your machine with `vagrant reload`, since a simple restart sometimes fixes things. If that doesn't work, destroy your machine and recreate it with - a `vagrant destroy` followed by a `1vagrant up`. If that doesn't work, + a `vagrant destroy` followed by a `vagrant up`. If that doesn't work, contact support. ssh_connection_timeout: |- Vagrant timed out while attempting to connect via SSH. This usually