Class: VagrantPlugins::Cloudstack::Action::ReadRdpInfo

Inherits:
ReadTransportInfo show all
Defined in:
lib/vagrant-cloudstack/action/read_rdp_info.rb

Overview

This action reads the WinRM info for the machine and puts it into the ‘:machine_winrm_info` key in the environment.

Instance Method Summary collapse

Methods inherited from ReadTransportInfo

#find_server, #retrieve_public_ip_port

Constructor Details

#initialize(app, env) ⇒ ReadRdpInfo

Returns a new instance of ReadRdpInfo.



10
11
12
13
14
15
# File 'lib/vagrant-cloudstack/action/read_rdp_info.rb', line 10

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new("vagrant_cloudstack::action::read_rdp_info")

  @public_port_fieldname = 'pf_public_rdp_port'
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
# File 'lib/vagrant-cloudstack/action/read_rdp_info.rb', line 17

def call(env)
  env[:machine_rdp_info] = read_rdp_info(env[:cloudstack_compute], env[:machine])

  @app.call(env)
end

#read_rdp_info(cloudstack, machine) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/vagrant-cloudstack/action/read_rdp_info.rb', line 23

def read_rdp_info(cloudstack, machine)
  return nil if (server = find_server(cloudstack, machine)).nil?

  # Get the Port forwarding config
  domain        = machine.provider_config.domain_id
  domain_config = machine.provider_config.get_domain_config(domain)

  pf_ip_address, pf_public_port = retrieve_public_ip_port(cloudstack, domain_config, machine)

  transport_info = {
               :host => pf_ip_address || server.nics[0]['ipaddress'],
               :port => pf_public_port
             }

  transport_info
end