Clean up - TCReapply still broken!

This commit is contained in:
Bob Lantz
2015-01-26 14:06:23 -08:00
parent 9ca6322603
commit bec34e7227
+14 -20
View File
@@ -1150,7 +1150,7 @@ class OVSSwitch( Switch ):
"""Return ovsdb UUIDs for our controllers """Return ovsdb UUIDs for our controllers
update: update cached value""" update: update cached value"""
if not self._uuids or update: if not self._uuids or update:
controllers = self.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 ]
@@ -1171,7 +1171,7 @@ class OVSSwitch( Switch ):
"Return OVS interface options for intf" "Return OVS interface options for intf"
opts = '' opts = ''
if not self.isOldOVS(): if not self.isOldOVS():
# ofport_request is not supported # ofport_request is not supported on old OVS
opts += ' ofport_request=%s' % self.ports[ intf ] opts += ' ofport_request=%s' % self.ports[ intf ]
# Patch ports don't work well with old OVS # Patch ports don't work well with old OVS
if isinstance( intf, OVSIntf ): if isinstance( intf, OVSIntf ):
@@ -1182,7 +1182,8 @@ class OVSSwitch( Switch ):
def bridgeOpts( self ): def bridgeOpts( self ):
"Return OVS bridge options" "Return OVS bridge options"
opts = '' opts = ( ' other_config:datapath-id=%s' % self.dpid +
' fail_mode=%s' % self.failMode )
if not self.inband: if not self.inband:
opts += ' other-config:disable-in-band=true' opts += ' other-config:disable-in-band=true'
if self.datapath == 'user': if self.datapath == 'user':
@@ -1193,19 +1194,18 @@ class OVSSwitch( Switch ):
opts += ' stp_enable=true' % self opts += ' stp_enable=true' % self
return opts return opts
# pylint: disable=too-many-branches
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"
if self.inNamespace: if self.inNamespace:
raise Exception( raise Exception(
'OVS kernel switch does not work in a namespace' ) 'OVS kernel switch does not work in a namespace' )
int( self.dpid, 16 ) # DPID must be a hex string int( self.dpid, 16 ) # DPID must be a hex string
# Interfaces and controllers # Command to add interfaces
intfs = ''.join( ' -- add-port %s %s' % ( self, intf ) + intfs = ''.join( ' -- add-port %s %s' % ( self, intf ) +
self.intfOpts( intf ) self.intfOpts( 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() )
# Construct big ovs-vsctl command # Command to create controller entries
clist = [ ( self.name + c.name, '%s:%s:%d' % clist = [ ( self.name + c.name, '%s:%s:%d' %
( c.protocol, c.IP(), c.port ) ) ( c.protocol, c.IP(), c.port ) )
for c in controllers ] for c in controllers ]
@@ -1217,27 +1217,21 @@ class OVSSwitch( Switch ):
ccmd += ' max_backoff=%d' % self.reconnectms ccmd += ' max_backoff=%d' % self.reconnectms
cargs = ' '.join( ccmd % ( name, target ) cargs = ' '.join( ccmd % ( name, target )
for name, target in clist ) for name, target in clist )
# Controller ID list
cids = ','.join( '@%s' % name for name, _target in clist ) cids = ','.join( '@%s' % name for name, _target in clist )
# Try to delete any existing bridges with the same name
if not self.isOldOVS(): if not self.isOldOVS():
cargs += ' -- --if-exists del-br %s' % self cargs += ' -- --if-exists del-br %s' % self
cmd = ( cargs + # One ovs-vsctl command to rule them all!
self.vsctl( cargs +
' -- add-br %s' % self + ' -- add-br %s' % self +
' -- set bridge %s controller=[%s]' % ( self, cids ) + ' -- set bridge %s controller=[%s]' % ( self, cids ) +
self.bridgeOpts() + self.bridgeOpts() +
intfs ) intfs )
# Do it!! # XXX BROKEN - need to fix this!!
self.vsctl( cmd )
# Reconnect quickly to controllers (1s vs. 15s max_backoff)
if self.isOldOVS() and self.reconnectms:
uuids = [ '-- set Controller %s max_backoff=%d' %
( uuid, self.reconnectms )
for uuid in self.controllerUUIDs() ]
if uuids:
self.vsctl( *uuids )
# If necessary, restore TC config overwritten by OVS # If necessary, restore TC config overwritten by OVS
for intf in self.intfList(): # for intf in self.intfList():
self.TCReapply( intf ) # self.TCReapply( intf )
# pylint: enable=too-many-branches
def stop( self, deleteIntfs=True ): def stop( self, deleteIntfs=True ):
"""Terminate OVS switch. """Terminate OVS switch.
@@ -1305,7 +1299,7 @@ class OVSBatch( OVSSwitch ):
def vsctl( self, *args, **kwargs ): def vsctl( self, *args, **kwargs ):
"Append ovs-vsctl command to list for later execution" "Append ovs-vsctl command to list for later execution"
if self.started: if self.started:
return OVSSwitch.vsctl( self, *args, **kwargs ) return super( OVSBridge, self).vsctl( *args, **kwargs )
cmd = ' '.join( str( arg ).strip() for arg in args ) cmd = ' '.join( str( arg ).strip() for arg in args )
self.commands.append( cmd ) self.commands.append( cmd )