Tag node bash processes and add attach script
Try invoking bash processes with -s mininet:host, for easy identification of hosts. This enables easy attachment using the util/m script. closes #121
This commit is contained in:
+4
-1
@@ -27,12 +27,15 @@ def cleanup():
|
|||||||
info("*** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes"
|
info("*** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes"
|
||||||
"\n")
|
"\n")
|
||||||
zombies = 'controller ofprotocol ofdatapath ping nox_core lt-nox_core '
|
zombies = 'controller ofprotocol ofdatapath ping nox_core lt-nox_core '
|
||||||
zombies += 'ovs-openflowd udpbwtest'
|
zombies += 'ovs-openflowd udpbwtest mnexec'
|
||||||
# Note: real zombie processes can't actually be killed, since they
|
# Note: real zombie processes can't actually be killed, since they
|
||||||
# are already (un)dead. Then again,
|
# are already (un)dead. Then again,
|
||||||
# you can't connect to them either, so they're mostly harmless.
|
# you can't connect to them either, so they're mostly harmless.
|
||||||
sh( 'killall -9 ' + zombies + ' 2> /dev/null' )
|
sh( 'killall -9 ' + zombies + ' 2> /dev/null' )
|
||||||
|
|
||||||
|
# And kill off sudo mnexec
|
||||||
|
sh( 'pkill -9 -f "sudo mnexec"')
|
||||||
|
|
||||||
info( "*** Removing junk from /tmp\n" )
|
info( "*** Removing junk from /tmp\n" )
|
||||||
sh( 'rm -f /tmp/vconn* /tmp/vlogs* /tmp/*.out /tmp/*.log' )
|
sh( 'rm -f /tmp/vconn* /tmp/vlogs* /tmp/*.out /tmp/*.log' )
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -118,7 +118,8 @@ class Node( object ):
|
|||||||
if self.inNamespace:
|
if self.inNamespace:
|
||||||
opts += 'n'
|
opts += 'n'
|
||||||
# bash -m: enable job control
|
# bash -m: enable job control
|
||||||
cmd = [ 'mnexec', opts, 'bash', '-m' ]
|
# -s: pass $* to shell, and make process easy to find in ps
|
||||||
|
cmd = [ 'mnexec', opts, 'bash', '-ms', 'mininet:' + self.name ]
|
||||||
self.shell = Popen( cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT,
|
self.shell = Popen( cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT,
|
||||||
close_fds=True )
|
close_fds=True )
|
||||||
self.stdin = self.shell.stdin
|
self.stdin = self.shell.stdin
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Attach to a Mininet host and run a command
|
||||||
|
|
||||||
|
if [ -z $1 ]; then
|
||||||
|
echo "usage: $0 host cmd [args...]"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
host=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
pid=`pgrep -f mininet:$host`
|
||||||
|
if [ "$pid" == "" ]; then
|
||||||
|
echo "Could not find Mininet host $host"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $2 ]; then
|
||||||
|
cmd='bash'
|
||||||
|
else
|
||||||
|
shift
|
||||||
|
cmd=$*
|
||||||
|
fi
|
||||||
|
|
||||||
|
cgroup=/sys/fs/cgroup/cpu/$host
|
||||||
|
if [ -d "$cgroup" ]; then
|
||||||
|
cg="-g $host"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec sudo mnexec -a $pid $cg $cmd
|
||||||
Reference in New Issue
Block a user