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

First crack at setting controller backoff in single command

parent 30ebb852
No related branches found
No related tags found
No related merge requests found
...@@ -1174,7 +1174,7 @@ def patchOpts( intf ): ...@@ -1174,7 +1174,7 @@ def patchOpts( intf ):
intf1, intf2 = intf.link.intf1, intf.link.intf2 intf1, intf2 = intf.link.intf1, intf.link.intf2
peer = intf1 if intf1 != intf else intf2 peer = intf1 if intf1 != intf else intf2
return ( ' -- set Interface %s type=patch' return ( ' -- set Interface %s type=patch'
' -- set Interface %s options:peer=%s ' % ' -- set Interface %s options:peer=%s' %
( intf, intf, peer ) ) ( intf, intf, peer ) )
# pylint: disable=too-many-branches # pylint: disable=too-many-branches
...@@ -1191,19 +1191,27 @@ def start( self, controllers ): ...@@ -1191,19 +1191,27 @@ def start( self, controllers ):
+ self.patchOpts( intf ) + self.patchOpts( intf )
for intf in self.intfList() for intf in self.intfList()
if self.ports[ intf ] and not intf.IP() ) if self.ports[ intf ] and not intf.IP() )
clist = ' '.join( '%s:%s:%d' % ( c.protocol, c.IP(), c.port )
for c in controllers )
if self.listenPort:
clist += ' ptcp:%s' % self.listenPort
# Construct big ovs-vsctl command for new versions of OVS # Construct big ovs-vsctl command for new versions of OVS
clist = [ ( self.name + c.name, '%s:%s:%d' %
( c.protocol, c.IP(), c.port ) )
for c in controllers ]
if self.listenPort:
clist.append( ( self.name + '-listen',
'ptcp:%s' % self.listenPort ) )
if not self.isOldOVS(): if not self.isOldOVS():
ccmd = ' -- --id=@%s create Controller target=\\"%s\\"'
if self.reconnectms:
ccmd += ' max_backoff=%d' % self.reconnectms
cargs = ''.join( ccmd % ( name, target )
for name, target in clist )
clist = ','.join( '@%s' % name for name, _target in clist )
cmd = ( '-- --if-exists del-br %s' % self + cmd = ( '-- --if-exists del-br %s' % self +
' -- add-br %s' % self + ' -- add-br %s' % self +
' -- set Bridge %s' % self + ' -- set bridge %s' % self +
' other_config:datapath-id=%s' % self.dpid + ' other_config:datapath-id=%s' % self.dpid +
' -- set-fail-mode %s %s ' % ( self, self.failMode ) + ' fail_mode=%s' % self.failMode +
intfs + ' controller=[%s] ' % clist +
' -- set-controller %s %s' % ( self, clist ) ) intfs + cargs )
# Construct ovs-vsctl commands for old versions of OVS # Construct ovs-vsctl commands for old versions of OVS
else: else:
# Annoyingly, --if-exists option seems not to work # Annoyingly, --if-exists option seems not to work
...@@ -1215,7 +1223,7 @@ def start( self, controllers ): ...@@ -1215,7 +1223,7 @@ def start( self, controllers ):
cmd = ( 'set Bridge %s' % self + cmd = ( 'set Bridge %s' % self +
' other_config:datapath-id=%s' % self.dpid + ' other_config:datapath-id=%s' % self.dpid +
' -- set-fail-mode %s %s ' % ( self, self.failMode ) + ' -- set-fail-mode %s %s ' % ( self, self.failMode ) +
' -- set-controller %s %s ' % ( self, clist ) ) ' -- set-controller %s %s ' % ( self, ' '.join( clist ) ) )
if not self.inband: if not self.inband:
cmd += ( ' -- set bridge %s ' cmd += ( ' -- set bridge %s '
'other-config:disable-in-band=true' % self ) 'other-config:disable-in-band=true' % self )
...@@ -1228,7 +1236,7 @@ def start( self, controllers ): ...@@ -1228,7 +1236,7 @@ def start( self, controllers ):
# Do it!! # Do it!!
self.vsctl( cmd ) self.vsctl( cmd )
# Reconnect quickly to controllers (1s vs. 15s max_backoff) # Reconnect quickly to controllers (1s vs. 15s max_backoff)
if self.reconnectms: if self.isOldOVS() and self.reconnectms:
uuids = [ '-- set Controller %s max_backoff=%d' % uuids = [ '-- set Controller %s max_backoff=%d' %
( uuid, self.reconnectms ) ( uuid, self.reconnectms )
for uuid in self.controllerUUIDs() ] for uuid in self.controllerUUIDs() ]
...@@ -1273,12 +1281,19 @@ def connected( self ): ...@@ -1273,12 +1281,19 @@ def connected( self ):
class OVSBatch( OVSSwitch ): class OVSBatch( OVSSwitch ):
"Experiment: batch startup of OVS switches" "Experiment: batch startup of OVS switches"
reconnectms = 1000 # shared for all switches
def __init__( self, *args, **kwargs ): def __init__( self, *args, **kwargs ):
kwargs.update( reconnectms=None )
self.commands = [] self.commands = []
self.started = False self.started = False
# Use global rather than local reconnectms
reconnectms = kwargs.pop( 'reconnectms', 1000 )
self.__class__.reconnectms = max( reconnectms,
self.__class__.reconnectms )
kwargs.update( reconnectms=None )
super( OVSBatch, self ).__init__( *args, **kwargs ) super( OVSBatch, self ).__init__( *args, **kwargs )
@classmethod @classmethod
def batchStartup( cls, switches ): def batchStartup( cls, switches ):
"Batch startup for OVS" "Batch startup for OVS"
...@@ -1291,11 +1306,11 @@ def batchStartup( cls, switches ): ...@@ -1291,11 +1306,11 @@ def batchStartup( cls, switches ):
cmds += ' ' + cmd.strip() cmds += ' ' + cmd.strip()
# Split into 1 MB blocks # Split into 1 MB blocks
if len( cmds ) > 1000000: if len( cmds ) > 1000000:
print quietRun( 'ovs-vsctl' + cmds ) errRun( 'ovs-vsctl' + cmds, shell=True )
cmds = '' cmds = ''
switch.started = True switch.started = True
if cmds: if cmds:
quietRun( 'ovs-vsctl' + cmds ) quietRun( 'ovs-vsctl' + cmds, shell=True )
return True return True
def vsctl( self, *args, **kwargs ): def vsctl( self, *args, **kwargs ):
...@@ -1428,6 +1443,7 @@ def stop( self, *args, **kwargs ): ...@@ -1428,6 +1443,7 @@ def stop( self, *args, **kwargs ):
"Stop controller." "Stop controller."
self.cmd( 'kill %' + self.command ) self.cmd( 'kill %' + self.command )
self.cmd( 'wait %' + self.command ) self.cmd( 'wait %' + self.command )
kwargs.update( deleteIntfs=False )
super( Controller, self ).stop( *args, **kwargs ) super( Controller, self ).stop( *args, **kwargs )
def IP( self, intf=None ): def IP( self, intf=None ):
......
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