basic roouter loop

This commit is contained in:
Torsten 2022-03-25 21:31:52 +02:00
parent a4e63b3d0c
commit 18cc06b9c1
2 changed files with 53 additions and 1 deletions

View File

@ -1 +1 @@
GaFVeuqp8OlAHTGhYbpuL3rjk2xbUYwxXtGsD+q2ebLlV1KU7/9et6ezxvS94pURH3NWfhJWY/M22oviWLl2o4pkpMSnHi7kIoDPjpeUG6ZQPgmwZgZtS+6o1/xiS5VtBq/auqEGucf8uxIa1+ZyUQGCF1V3cWNM9m+tNKo071jtN4JgsQ1NPfAUi7UfeIjy4/Tw1JbAwP2982AfioZqElDaqZdPiLHRvn0sKvAW8mjjFMUZQFWPcFOqDoZUQ381FJfhyhE0T2jJXb9ASzY8pNoH13GqEQhprbxGcFv4Sl0k+vobwy0yj/qdDbVTUpIJqsaJuY+yrdh7y4+Eyg873pbH8kHg37/kKckqPaCP2RIH06TBxtzPIwFEgHZcuZzY4KG8w64q7DDKr+XKRsjP7mjq9E8cYY3pQ4JB--0J9loPWEJu9xUa6C--K+TdTBkhMSUKxOkP9Zo4Xw==
0m6IXDJDw8m1+jPTJ9S93WUkdsx4fO7FUa1SRuPdjrBZbweh9s4SJbVKfjJjlvSf4iqgtcFbcLCpHipGDFqRWwgainwYSgEQD0HpWuWpY4uLmJNi7xlOtukBSy3UHLdBagXMQX8bXnO8PrvepoEGKPbPOofvaeGw5C/l/zwaFpGow3eBxygMhdwbc9Ec5zgkvM/tse2zuzFjA5du6tg1D9M+co0yOBkee3lO88YStYgW54U15ClsT9d60ANDsR/nSuAGYUIGEdzYAxgnz26yP2y+HL0FW0ekv0070bawSWLxuPB9RWYv1VfVnX1JBYuUyOSd12sA6keQvm+yfsAqZe7GbkNIW1XUWol+crv4BJ9095bMafuP8p6zIPM++BOJ0yMBZYDAbq93Cd7+CvntuhcNddGqyMqHCTT/GaDTFrGx9z6uD//7WA==--gukSn6+4adNrpZau--ju1BA3I3U2uzjAFHR9XUSA==

52
lib/routers.rb Normal file
View File

@ -0,0 +1,52 @@
require_relative "../config/application"
require "net/ssh"
class Routers
@@start_address = "10.20.20."
@@start_at = 30
@@stop_at = 80
def initialize
@at = @@start_at
end
def at
@@start_address + @at.to_s
end
def for_each command_string
# find
# connect
# run command
end
def all_ips
connections = {}
while(@at < @@stop_at)
error = nil
begin
connection = Net::SSH.start(at , "root" ,
password: Rails.application.credentials.sala,
non_interactive: true ,
timeout: 4)
puts "Ok #{at}"
connections[at] = connection
rescue Net::SSH::ConnectionTimeout
error = " Timed out ssh"
rescue Errno::ETIMEDOUT
error = " Timed out erro"
rescue Errno::EHOSTUNREACH
error = " Host unreachable"
rescue Errno::ECONNREFUSED
error = " Connection refused"
rescue Net::SSH::AuthenticationFailed
error = " Authentication failure"
end
puts "not at #{at} #{error}" if error
@at += 1
end
end
end
Routers.new.all_ips