Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f15744cc9 | ||
|
|
a0497d8c38 | ||
|
|
2e4ef57cf0 |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
include mnexec.c
|
||||
exclude bin/mnexec
|
||||
@@ -21,10 +21,12 @@ test: $(MININET) $(TEST)
|
||||
-echo "Running tests"
|
||||
mininet/test/test_nets.py
|
||||
|
||||
install: mnexec
|
||||
cp mnexec bin/
|
||||
install:
|
||||
python setup.py install
|
||||
|
||||
develop:
|
||||
python setup.py develop
|
||||
|
||||
doc:
|
||||
doxygen doxygen.cfg
|
||||
|
||||
+7
-7
@@ -91,7 +91,6 @@ import re
|
||||
import select
|
||||
import signal
|
||||
from time import sleep
|
||||
from subprocess import check_output
|
||||
|
||||
from mininet.cli import CLI
|
||||
from mininet.log import info, error, debug, output
|
||||
@@ -562,12 +561,13 @@ def init():
|
||||
"Initialize Mininet."
|
||||
if init.inited:
|
||||
return
|
||||
# Make sure we can sudo without a password
|
||||
try:
|
||||
check_output( [ 'sudo', '-n', 'echo' ] )
|
||||
except:
|
||||
raise Exception( "Could not run sudo -n echo - check /etc/sudoers" )
|
||||
# Make sure mnexec is in our path
|
||||
if os.getuid() != 0:
|
||||
# Note: this script must be run as root
|
||||
# Perhaps we should do so automatically!
|
||||
print "*** Mininet must run as root."
|
||||
exit( 1 )
|
||||
# If which produces no output, then mnexec is not in the path.
|
||||
# May want to loosen this to handle mnexec in the current dir.
|
||||
if not quietRun( 'which mnexec' ):
|
||||
raise Exception( "Could not find mnexec - check $PATH" )
|
||||
fixLimits()
|
||||
|
||||
+3
-5
@@ -76,12 +76,12 @@ class Node( object ):
|
||||
opts = '-cdp'
|
||||
if self.inNamespace:
|
||||
opts += 'n'
|
||||
cmd = [ 'sudo', '-E', 'env', 'PATH=%s' % os.environ['PATH'],
|
||||
'mnexec', opts, 'bash', '-m', '-p' ]
|
||||
cmd = [ 'mnexec', opts, 'bash', '-m' ]
|
||||
self.shell = Popen( cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT,
|
||||
close_fds=False )
|
||||
self.stdin = self.shell.stdin
|
||||
self.stdout = self.shell.stdout
|
||||
self.pid = self.shell.pid
|
||||
self.pollOut = select.poll()
|
||||
self.pollOut.register( self.stdout )
|
||||
# Maintain mapping between file descriptors and nodes
|
||||
@@ -102,8 +102,6 @@ class Node( object ):
|
||||
self.waiting = False
|
||||
# Stash additional information as desired
|
||||
self.args = kwargs
|
||||
# Read pid from mnexec
|
||||
self.pid = int( self.readline()[ 1: ] )
|
||||
|
||||
@classmethod
|
||||
def fdToNode( cls, fd ):
|
||||
@@ -151,7 +149,7 @@ class Node( object ):
|
||||
|
||||
def terminate( self ):
|
||||
"Send kill signal to Node and clean up after it."
|
||||
quietRun( 'kill ' + str( self.pid ) )
|
||||
os.kill( self.pid, signal.SIGKILL )
|
||||
self.cleanup()
|
||||
|
||||
def stop( self ):
|
||||
|
||||
+4
-23
@@ -1,12 +1,11 @@
|
||||
"Utility functions for Mininet."
|
||||
|
||||
from time import sleep
|
||||
from resource import setrlimit, getrlimit, RLIMIT_NPROC, RLIMIT_NOFILE
|
||||
from resource import setrlimit, RLIMIT_NPROC, RLIMIT_NOFILE
|
||||
import select
|
||||
from subprocess import call, check_call, Popen, PIPE, STDOUT
|
||||
import os
|
||||
|
||||
from mininet.log import error, warn
|
||||
from mininet.log import error
|
||||
|
||||
# Command execution support
|
||||
|
||||
@@ -30,7 +29,6 @@ def quietRun( *cmd ):
|
||||
cmd = cmd[ 0 ]
|
||||
if isinstance( cmd, str ):
|
||||
cmd = cmd.split( ' ' )
|
||||
cmd = ["sudo", "-E", "env", "PATH=%s" % os.environ["PATH"]] + cmd
|
||||
popen = Popen( cmd, stdout=PIPE, stderr=STDOUT )
|
||||
# We can't use Popen.communicate() because it uses
|
||||
# select(), which can't handle
|
||||
@@ -207,22 +205,5 @@ def makeNumeric( s ):
|
||||
|
||||
def fixLimits():
|
||||
"Fix ridiculously small resource limits."
|
||||
manyprocs = 8192
|
||||
manyfiles = 32768
|
||||
minprocs, maxprocs = getrlimit( RLIMIT_NPROC )
|
||||
minfiles, maxfiles = getrlimit( RLIMIT_NOFILE )
|
||||
# Root can raise limits
|
||||
if os.getuid() == 0:
|
||||
maxprocs = max( maxprocs, manyprocs )
|
||||
maxfiles = max( maxfiles, manyfiles )
|
||||
minprocs = min( manyprocs, maxprocs )
|
||||
minfiles = min( manyfiles, maxfiles )
|
||||
setrlimit( RLIMIT_NPROC, ( minprocs, maxprocs ) )
|
||||
setrlimit( RLIMIT_NOFILE, ( minfiles, maxfiles ) )
|
||||
nprocs = max( getrlimit( RLIMIT_NPROC ) )
|
||||
nfiles = max( getrlimit( RLIMIT_NOFILE ) )
|
||||
# Complain if limits are too low
|
||||
if nprocs < manyprocs:
|
||||
warn( '*** Warning: process limit is low:', nprocs, 'procs\n' )
|
||||
if nfiles < manyfiles:
|
||||
warn( '*** Warning: open file limit is low:', nfiles, 'files \n' )
|
||||
setrlimit( RLIMIT_NPROC, ( 4096, 8192 ) )
|
||||
setrlimit( RLIMIT_NOFILE, ( 16384, 32768 ) )
|
||||
@@ -2,26 +2,33 @@
|
||||
|
||||
"Setuptools params"
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
from os.path import join
|
||||
|
||||
scripts = [ join( 'bin', filename ) for filename in [
|
||||
'mn', 'mnexec' ] ]
|
||||
import os, setuptools
|
||||
import distutils.command.build_scripts
|
||||
import distutils.command.clean
|
||||
import distutils.ccompiler
|
||||
|
||||
modname = distname = 'mininet'
|
||||
|
||||
setup(
|
||||
class build_scripts(distutils.command.build_scripts.build_scripts):
|
||||
def run(self):
|
||||
distutils.ccompiler.new_compiler().link_executable(["mnexec.c"], "bin/mnexec")
|
||||
distutils.command.build_scripts.build_scripts.run(self)
|
||||
|
||||
class clean(distutils.command.clean.clean):
|
||||
def run(self):
|
||||
if os.path.exists("bin/mnexec"):
|
||||
os.unlink("bin/mnexec")
|
||||
distutils.command.clean.clean.run(self)
|
||||
|
||||
setuptools.setup(
|
||||
name=distname,
|
||||
version='0.0.0',
|
||||
description='Process-based OpenFlow emulator',
|
||||
author='Bob Lantz',
|
||||
author_email='rlantz@cs.stanford.edu',
|
||||
packages=find_packages(exclude='test'),
|
||||
long_description="""
|
||||
Insert longer description here.
|
||||
""",
|
||||
packages=setuptools.find_packages(exclude='test'),
|
||||
classifiers=[
|
||||
"License :: OSI Approved :: GNU General Public License (GPL)",
|
||||
"License :: OSI Approved :: BSD",
|
||||
"Programming Language :: Python",
|
||||
"Development Status :: 4 - Beta",
|
||||
"Intended Audience :: Developers",
|
||||
@@ -33,5 +40,10 @@ Insert longer description here.
|
||||
'setuptools',
|
||||
'networkx'
|
||||
],
|
||||
scripts=scripts,
|
||||
scripts=[
|
||||
'bin/mn',
|
||||
'bin/mnexec'
|
||||
],
|
||||
cmdclass={"build_scripts": build_scripts,
|
||||
"clean": clean}
|
||||
)
|
||||
Reference in new issue
Block a user