Class: SSHRegistry
Constant Summary
Constants inherited from Registry
Instance Attribute Summary
Attributes inherited from Registry
Instance Method Summary collapse
- #failed_connections ⇒ Object
-
#initialize ⇒ SSHRegistry
constructor
A new instance of SSHRegistry.
- #run_on_all(cmd) ⇒ Object
Methods inherited from Registry
#diag, #find_host, #list_images, #list_vms, #sysinfo
Constructor Details
#initialize ⇒ SSHRegistry
Returns a new instance of SSHRegistry.
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# 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 |
Instance Method Details
#failed_connections ⇒ Object
359 360 361 |
# File 'lib/smartos-manager/core.rb', line 359 def failed_connections @failed_connections.map{|address| @hosts[address] } end |
#run_on_all(cmd) ⇒ Object
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# 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 |