Start a network, connect it to root ns, and run sshd on all hosts. ip: root-eth0 IP address in root namespace (10.123.123.1/32) routes: Mininet host networks to route to (10.0/24) switch: Mininet switch to connect to root namespace (s1)
( network, cmd='/usr/sbin/sshd', opts='-D',
ip='10.123.123.1/32', routes=None, switch=None )
| 49 | |
| 50 | # pylint: disable=too-many-arguments |
| 51 | def sshd( network, cmd='/usr/sbin/sshd', opts='-D', |
| 52 | ip='10.123.123.1/32', routes=None, switch=None ): |
| 53 | """Start a network, connect it to root ns, and run sshd on all hosts. |
| 54 | ip: root-eth0 IP address in root namespace (10.123.123.1/32) |
| 55 | routes: Mininet host networks to route to (10.0/24) |
| 56 | switch: Mininet switch to connect to root namespace (s1)""" |
| 57 | if not switch: |
| 58 | switch = network[ 's1' ] # switch to use |
| 59 | if not routes: |
| 60 | routes = [ '10.0.0.0/24' ] |
| 61 | connectToRootNS( network, switch, ip, routes ) |
| 62 | for host in network.hosts: |
| 63 | host.cmd( cmd + ' ' + opts + '&' ) |
| 64 | info( "*** Waiting for ssh daemons to start\n" ) |
| 65 | for server in network.hosts: |
| 66 | waitListening( server=server, port=22, timeout=5 ) |
| 67 | |
| 68 | info( "\n*** Hosts are running sshd at the following addresses:\n" ) |
| 69 | for host in network.hosts: |
| 70 | info( host.name, host.IP(), '\n' ) |
| 71 | info( "\n*** Type 'exit' or control-D to shut down network\n" ) |
| 72 | CLI( network ) |
| 73 | for host in network.hosts: |
| 74 | host.cmd( 'kill %' + cmd ) |
| 75 | network.stop() |
| 76 | |
| 77 | |
| 78 | if __name__ == '__main__': |
no test coverage detected