From 5b5f10e175583c29314f6ca94f7dccafedd9c0c8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 12 Apr 2014 16:37:44 -0700 Subject: [PATCH] commands/rdp: config --- plugins/commands/rdp/command.rb | 4 ++-- plugins/commands/rdp/config.rb | 23 +++++++++++++++++++++++ plugins/commands/rdp/plugin.rb | 5 +++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 plugins/commands/rdp/config.rb diff --git a/plugins/commands/rdp/command.rb b/plugins/commands/rdp/command.rb index 0ee15cc33..766514bcb 100644 --- a/plugins/commands/rdp/command.rb +++ b/plugins/commands/rdp/command.rb @@ -48,11 +48,11 @@ module VagrantPlugins end host = ssh_info[:host] - port = 3389 + port = machine.config.rdp.port if host == "127.0.0.1" # We need to find a forwarded port... - search_port = 3389 + search_port = machine.config.rdp.search_port ports = nil if machine.provider.capability?(:forwarded_ports) ports = machine.provider.capability(:forwarded_ports) diff --git a/plugins/commands/rdp/config.rb b/plugins/commands/rdp/config.rb new file mode 100644 index 000000000..1384c6713 --- /dev/null +++ b/plugins/commands/rdp/config.rb @@ -0,0 +1,23 @@ +module VagrantPlugins + module CommandRDP + class Config < Vagrant.plugin("2", :config) + attr_accessor :port + attr_accessor :search_port + + def initialize + @port = UNSET_VALUE + @search_port = UNSET_VALUE + end + + def finalize! + @port = 3389 if @port == UNSET_VALUE + @search_port = 3389 if @search_port == UNSET_VALUE + end + + def validate(machine) + errors = _detected_errors + { "RDP" => errors } + end + end + end +end diff --git a/plugins/commands/rdp/plugin.rb b/plugins/commands/rdp/plugin.rb index 5cc00be78..83e1a023f 100644 --- a/plugins/commands/rdp/plugin.rb +++ b/plugins/commands/rdp/plugin.rb @@ -17,6 +17,11 @@ module VagrantPlugins Command end + config("rdp") do + require_relative "config" + Config + end + protected def self.init!