Revision efc9a01c mininet/util.py

View differences:

mininet/util.py
15 15
def checkRun( cmd ):
16 16
    """Simple interface to subprocess.check_call()
17 17
       cmd: list of command params"""
18
    check_call( cmd.split( ' ' ) )
18
    return check_call( cmd.split( ' ' ) )
19 19

  
20 20
def quietRun( cmd ):
21 21
    """Run a command, routing stderr to stdout, and return the output.
......
63 63
    quietRun( 'ip link del ' + intf2 )
64 64
    # Create new pair
65 65
    cmd = 'ip link add name ' + intf1 + ' type veth peer name ' + intf2
66
    return checkRun( cmd )
66
    return quietRun( cmd )
67 67

  
68 68
def retry( retries, delaySecs, fn, *args, **keywords ):
69 69
    """Try something several times before giving up.
......
101 101
       printError: if true, print error"""
102 102
    retry( retries, delaySecs, moveIntfNoRetry, intf, node, printError )
103 103

  
104
def createLink( node1, node2, retries=10, delaySecs=0.001 ):
104
def createLink( node1, port1, node2, port2 ):
105 105
    """Create a link between nodes, making an interface for each.
106 106
       node1: Node object
107
       node2: Node object"""
108
    intf1 = node1.newIntf()
109
    intf2 = node2.newIntf()
107
       port1: node1 port number
108
       node2: Node object
109
       port2: node2 port number
110
       returns: intf1 name, intf2 name"""
111
    intf1 = node1.intfName( port1 )
112
    intf2 = node2.intfName( port2 )
110 113
    makeIntfPair( intf1, intf2 )
111
    if node1.inNamespace:
112
        retry( retries, delaySecs, moveIntf, intf1, node1 )
113
    if node2.inNamespace:
114
        retry( retries, delaySecs, moveIntf, intf2, node2 )
115
    node1.connection[ intf1 ] = ( node2, intf2 )
116
    node2.connection[ intf2 ] = ( node1, intf1 )
114
    node1.addIntf( intf1, port1 )
115
    node2.addIntf( intf2, port2 )
116
    node1.connect( intf1, node2, intf2 )
117
    node2.connect( intf2, node1, intf1 )
117 118
    return intf1, intf2
118 119

  
119 120
def fixLimits():
......
141 142

  
142 143
def ipStr( ip ):
143 144
    """Generate IP address string
144
       returns: ip addr string"""
145
       ip: unsigned int of form x << 16 | y << 8 | z
146
       returns: ip address string 10.x.y.z """
145 147
    hi = ( ip & 0xff0000 ) >> 16
146 148
    mid = ( ip & 0xff00 ) >> 8
147 149
    lo = ip & 0xff

Also available in: Unified diff