class SSHRegistry
Public Class Methods
new(*)
click to toggle source
Calls superclass method
Registry::new
# File lib/smartos-manager/core.rb, line 310 def initialize(*) puts "(( Using live data ))" super @failed_connections = [] @gateways = {} @connection = Net::SSH::Multi.start(:on_error => ->(server){ @failed_connections << server.host }) @hosts.each do |_, host| @connection.use(host.address, via: gateway_for(host.gateway, host.gateway_user), user: host.user, timeout: 20, auth_methods: %w(publickey), compression: false ) end end
Public Instance Methods
failed_connections()
click to toggle source
# File lib/smartos-manager/core.rb, line 359 def failed_connections @failed_connections.map{|address| @hosts[address] } end
run_on_all(cmd)
click to toggle source
# File lib/smartos-manager/core.rb, line 332 def run_on_all(cmd) ret = {} # set the keys in cas we get nothing back @hosts.each do |addr, _| ret[addr] = "" end channel = @connection.exec(cmd) do |ch, stream, data| host = @hosts[ch[:host]] ret[host.address] << data end channel.wait() # remove empty results @hosts.each do |addr, _| if ret[addr] == "" ret.delete(addr) end end cache_result(cmd, ret) ret end
Private Instance Methods
gateway_for(host, user)
click to toggle source
# File lib/smartos-manager/core.rb, line 364 def gateway_for(host, user) @gateways[host] ||= Net::SSH::Gateway.new( host, user, compression: false ) end