Revision 18aab5b7 examples/numberedports.py

View differences:

examples/numberedports.py
20 20
    else:
21 21
        return 1
22 22

  
23
def net():
23
def testPortNumbering():
24 24

  
25
    "Create a network with 5 hosts."
25
    """Test port numbering:
26
       Create a network with 5 hosts (using Mininet's
27
       mid-level API) and check that implicit and
28
       explicit port numbering works as expected."""
26 29

  
27 30
    net = Mininet( controller=Controller )
28 31

  
......
45 48
    net.addLink( h2, s1 )
46 49
    net.addLink( h3, s1 )
47 50
    net.addLink( h4, s1 )
48
    net.addLink( h5, s1, port1 = 1, port2 = 9 ) # specify a different port to connect host 5 to on the switch.
51
    # specify a different port to connect host 5 to on the switch.
52
    net.addLink( h5, s1, port1=1, port2= 9)
49 53

  
50 54
    info( '*** Starting network\n' )
51 55
    net.start()
52 56

  
53 57
    # print the interfaces and their port numbers
54
    info( '\n*** printing and validating the ports running on each interface\n' )
58
    info( '\n*** printing and validating the ports '
59
          'running on each interface\n' )
55 60
    for intfs in s1.intfList():
56 61
        if not intfs.name == "lo":
57 62
            info( intfs, ': ', s1.ports[intfs],
58 63
            '\n' )
59
            info ( 'Validating that', intfs, 'is actually on port', s1.ports[intfs], '... ' )
64
            info ( 'Validating that', intfs,
65
                   'is actually on port', s1.ports[intfs], '... ' )
60 66
            if validatePort( s1, intfs ):
61 67
                info( 'Validated.\n' )
62 68
    print '\n'
......
70 76

  
71 77
if __name__ == '__main__':
72 78
    setLogLevel( 'info' )
73
    net()
74

  
79
    testPortNumbering()

Also available in: Unified diff