From a562ca1be399fa6d18fb2d1a6662f1f2f3b726db Mon Sep 17 00:00:00 2001 From: Bob Lantz <rlantz@cs.stanford.edu> Date: Tue, 4 Nov 2014 16:27:34 -0800 Subject: [PATCH] Move RT check into its own method, and save value. --- mininet/node.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/mininet/node.py b/mininet/node.py index 784fe890..0a0fec0a 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -166,7 +166,7 @@ def mountPrivateDirs( self ): for directory in self.privateDirs: if isinstance( directory, tuple ): # mount given private directory - privateDir = directory[ 1 ] % self.__dict__ + privateDir = directory[ 1 ] % self.__dict__ mountPoint = directory[ 0 ] self.cmd( 'mkdir -p %s' % privateDir ) self.cmd( 'mkdir -p %s' % mountPoint ) @@ -174,7 +174,7 @@ def mountPrivateDirs( self ): ( privateDir, mountPoint ) ) else: # mount temporary filesystem on directory - self.cmd( 'mkdir -p %s' % directory ) + self.cmd( 'mkdir -p %s' % directory ) self.cmd( 'mount -n -t tmpfs tmpfs %s' % directory ) def unmountPrivateDirs( self ): @@ -640,13 +640,9 @@ def __init__( self, name, sched='cfs', **kwargs ): # still does better with larger period values. self.period_us = kwargs.get( 'period_us', 100000 ) self.sched = sched - if self.sched == 'rt': - release = quietRun( 'uname -r' ).strip('\r\n') - output = quietRun( 'grep CONFIG_RT_GROUP_SCHED /boot/config-%s' % release ) - if output == '# CONFIG_RT_GROUP_SCHED is not set\n': - error( '\n*** error: please enable RT_GROUP_SCHED in your kernel\n' ) - exit( 1 ) - self.rtprio = 20 + if sched == 'rt': + self.checkRtGroupSched() + self.rtprio = 20 def cgroupSet( self, param, value, resource='cpu' ): "Set a cgroup parameter and return its value" @@ -710,6 +706,19 @@ def rtInfo( self, f ): quota = int( self.period_us * f ) return pstr, qstr, self.period_us, quota + _rtGroupSched = False # internal class var: Is CONFIG_RT_GROUP_SCHED set? + + @classmethod + def checkRtGroupSched( cls ): + "Check (Ubuntu,Debian) kernel config for CONFIG_RT_GROUP_SCHED for RT" + if not cls._rtGroupSched: + release = quietRun( 'uname -r' ).strip('\r\n') + output = quietRun( 'grep CONFIG_RT_GROUP_SCHED /boot/config-%s' % release ) + if output == '# CONFIG_RT_GROUP_SCHED is not set\n': + error( '\n*** error: please enable RT_GROUP_SCHED in your kernel\n' ) + exit( 1 ) + cls._rtGroupSched = True + def cfsInfo( self, f): "Internal method: return parameters for CFS bandwidth" pstr, qstr = 'cfs_period_us', 'cfs_quota_us' @@ -1370,7 +1379,7 @@ def __init__( self, name, *ryuArgs, **kwargs ): Controller.__init__( self, name, command='ryu-manager', - cargs='--ofp-tcp-listen-port %s ' + + cargs='--ofp-tcp-listen-port %s ' + ' '.join( ryuArgs ), cdir=ryuCoreDir, **kwargs ) -- GitLab