From 300efb2b803efe234c24d81cc7f835a05f1ed6c4 Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Wed, 1 Sep 2010 19:54:10 -0700 Subject: [PATCH] Added simple example of using API just to create a namespace. --- examples/baresshd.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 examples/baresshd.py diff --git a/examples/baresshd.py b/examples/baresshd.py new file mode 100755 index 0000000..841454a --- /dev/null +++ b/examples/baresshd.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +"This example doesn't use OpenFlow, but attempts to run sshd in a namespace." + +from mininet.node import Host + +print "*** Creating nodes" +h1 = Host( 'h1' ) +root = Host( 'root', inNamespace=False ) + +print "*** Creating links" +h1.linkTo( root ) + +print "*** Configuring nodes" +h1.setIP( h1.intfs[ 0 ], '10.0.0.1', 8 ) +root.setIP( root.intfs[ 0 ], '10.0.0.2', 8 ) + +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" +h1.cmd( '/usr/sbin/sshd -o "Banner /tmp/%s.banner"' % h1.name ) + +print "*** You may now ssh into", h1.name, "at", h1.IP()