wait for sshd to start in example

This commit is contained in:
cody burkard
2014-10-03 04:52:21 -07:00
parent 2ceb57915a
commit 7c5d2771f7
3 changed files with 27 additions and 17 deletions
+8 -2
View File
@@ -4,9 +4,10 @@
import sys
from mininet.node import Host
from mininet.util import ensureRoot
from mininet.util import ensureRoot, waitListening
ensureRoot()
timeout = 5
print "*** Creating nodes"
h1 = Host( 'h1' )
@@ -33,5 +34,10 @@ cmd = '/usr/sbin/sshd -o UseDNS=no -u0 -o "Banner /tmp/%s.banner"' % h1.name
if len( sys.argv ) > 1:
cmd += ' ' + ' '.join( sys.argv[ 1: ] )
h1.cmd( cmd )
listening = waitListening( server=h1, port=22, timeout=timeout )
print "*** You may now ssh into", h1.name, "at", h1.IP()
if listening:
print "*** You may now ssh into", h1.name, "at", h1.IP()
else:
print ( "*** Warning: after %s seconds, %s is not listening on port 22"
% ( timeout, h1.name ) )