Class: Net::SSH::Xlogin::Connection

Inherits:
Telnet
  • Object
show all
Defined in:
lib/net/ssh/xlogin/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template, name, **opts) ⇒ Connection



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/net/ssh/xlogin/connection.rb', line 11

def initialize(template, name, **opts)
  @name     = name
  @options  = opts

  log       = @options[:log] || @options[:output_log]
  max_retry = @options[:max_retry] || 1

  @options[:timeout]   ||= template.timeout
  @options[:host_name] ||= name

  begin
    args = Hash.new
    args["Output_log"]  = log if log
    args["Dump_log"]    = @options[:dump_log]   if @options[:dump_log]
    args["Prompt"]      = @options[:prompt]     || template.prompt_patten
    args["Timeout"]     = @options[:timeout]    || 10
    args["Waittime"]    = @options[:waittime]   || 0
    args["Terminator"]  = @options[:terminator] || LF
    args["Binmode"]     = @options[:binmode]    || false
    args["PTYOptions"]  = @options[:ptyoptions] || {}

    if @options[:relay]
      relay             = @options[:relay]
      info              = Factory.instance.inventory[relay]
      @options[:port]   = Net::SSH::Gateway.new(relay, nil , info)
    end

    if @options[:proxy]
      args["Host"]      = @options[:host_name]
      args["Port"]      = @options[:port]
      args["Username"]  = @options[:user]
      args["Password"]  = @options[:password]
      args["Proxy"]     = @options[:proxy]
    else
      ssh_options       = @options.slice(*Net::SSH::VALID_OPTIONS)
      ssh_options       = @options[:host] unless @options[:host_name]
      args['Session']   = Net::SSH.start(name, nil, ssh_options)
    end

    super(args)
  rescue => e
    retry if (max_retry -= 1) > 0
    raise e
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/net/ssh/xlogin/connection.rb', line 9

def name
  @name
end