'Make a tunnel across switches on different servers'

def makeTunnel(self, node1, node2, intfname1, intfname2, addr1=None, addr2=None):

    assert (node1.server != node2.server)
    if (node2.server == 'localhost'):
        return self.makeTunnel(node2, node1, intfname2, intfname1, addr2, addr1)
    debug(((((((('\n***    Make    SSH    tunnel    ' + node1.server) + ':') + intfname1) + '    ==    ') + node2.server) + ':') + intfname2))
    for node in (node1, node2):
        cmd = ('ip    tuntap    add    dev    tap9    mode    tap    user    ' + node.user)
        result = node.rcmd(cmd)
        if result:
            raise Exception(('error    creating    tap9    on    %s:    %s' % (node, result)))
    dest = ('%s@%s' % (node2.user, node2.serverIP))
    cmd = ['ssh', '-n', '-o', 'Tunnel=Ethernet', '-w', '9:9', dest, 'echo    @']
    self.cmd = cmd
    tunnel = node1.rpopen(cmd, sudo=False)
    debug('Waiting    for    tunnel    to    come    up...\n')
    ch = tunnel.stdout.read(1)
    if (ch != '@'):
        raise Exception('makeTunnel:\n', 'Tunnel    setup    failed    for', ('%s:%s' % (node1, node1.dest)), 'to', ('%s:%s\n' % (node2, node2.dest)), 'command    was:', cmd, '\n')
    for node in (node1, node2):
        if (not self.moveIntf('tap9', node)):
            raise Exception(('interface    move    failed    on    node    %s' % node))
    for (node, intf, addr) in ((node1, intfname1, addr1), (node2, intfname2, addr2)):
        if (not addr):
            result = node.cmd('ip    link    set    tap9    name', intf)
        else:
            result = node.cmd('ip    link    set    tap9    name', intf, 'address', addr)
        if result:
            raise Exception(('error    renaming    %s:    %s' % (intf, result)))
    return tunnel
