Correctly set controller backoff for OVS.

Also report connected in standalone/bridge mode

Fixes #460

Conflicts:
	mininet/node.py
This commit is contained in:
Bob Lantz
2014-12-11 17:03:49 -08:00
parent c75eb47158
commit 05dbf82edb
+23 -20
View File
@@ -1066,6 +1066,7 @@ class OVSSwitch( Switch ):
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 @@ class OVSSwitch( Switch ):
"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 @@ class OVSSwitch( Switch ):
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 )