Skip to content
Snippets Groups Projects
Commit 05dbf82e authored by Bob Lantz's avatar Bob Lantz
Browse files

Correctly set controller backoff for OVS.

Also report connected in standalone/bridge mode

Fixes #460

Conflicts:
	mininet/node.py
parent c75eb471
No related branches found
No related tags found
No related merge requests found
...@@ -1066,6 +1066,7 @@ def __init__( self, name, failMode='secure', datapath='kernel', ...@@ -1066,6 +1066,7 @@ def __init__( self, name, failMode='secure', datapath='kernel',
self.datapath = datapath self.datapath = datapath
self.inband = inband self.inband = inband
self.protocols = protocols self.protocols = protocols
self._uuids = [] # controller UUIDs
@classmethod @classmethod
def setup( cls ): def setup( cls ):
...@@ -1124,22 +1125,25 @@ def detach( self, intf ): ...@@ -1124,22 +1125,25 @@ def detach( self, intf ):
"Disconnect a data port" "Disconnect a data port"
self.cmd( 'ovs-vsctl del-port', self, intf ) self.cmd( 'ovs-vsctl del-port', self, intf )
def controllerUUIDs( self ): def controllerUUIDs( self, update=False ):
"Return ovsdb UUIDs for our controllers" """Return ovsdb UUIDs for our controllers
uuids = [] update: update cached value"""
controllers = self.cmd( 'ovs-vsctl -- get Bridge', self, if not self._uuids or update:
'Controller' ).strip() controllers = self.cmd( 'ovs-vsctl -- get Bridge', self,
if controllers.startswith( '[' ) and controllers.endswith( ']' ): 'Controller' ).strip()
controllers = controllers[ 1 : -1 ] if controllers.startswith( '[' ) and controllers.endswith( ']' ):
uuids = [ c.strip() for c in controllers.split( ',' ) ] controllers = controllers[ 1 : -1 ]
return uuids if controllers:
self._uuids = [ c.strip() for c in controllers.split( ',' ) ]
return self._uuids
def connected( self ): def connected( self ):
"Are we connected to at least one of our controllers?" "Are we connected to at least one of our controllers?"
results = [ 'true' in self.cmd( 'ovs-vsctl -- get Controller', for uuid in self.controllerUUIDs():
uuid, 'is_connected' ) if 'true' in self.cmd( 'ovs-vsctl -- get Controller',
for uuid in self.controllerUUIDs() ] uuid, 'is_connected' ):
return reduce( or_, results, False ) return True
return self.failMode == 'standalone'
def start( self, controllers ): def start( self, controllers ):
"Start up a new OVS OpenFlow switch using ovs-vsctl" "Start up a new OVS OpenFlow switch using ovs-vsctl"
...@@ -1184,15 +1188,14 @@ def start( self, controllers ): ...@@ -1184,15 +1188,14 @@ def start( self, controllers ):
cmd += '-- set bridge %s datapath_type=netdev ' % self cmd += '-- set bridge %s datapath_type=netdev ' % self
if self.protocols: if self.protocols:
cmd += '-- set bridge %s protocols=%s' % ( self, self.protocols ) cmd += '-- set bridge %s protocols=%s' % ( self, self.protocols )
# Reconnect quickly to controllers (1s vs. 15s max_backoff)
for uuid in self.controllerUUIDs():
if uuid.count( '-' ) != 4:
# Doesn't look like a UUID
continue
uuid = uuid.strip()
cmd += '-- set Controller %smax_backoff=1000 ' % uuid
# Do it!! # Do it!!
self.cmd( cmd ) self.cmd( cmd )
# Reconnect quickly to controllers (1s vs. 15s max_backoff)
uuids = [ '-- set Controller %s max_backoff=1000' % uuid
for uuid in self.controllerUUIDs() ]
if uuids:
self.cmd( 'ovs-vsctl', *uuids )
# If necessary, restore TC config overwritten by OVS
for intf in self.intfList(): for intf in self.intfList():
self.TCReapply( intf ) self.TCReapply( intf )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment