'Connect to the remote machine and determine the values to use for the
required netconsole parameters.'

def __determine_netconsole_params(self):

    remote_ip = socket.gethostbyname(self.hostname)
    local_ip = socket.gethostbyname(socket.gethostname())
    try:
        traceroute = self.run(('traceroute    -n    %s' % local_ip))
    except error.AutoservRunError:
        return
    first_node = traceroute.stdout.split('\n')[0]
    match = re.search('\\s+((\\d+\\.){3}\\d+)\\s+', first_node)
    if match:
        router_ip = match.group(1)
    else:
        return
    try:
        self.run(('ping    -c    1    %s' % router_ip))
        arp = self.run(('arp    -n    -a    %s' % router_ip))
    except error.AutoservRunError:
        return
    match = re.search('\\s+(([0-9A-F]{2}:){5}[0-9A-F]{2})\\s+', arp.stdout)
    if match:
        gateway_mac = match.group(1)
    else:
        return None
    return ('netconsole=@%s/,%s@%s/%s' % (remote_ip, self.__port, local_ip, gateway_mac))
