Use print function

This commit is contained in:
Brad Walker
2016-06-21 16:27:04 -07:00
committed by Bob Lantz
parent 57abd9baef
commit 70fcc45893
25 changed files with 189 additions and 141 deletions
+11 -8
View File
@@ -2,33 +2,36 @@
"This example doesn't use OpenFlow, but attempts to run sshd in a namespace."
from __future__ import print_function
import sys
from mininet.node import Host
from mininet.util import ensureRoot, waitListening
ensureRoot()
timeout = 5
print "*** Creating nodes"
print( "*** Creating nodes" )
h1 = Host( 'h1' )
root = Host( 'root', inNamespace=False )
print "*** Creating links"
print( "*** Creating links" )
h1.linkTo( root )
print h1
print( h1 )
print "*** Configuring nodes"
print( "*** Configuring nodes" )
h1.setIP( '10.0.0.1', 8 )
root.setIP( '10.0.0.2', 8 )
print "*** Creating banner file"
print( "*** Creating banner file" )
f = open( '/tmp/%s.banner' % h1.name, 'w' )
f.write( 'Welcome to %s at %s\n' % ( h1.name, h1.IP() ) )
f.close()
print "*** Running sshd"
print( "*** Running sshd" )
cmd = '/usr/sbin/sshd -o UseDNS=no -u0 -o "Banner /tmp/%s.banner"' % h1.name
# add arguments from the command line
if len( sys.argv ) > 1:
@@ -37,7 +40,7 @@ h1.cmd( cmd )
listening = waitListening( server=h1, port=22, timeout=timeout )
if listening:
print "*** You may now ssh into", h1.name, "at", h1.IP()
print( "*** You may now ssh into", h1.name, "at", h1.IP() )
else:
print ( "*** Warning: after %s seconds, %s is not listening on port 22"
print( "*** Warning: after %s seconds, %s is not listening on port 22"
% ( timeout, h1.name ) )