Exemplo n.º 1
0
    def mountDirs( self, dirs ):
        "Mount a list of directories"
        for dir_ in dirs:
            mountpoint = self.root + dir_
	    #print mountpoint
            errFail( 'mount -B %s %s' %
                     ( dir_, mountpoint ) )
Exemplo n.º 2
0
 def mountPrivateDirs(self):
     "Create and bind mount private dirs"
     for dir in self.privateDirs:
         privateDir = self.private + dir
         errFail('mkdir -p ' + privateDir)
         mountPoint = self.root + dir
         errFail('mount -B %s %s' % (privateDir, mountPoint))
Exemplo n.º 3
0
 def mountPrivateDirs( self ):
     "Create and bind mount private dirs"
     for dir_ in self.privateDirs:
         privateDir = self.private + dir_
         errFail( 'mkdir -p ' + privateDir )
         mountPoint = self.root + dir_
         errFail( 'mount -B %s %s' %
                        ( privateDir, mountPoint) )
Exemplo n.º 4
0
 def cleanup(self):
     """Clean up, then unmount bind mounts
        unmount: actually unmount bind mounts?"""
     # Wait for process to actually terminate
     self.shell.wait()
     Host.cleanup(self)
     if self.unmount:
         self.unmountBindMounts()
         errFail('rmdir ' + self.root)
Exemplo n.º 5
0
 def cleanup( self ):
     """Clean up, then unmount bind mounts
        unmount: actually unmount bind mounts?"""
     # Wait for process to actually terminate
     self.shell.wait()
     Host.cleanup( self )
     if self.unmount:
         self.unmountBindMounts()
         errFail( 'rmdir ' + self.root )
Exemplo n.º 6
0
 def setCPUs(self, cores, mems=0):
     "Specify (real) cores that our cgroup can run on"
     if type(cores) is list:
         cores = ','.join([str(c) for c in cores])
     self.cgroupSet(resource='cpuset', param='cpus', value=cores)
     # Memory placement is probably not relevant, but we
     # must specify it anyway
     self.cgroupSet(resource='cpuset', param='mems', value=mems)
     # We have to do this here after we've specified
     # cpus and mems
     errFail('cgclassify -g cpuset:/%s %s' % (self.name, self.pid))
Exemplo n.º 7
0
Arquivo: node.py Projeto: sjas/mininet
 def setCPUs(self, cores, mems=0):
     "Specify (real) cores that our cgroup can run on"
     if type(cores) is list:
         cores = ",".join([str(c) for c in cores])
     self.cgroupSet(resource="cpuset", param="cpus", value=cores)
     # Memory placement is probably not relevant, but we
     # must specify it anyway
     self.cgroupSet(resource="cpuset", param="mems", value=mems)
     # We have to do this here after we've specified
     # cpus and mems
     errFail("cgclassify -g cpuset:/%s %s" % (self.name, self.pid))
    def set_sysctl_variable(var, value):
        """
        Use Mininet command execution to set and verify sysctl variables.

        :param var:     sysctl var name, e.g. 'net.mptcp.mptcp_enabled'
        :param value:   variable value, e.g. '1'
        :return:
        """
        errFail(['sysctl', '-w', '{0}={1}'.format(var, value)])
        out, err, ret = errFail(['sysctl', '-n', var])
        debug('type {} and value "{}"\n'.format(type(out), out.strip()))
        out = out.replace('\n', '')
        if type(value) is bool and bool(out) != value or type(
                value) is not bool and out != str(value):
            raise Exception(
                "sysctl Fail: setting {} failed, should be {} is {}".format(
                    var, value, out))
