Module: Egon::Undercloud::PortCheckMixin
- Included in:
- Installer, SSHConnection
- Defined in:
- lib/egon/undercloud/port-check-mixin.rb
Instance Method Summary collapse
Instance Method Details
#port_open?(ip, port, stringio = nil) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/egon/undercloud/port-check-mixin.rb', line 12 def port_open?(ip, port, stringio=nil) begin url = "http://#{ip}:#{port}" stringio_write(stringio, "Testing #{url}") res = Net::HTTP.get_response(URI(url)) stringio_write(stringio, res.body) stringio_write(stringio, "Port #{port} is open") true rescue => e stringio_write(stringio, e.) stringio_write(stringio, e.backtrace) stringio_write(stringio, "Port #{port} is closed") false end end |
#stringio_write(stringio, text) ⇒ Object
7 8 9 10 |
# File 'lib/egon/undercloud/port-check-mixin.rb', line 7 def stringio_write(stringio, text) $stdout.puts text if stringio.nil? stringio.puts text unless stringio.nil? end |