carlosmscabral | f40ecd1 | 2013-02-01 18:15:58 -0200 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | "This example doesn't use OpenFlow, but attempts to run sshd in a namespace." |
| 4 | |
| 5 | from mininet.node import Host |
| 6 | from mininet.util import ensureRoot |
| 7 | |
| 8 | ensureRoot() |
| 9 | |
| 10 | print "*** Creating nodes" |
| 11 | h1 = Host( 'h1' ) |
| 12 | |
| 13 | root = Host( 'root', inNamespace=False ) |
| 14 | |
| 15 | print "*** Creating links" |
| 16 | h1.linkTo( root ) |
| 17 | |
| 18 | print h1 |
| 19 | |
| 20 | print "*** Configuring nodes" |
| 21 | h1.setIP( '10.0.0.1', 8 ) |
| 22 | root.setIP( '10.0.0.2', 8 ) |
| 23 | |
| 24 | print "*** Creating banner file" |
| 25 | f = open( '/tmp/%s.banner' % h1.name, 'w' ) |
| 26 | f.write( 'Welcome to %s at %s\n' % ( h1.name, h1.IP() ) ) |
| 27 | f.close() |
| 28 | |
| 29 | print "*** Running sshd" |
| 30 | h1.cmd( '/usr/sbin/sshd -o "Banner /tmp/%s.banner"' % h1.name ) |
| 31 | |
| 32 | print "*** You may now ssh into", h1.name, "at", h1.IP() |