Exemplo n.º 9
0
 def __init__( self, name, sched='cfs', **kwargs ):
     Host.__init__( self, name, **kwargs )
     # Initialize class if necessary
     if not CPULimitedHost.inited:
         CPULimitedHost.init()
     # Create a cgroup and move shell into it
     self.cgroup = 'cpu,cpuacct,cpuset:/' + self.name
     errFail( 'cgcreate -g ' + self.cgroup )
     # We don't add ourselves to a cpuset because you must
     # specify the cpu and memory placement first
     errFail( 'cgclassify -g cpu,cpuacct:/%s %s' % ( self.name, self.pid ) )
     # BL: Setting the correct period/quota is tricky, particularly
     # for RT. RT allows very small quotas, but the overhead
     # seems to be high. CFS has a mininimum quota of 1 ms, but
     # still does better with larger period values.
     self.period_us = kwargs.get( 'period_us', 100000 )
     self.sched = sched
     self.rtprio = 20
Exemplo n.º 10
0
    def __init__(self, name, sched='cfs', **kwargs):
        """Initailized Resource Limited Host Class"""
        Host.__init__(self, name, **kwargs)
        # Initialize class if necessary
        if not RSLimitedHost.inited:
            RSLimitedHost.init()

        self.cgroup = 'cpu,cpuacct,cpuset,memory,blkio:/' + self.name

        errFail('cgcreate -g ' + self.cgroup)
        errFail('cgclassify -g cpu,cpuacct,memory,blkio:/%s %s' %
                (self.name, self.pid))

        self.period_us = kwargs.get('period_us', 100000)
        self.sched = sched
        if sched == 'rt':
            self.checkRtGroupSched()
            self.rtprio = 20
Exemplo n.º 11
0
def mountPoints():
    "Return list of mounted file systems"
    mtab, _err, _ret = errFail('cat /proc/mounts')
    lines = mtab.split('\n')
    mounts = []
    for line in lines:
        if not line:
            continue
        fields = line.split(' ')
        mount = fields[1]
        mounts.append(mount)
    return mounts
Exemplo n.º 12
0
def mountPoints():
    "Return list of mounted file systems"
    mtab, _err, _ret = errFail( 'cat /proc/mounts' )
    lines = mtab.split( '\n' )
    mounts = []
    for line in lines:
        if not line:
            continue
        fields = line.split( ' ')
        mount = fields[ 1 ]
        mounts.append( mount )
    return mounts
Exemplo n.º 13
0
 def createBindMounts(self):
     """Create a chroot directory structure,
        with self.privateDirs as private dirs"""
     errFail('mkdir -p ' + self.rundir)
     unmountAll(self.rundir)
     # Create /root and /private directories
     self.root = self.rundir + '/root'
     self.private = self.rundir + '/private'
     errFail('mkdir -p ' + self.root)
     errFail('mkdir -p ' + self.private)
     # Recursively mount / in private doort
     # note we'll remount /sys and /proc later
     errFail('mount -B / ' + self.root)
     self.mountDirs(self.remounts)
     self.mountPrivateDirs()
Exemplo n.º 14
0
 def createBindMounts( self ):
     """Create a chroot directory structure,
        with self.privateDirs as private dirs"""
     errFail( 'mkdir -p '+ self.rundir )
     unmountAll( self.rundir )
     # Create /root and /private directories
     self.root = self.rundir + '/root'
     self.private = self.rundir + '/private'
     errFail( 'mkdir -p ' + self.root )
     errFail( 'mkdir -p ' + self.private )
     # Recursively mount / in private doort
     # note we'll remount /sys and /proc later
     errFail( 'mount -B / ' + self.root )
     self.mountDirs( self.remounts )
     self.mountPrivateDirs()
Exemplo n.º 15
0
 def mountDirs(self, dirs):
     "Mount a list of directories"
     for dir in dirs:
         mountpoint = self.root + dir
         errFail('mount -B %s %s' % (dir, mountpoint))
Exemplo n.º 16
0
def get_system_available_congestioncontrol_algos():
    out, err, ret = errFail(
        ['sysctl', '-n', 'net.ipv4.tcp_available_congestion_control'])
    return out.strip().split()