From ba43451bd637ac530e2118b9d0045dff74f0b633 Mon Sep 17 00:00:00 2001 From: Cody <cody@onlab.us> Date: Wed, 28 May 2014 12:42:48 -0700 Subject: [PATCH] rearranged code for elegance --- mininet/node.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/mininet/node.py b/mininet/node.py index 4366362b..0630aae6 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -991,8 +991,6 @@ def setup( cls ): exit( 1 ) info = quietRun( 'ovs-vsctl --version' ) cls.OVSVersion = findall( '\d+\.\d+', info )[ 0 ] - if cls.isOldOVS(): - print "using old version of ovs so startup will be slower" @classmethod def isOldOVS( cls ): @@ -1055,6 +1053,7 @@ def start( self, controllers ): self.cmd( 'ifconfig lo up' ) # Annoyingly, --if-exists option seems not to work self.cmd( 'ovs-vsctl del-br', self ) + int( self.dpid, 16 ) # DPID must be a hex string # Interfaces and controllers 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() ) @@ -1062,8 +1061,18 @@ def start( self, controllers ): for c in controllers ) if self.listenPort: clist += ' ptcp:%s' % self.listenPort - # configure old version ov ovs - if self.isOldOVS(): + # Construct big ovs-vsctl command for new versions of OVS + 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 ) for intf in self.intfList(): if not intf.IP(): @@ -1072,17 +1081,6 @@ def start( self, controllers ): 'other_config:datapath-id=%s ' % self.dpid + '-- set-fail-mode %s %s ' % ( self, self.failMode ) + '-- 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: cmd += ( '-- set bridge %s ' 'other-config:disable-in-band=true ' % self ) -- GitLab