rearranged code for elegance
This commit is contained in:
+13
-15
@@ -991,8 +991,6 @@ class OVSSwitch( Switch ):
|
|||||||
exit( 1 )
|
exit( 1 )
|
||||||
info = quietRun( 'ovs-vsctl --version' )
|
info = quietRun( 'ovs-vsctl --version' )
|
||||||
cls.OVSVersion = findall( '\d+\.\d+', info )[ 0 ]
|
cls.OVSVersion = findall( '\d+\.\d+', info )[ 0 ]
|
||||||
if cls.isOldOVS():
|
|
||||||
print "using old version of ovs so startup will be slower"
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def isOldOVS( cls ):
|
def isOldOVS( cls ):
|
||||||
@@ -1055,6 +1053,7 @@ class OVSSwitch( Switch ):
|
|||||||
self.cmd( 'ifconfig lo up' )
|
self.cmd( 'ifconfig lo up' )
|
||||||
# Annoyingly, --if-exists option seems not to work
|
# Annoyingly, --if-exists option seems not to work
|
||||||
self.cmd( 'ovs-vsctl del-br', self )
|
self.cmd( 'ovs-vsctl del-br', self )
|
||||||
|
int( self.dpid, 16 ) # DPID must be a hex string
|
||||||
# Interfaces and controllers
|
# Interfaces and controllers
|
||||||
intfs = ' '.join( '-- add-port %s %s -- set Interface %s ofport_request=%s ' % ( self, intf, intf, self.ports[intf] )
|
intfs = ' '.join( '-- add-port %s %s -- set Interface %s ofport_request=%s ' % ( self, intf, intf, self.ports[intf] )
|
||||||
for intf in self.intfList() if not intf.IP() )
|
for intf in self.intfList() if not intf.IP() )
|
||||||
@@ -1062,8 +1061,18 @@ class OVSSwitch( Switch ):
|
|||||||
for c in controllers )
|
for c in controllers )
|
||||||
if self.listenPort:
|
if self.listenPort:
|
||||||
clist += ' ptcp:%s' % self.listenPort
|
clist += ' ptcp:%s' % self.listenPort
|
||||||
# configure old version ov ovs
|
# Construct big ovs-vsctl command for new versions of OVS
|
||||||
if self.isOldOVS():
|
if not self.isOldOVS():
|
||||||
|
print "\nusing a newer ovs version"
|
||||||
|
cmd = ( 'ovs-vsctl add-br %s ' % self +
|
||||||
|
'-- set Bridge %s ' % self +
|
||||||
|
'other_config:datapath-id=%s ' % self.dpid +
|
||||||
|
'-- set-fail-mode %s %s ' % ( self, self.failMode ) +
|
||||||
|
intfs +
|
||||||
|
'-- set-controller %s %s ' % (self, clist ) )
|
||||||
|
# Construct ovs-vsctl commands for old versions of OVS
|
||||||
|
else:
|
||||||
|
print "\nusing an older ovs version"
|
||||||
self.cmd( 'ovs-vsctl add-br', self )
|
self.cmd( 'ovs-vsctl add-br', self )
|
||||||
for intf in self.intfList():
|
for intf in self.intfList():
|
||||||
if not intf.IP():
|
if not intf.IP():
|
||||||
@@ -1072,17 +1081,6 @@ class OVSSwitch( Switch ):
|
|||||||
'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, clist ))
|
||||||
|
|
||||||
int( self.dpid, 16 ) # DPID must be a hex string
|
|
||||||
# Construct big ovs-vsctl command
|
|
||||||
if not self.isOldOVS():
|
|
||||||
print "using a newer ovs version so startup will be faster"
|
|
||||||
cmd = ( 'ovs-vsctl add-br %s ' % self +
|
|
||||||
'-- set Bridge %s ' % self +
|
|
||||||
'other_config:datapath-id=%s ' % self.dpid +
|
|
||||||
'-- set-fail-mode %s %s ' % ( self, self.failMode ) +
|
|
||||||
intfs +
|
|
||||||
'-- set-controller %s %s ' % (self, 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 )
|
||||||
|
|||||||
Reference in New Issue
Block a user