Correctly set controller backoff for OVS.
Also report connected in standalone/bridge mode Fixes #460 Conflicts: mininet/node.py
This commit is contained in:
+19
-16
@@ -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"""
|
||||||
|
if not self._uuids or update:
|
||||||
controllers = self.cmd( 'ovs-vsctl -- get Bridge', self,
|
controllers = self.cmd( 'ovs-vsctl -- get Bridge', self,
|
||||||
'Controller' ).strip()
|
'Controller' ).strip()
|
||||||
if controllers.startswith( '[' ) and controllers.endswith( ']' ):
|
if controllers.startswith( '[' ) and controllers.endswith( ']' ):
|
||||||
controllers = controllers[ 1 : -1 ]
|
controllers = controllers[ 1 : -1 ]
|
||||||
uuids = [ c.strip() for c in controllers.split( ',' ) ]
|
if controllers:
|
||||||
return uuids
|
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 )
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user