Method: Unix::Exec#get_ip

Defined in:
lib/beaker/host/unix/exec.rb

#get_ipObject



137
138
139
140
141
142
143
144
145
# File 'lib/beaker/host/unix/exec.rb', line 137

def get_ip
  if self['platform'].include?('solaris') || self['platform'].include?('osx')
    execute("ifconfig -a inet| awk '/broadcast/ {print $2}' | cut -d/ -f1 | head -1").strip
  else

    pipe_cmd = "#{self['hypervisor']}".include?('vagrant') ? 'tail' : 'head'
    execute("ip a | awk '/global/{print$2}' | cut -d/ -f1 | #{pipe_cmd} -1").strip
  end
end