Class: Bcome::Ssh::ProxyHop
- Inherits:
-
Object
- Object
- Bcome::Ssh::ProxyHop
show all
- Includes:
- Draw
- Defined in:
- lib/objects/ssh/proxy_hop.rb
Constant Summary
Constants included
from Draw
Draw::BLIP, Draw::BOTTOM_ANCHOR, Draw::BOX_BOTTOM_LEFT, Draw::BOX_BOTTOM_RIGHT, Draw::BOX_HORIZONTAL_LINE, Draw::BOX_SIDE, Draw::BOX_TOP_LEFT, Draw::BOX_TOP_RIGHT, Draw::BRANCH, Draw::INGRESS, Draw::LEFT_PADDING, Draw::MID_SHIPS
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Draw
#box_it, #max_box_line_length
Constructor Details
#initialize(config, context_node, parent) ⇒ ProxyHop
Returns a new instance of ProxyHop.
9
10
11
12
13
14
|
# File 'lib/objects/ssh/proxy_hop.rb', line 9
def initialize(config, context_node, parent)
@config = config
@context_node = context_node
@parent = parent
set_host
end
|
Instance Attribute Details
#bcome_proxy_node ⇒ Object
Returns the value of attribute bcome_proxy_node.
7
8
9
|
# File 'lib/objects/ssh/proxy_hop.rb', line 7
def bcome_proxy_node
@bcome_proxy_node
end
|
#config ⇒ Object
Returns the value of attribute config.
7
8
9
|
# File 'lib/objects/ssh/proxy_hop.rb', line 7
def config
@config
end
|
#host ⇒ Object
Returns the value of attribute host.
7
8
9
|
# File 'lib/objects/ssh/proxy_hop.rb', line 7
def host
@host
end
|
#parent ⇒ Object
Returns the value of attribute parent.
7
8
9
|
# File 'lib/objects/ssh/proxy_hop.rb', line 7
def parent
@parent
end
|
Instance Method Details
#==(other) ⇒ Object
42
43
44
|
# File 'lib/objects/ssh/proxy_hop.rb', line 42
def ==(other)
config == other.config
end
|
#eql?(other) ⇒ Boolean
46
47
48
|
# File 'lib/objects/ssh/proxy_hop.rb', line 46
def eql?(other)
config == other.config
end
|
#get_local_port_forward_string ⇒ Object
64
65
66
67
68
69
70
71
|
# File 'lib/objects/ssh/proxy_hop.rb', line 64
def get_local_port_forward_string
con_str = ''
con_str += parent.get_local_port_forward_string.to_s if has_parent?
con_str += "#{user}@#{host}\s"
con_str
end
|
#get_rsync_string ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'lib/objects/ssh/proxy_hop.rb', line 55
def get_rsync_string
con_str = ''
con_str += "#{parent.get_rsync_string}\s" if has_parent?
con_str += "'ssh -o \"ProxyCommand ssh -A #{user}@#{host} -W %h:%p\"'"
con_str
end
|
#get_ssh_string(_is_first_hop = false) ⇒ Object
50
51
52
53
|
# File 'lib/objects/ssh/proxy_hop.rb', line 50
def get_ssh_string(_is_first_hop = false)
con_str = "#{user}@#{host}"
con_str
end
|
#has_parent? ⇒ Boolean
38
39
40
|
# File 'lib/objects/ssh/proxy_hop.rb', line 38
def has_parent?
!parent.nil?
end
|
#pretty_proxy_details(n = 1) ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/objects/ssh/proxy_hop.rb', line 23
def pretty_proxy_details(n = 1)
lines = ["proxy\s".bc_cyan + "[#{n}]"]
lines << "bcome node\s".bc_yellow + @bcome_proxy_node.keyed_namespace if @bcome_proxy_node
lines << "host\s".bc_yellow + host
lines << "user\s".bc_yellow + user
lines
end
|
#proxy_details ⇒ Object
16
17
18
19
20
21
|
# File 'lib/objects/ssh/proxy_hop.rb', line 16
def proxy_details
@config.merge(
proxy_host: host,
user: user
).except!(:bastion_host_user, :fallback_bastion_host_user)
end
|
#user ⇒ Object
34
35
36
|
# File 'lib/objects/ssh/proxy_hop.rb', line 34
def user
@user ||= get_user
end
|