Revision 197b083f mininet/net.py

View differences:

mininet/net.py
96 96
from mininet.log import info, error, debug, output
97 97
from mininet.node import Host, OVSKernelSwitch, Controller
98 98
from mininet.link import Link, Intf
99
from mininet.util import quietRun, fixLimits
99
from mininet.util import quietRun, fixLimits, numCores
100 100
from mininet.util import macColonHex, ipStr, ipParse, netParse, ipAdd
101 101
from mininet.term import cleanUpScreens, makeTerms
102 102

  
......
107 107
                 controller=Controller, link=Link, intf=Intf,
108 108
                 build=True, xterms=False, cleanup=False, ipBase='10.0.0.0/8',
109 109
                 inNamespace=False,
110
                 autoSetMacs=False, autoStaticArp=False, listenPort=None ):
110
                 autoSetMacs=False, autoStaticArp=False, autoPinCpus=False,
111
                 listenPort=None ):
111 112
        """Create Mininet object.
112 113
           topo: Topo (topology) object or None
113 114
           switch: default Switch class
......
120 121
           xterms: if build now, spawn xterms?
121 122
           cleanup: if build now, cleanup before creating?
122 123
           inNamespace: spawn switches and controller in net namespaces?
123
           autoSetMacs: set MAC addrs from topo dpid?
124
           autoSetMacs: set MAC addrs automatically like IP addresses?
124 125
           autoStaticArp: set all-pairs static MAC addrs?
126
           autoPinCpus: pin hosts to (real) cores (requires CPULimitedHost)?
125 127
           listenPort: base listening port to open; will be incremented for
126 128
               each additional switch in the net if inNamespace=False"""
127 129
        self.topo = topo
......
138 140
        self.cleanup = cleanup
139 141
        self.autoSetMacs = autoSetMacs
140 142
        self.autoStaticArp = autoStaticArp
143
        self.autoPinCpus = autoPinCpus
144
        self.numCores = numCores()
145
        self.nextCore = 0  # next core for pinning hosts to CPUs
141 146
        self.listenPort = listenPort
142 147

  
143 148
        self.hosts = []
......
166 171
                                  prefixLen=self.prefixLen ) }
167 172
        if self.autoSetMacs:
168 173
            defaults[ 'mac'] = macColonHex( self.nextIP )
174
        if self.autoPinCpus:
175
            defaults[ 'cores' ] = self.nextCore
176
            self.nextCore = ( self.nextCore + 1 ) % self.numCores
169 177
        self.nextIP += 1
170 178
        defaults.update( params )
171 179
        if not cls:
......
230 238
        "Configure a set of hosts."
231 239
        for host in self.hosts:
232 240
            info( host.name + ' ' )
233
            host.configDefault( defaultRoute=host.defaultIntf )
241
            host.configDefault( defaultRoute=host.defaultIntf() )
234 242
            # You're low priority, dude!
235 243
            # BL: do we want to do this here or not?
236 244
            # May not make sense if we have CPU lmiting...

Also available in: Unified diff