'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)
    (IP1, IP2) = (node1.serverIP, node2.serverIP)
    if (node1.server == 'localhost'):
        output = quietRun(('ip    route    get    %s' % node2.serverIP))
        IP1 = output.split('    src    ')[1].split()[0]
    debug(((((((('\n***    Make    GRE    tunnel    ' + node1.server) + ':') + intfname1) + '    ==    ') + node2.server) + ':') + intfname2))
    tun1 = ((('local    ' + IP1) + '    remote    ') + IP2)
    tun2 = ((('local    ' + IP2) + '    remote    ') + IP1)
    self.__class__.GRE_KEY += 1
    for (node, intfname, addr, tun) in [(node1, intfname1, addr1, tun1), (node2, intfname2, addr2, tun2)]:
        node.rcmd(('ip    link    delete    ' + intfname))
        result = node.rcmd(((((('ip    link    add    name    ' + intfname) + '    type    gretap    ') + tun) + '    ttl    64    key    ') + str(self.__class__.GRE_KEY)))
        if result:
            raise Exception(('error    creating    gretap    on    %s:    %s' % (node, result)))
        if addr:
            node.rcmd(('ip    link    set    %s    address    %s' % (intfname, addr)))
        node.rcmd(('ip    link    set    dev    %s    up' % intfname))
        node.rcmd(('ip    link    set    dev    %s    mtu    1450' % intfname))
        if (not self.moveIntf(intfname, node)):
            raise Exception(('interface    move    failed    on    node    %s' % node))
