class Kitchen::Provisioner::Finder::Ssh
SSH implementation for returning active non-localhost IPs
Constants
- IP4REGEX
Public Class Methods
new(connection)
click to toggle source
# File lib/kitchen/provisioner/finder/ssh.rb, line 58 def initialize(connection) @connection = connection end
Public Instance Methods
find_fqdn()
click to toggle source
# File lib/kitchen/provisioner/finder/ssh.rb, line 76 def find_fqdn @connection.node_execute('hostname -f').chomp.chomp end
find_ips()
click to toggle source
# File lib/kitchen/provisioner/finder/ssh.rb, line 62 def find_ips ips = [] 5.times do begin ips = run_ifconfig rescue Kitchen::Transport::TransportFailed ips = run_ip_addr end return ips unless ips.empty? sleep 0.5 end ips end
Private Instance Methods
run_ifconfig()
click to toggle source
# File lib/kitchen/provisioner/finder/ssh.rb, line 82 def run_ifconfig response = @connection.node_execute('/sbin/ifconfig -a') ips = [] response.split(/^\S+/).each do |device| next if !device.include?('RUNNING') || device.include?('LOOPBACK') next if IP4REGEX.match(device).nil? ips << IP4REGEX.match(device)[1] end ips.compact end
run_ip_addr()
click to toggle source
# File lib/kitchen/provisioner/finder/ssh.rb, line 93 def run_ip_addr response = @connection.node_execute('/sbin/ip -4 addr show') ips = [] response.split(/^[0-9]+: /).each do |device| next if device.include?('LOOPBACK') || device.include?('NO-CARRIER') next if device == '' found_ips = IP4REGEX.match(device) ips << IP4REGEX.match(device)[1] unless found_ips.nil? end ips.compact end