Class: VagrantPlugins::VagrantHyperV::Action::Rdp
- Inherits:
-
Object
- Object
- VagrantPlugins::VagrantHyperV::Action::Rdp
- Defined in:
- lib/vagrant-windows-hyperv/action/rdp.rb
Overview
This action generates a .rdp file into the root path of the project. and establishes a RDP session with necessary resource sharing
Instance Method Summary collapse
- #call(env) ⇒ Object
- #generate_rdp_file ⇒ Object
-
#initialize(app, env) ⇒ Rdp
constructor
A new instance of Rdp.
Constructor Details
#initialize(app, env) ⇒ Rdp
Returns a new instance of Rdp.
16 17 18 19 |
# File 'lib/vagrant-windows-hyperv/action/rdp.rb', line 16 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant::hyperv::rdp") end |
Instance Method Details
#call(env) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vagrant-windows-hyperv/action/rdp.rb', line 21 def call(env) if env[:machine].config.vm.guest != :windows raise Errors::RDPNotAvailable, guest: env[:machine].config.vm.guest end @env = env @env[:ui].detail I18n.t("vagrant_win_hyperv.generating_rdp") generate_rdp_file command = ["mstsc", "machine.rdp"] Vagrant::Util::PowerShell.execute(*command) end |
#generate_rdp_file ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vagrant-windows-hyperv/action/rdp.rb', line 33 def generate_rdp_file ssh_info = @env[:machine].ssh_info = { "username:s" => ssh_info[:username], "prompt for credentials:i" => "1", "full address:s" => ssh_info[:host] } file = File.open("machine.rdp", "w") .each do |key, value| file.puts "#{key}:#{value}" end file.close end |