Add passive listening port
This commit is contained in:
@@ -176,6 +176,9 @@ class MininetRunner( object ):
|
|||||||
' controller]' )
|
' controller]' )
|
||||||
opts.add_option( '--innamespace', action='store_true',
|
opts.add_option( '--innamespace', action='store_true',
|
||||||
default=False, help='sw and ctrl in namespace?' )
|
default=False, help='sw and ctrl in namespace?' )
|
||||||
|
opts.add_option( '--listenport', type='int', default=6634,
|
||||||
|
help='[base port for passive switch listening'
|
||||||
|
' controller]' )
|
||||||
opts.add_option( '--pre', type='string', default=None,
|
opts.add_option( '--pre', type='string', default=None,
|
||||||
help='[CLI script to run before tests]' )
|
help='[CLI script to run before tests]' )
|
||||||
opts.add_option( '--post', type='string', default=None,
|
opts.add_option( '--post', type='string', default=None,
|
||||||
@@ -222,10 +225,11 @@ class MininetRunner( object ):
|
|||||||
xterms = self.options.xterms
|
xterms = self.options.xterms
|
||||||
mac = self.options.mac
|
mac = self.options.mac
|
||||||
arp = self.options.arp
|
arp = self.options.arp
|
||||||
|
listenPort = self.options.listenport
|
||||||
mn = Mininet( topo, switch, host, controller, controllerParams,
|
mn = Mininet( topo, switch, host, controller, controllerParams,
|
||||||
inNamespace=inNamespace,
|
inNamespace=inNamespace,
|
||||||
xterms=xterms, autoSetMacs=mac,
|
xterms=xterms, autoSetMacs=mac,
|
||||||
autoStaticArp=arp )
|
autoStaticArp=arp, listenPort=listenPort )
|
||||||
if self.options.pre:
|
if self.options.pre:
|
||||||
CLI( mn, script=self.options.pre )
|
CLI( mn, script=self.options.pre )
|
||||||
|
|
||||||
|
|||||||
+13
-6
@@ -108,7 +108,7 @@ class Mininet( object ):
|
|||||||
cparams=ControllerParams( '10.0.0.0', 8 ),
|
cparams=ControllerParams( '10.0.0.0', 8 ),
|
||||||
build=True, xterms=False, cleanup=False,
|
build=True, xterms=False, cleanup=False,
|
||||||
inNamespace=False,
|
inNamespace=False,
|
||||||
autoSetMacs=False, autoStaticArp=False ):
|
autoSetMacs=False, autoStaticArp=False, listenPort=None ):
|
||||||
"""Create Mininet object.
|
"""Create Mininet object.
|
||||||
topo: Topo (topology) object or None
|
topo: Topo (topology) object or None
|
||||||
switch: Switch class
|
switch: Switch class
|
||||||
@@ -120,7 +120,9 @@ class Mininet( object ):
|
|||||||
cleanup: if build now, cleanup before creating?
|
cleanup: if build now, cleanup before creating?
|
||||||
inNamespace: spawn switches and controller in net namespaces?
|
inNamespace: spawn switches and controller in net namespaces?
|
||||||
autoSetMacs: set MAC addrs from topo?
|
autoSetMacs: set MAC addrs from topo?
|
||||||
autoStaticArp: set all-pairs static MAC addrs?"""
|
autoStaticArp: set all-pairs static MAC addrs?
|
||||||
|
listenPort: base listening port to open; will be incremented for
|
||||||
|
each additional switch in the net if inNamespace=False"""
|
||||||
self.switch = switch
|
self.switch = switch
|
||||||
self.host = host
|
self.host = host
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
@@ -131,6 +133,7 @@ class Mininet( object ):
|
|||||||
self.cleanup = cleanup
|
self.cleanup = cleanup
|
||||||
self.autoSetMacs = autoSetMacs
|
self.autoSetMacs = autoSetMacs
|
||||||
self.autoStaticArp = autoStaticArp
|
self.autoStaticArp = autoStaticArp
|
||||||
|
self.listenPort = listenPort
|
||||||
|
|
||||||
self.hosts = []
|
self.hosts = []
|
||||||
self.switches = []
|
self.switches = []
|
||||||
@@ -162,13 +165,17 @@ class Mininet( object ):
|
|||||||
"""Add switch.
|
"""Add switch.
|
||||||
name: name of switch to add
|
name: name of switch to add
|
||||||
mac: default MAC address for kernel/OVS switch intf 0
|
mac: default MAC address for kernel/OVS switch intf 0
|
||||||
returns: added switch"""
|
returns: added switch
|
||||||
|
side effect: increments the listenPort member variable."""
|
||||||
if self.switch == UserSwitch:
|
if self.switch == UserSwitch:
|
||||||
sw = self.switch( name, defaultMAC=mac, defaultIP=ip,
|
sw = self.switch( name, listenPort=self.listenPort,
|
||||||
inNamespace=self.inNamespace )
|
defaultMAC=mac, defaultIP=ip, inNamespace=self.inNamespace )
|
||||||
else:
|
else:
|
||||||
sw = self.switch( name, defaultMAC=mac, defaultIP=ip, dp=self.dps,
|
sw = self.switch( name, listenPort=self.listenPort,
|
||||||
|
defaultMAC=mac, defaultIP=ip, dp=self.dps,
|
||||||
inNamespace=self.inNamespace )
|
inNamespace=self.inNamespace )
|
||||||
|
if not self.inNamespace:
|
||||||
|
self.listenPort += 1
|
||||||
self.dps += 1
|
self.dps += 1
|
||||||
self.switches.append( sw )
|
self.switches.append( sw )
|
||||||
self.nameToNode[ name ] = sw
|
self.nameToNode[ name ] = sw
|
||||||
|
|||||||
+4
-1
@@ -434,9 +434,12 @@ class Switch( Node ):
|
|||||||
|
|
||||||
portBase = SWITCH_PORT_BASE # 0 for OF < 1.0, 1 for OF >= 1.0
|
portBase = SWITCH_PORT_BASE # 0 for OF < 1.0, 1 for OF >= 1.0
|
||||||
|
|
||||||
def __init__( self, name, opts='', **kwargs):
|
def __init__( self, name, opts='', listenPort=None, **kwargs):
|
||||||
Node.__init__( self, name, **kwargs )
|
Node.__init__( self, name, **kwargs )
|
||||||
self.opts = opts
|
self.opts = opts
|
||||||
|
self.listenPort = listenPort
|
||||||
|
if self.listenPort:
|
||||||
|
self.opts += ' --listen=ptcp:%i ' % self.listenPort
|
||||||
|
|
||||||
def sendCmd( self, *cmd, **kwargs ):
|
def sendCmd( self, *cmd, **kwargs ):
|
||||||
"""Send command to Node.
|
"""Send command to Node.
|
||||||
|
|||||||
Reference in New Issue
Block a user