Skip to content

Commit c265dee

Browse files
committed
Cluster edition prototype: remote nodes and links.
We add a new experimental feature to allow Mininet to run across a cluster of machines. This is currently implemented via a set mix-in classes that provide remote nodes that are implemented via a connection to a remote shell, and remote links which are tunnels across servers. In this preliminary implementation, both control and data connections are made via ssh, but this could change in the future. A MininetCluster class is provided which allows existing code to be used with minimal modification - all that is required is to provide a list of servers to use. A customizable placement algorithm may also be specified. An experimental CLI subclass is also provided to make it easier to examine node placement; status and links commands can also check whether nodes and tunnels are still running. Although this is an experimental feature, it does include a --cluster option to make it convenient to start up a Mininet simulation over a cluster, and a script to assist with setting up the prerequisite authentication via ssh key pairs. The cluster feature is preliminary and missing some obvious important features, such as parallel startup and multiple tunnel types, which we hope to add in the future.
1 parent 0333d3d commit c265dee

11 files changed

Lines changed: 1294 additions & 78 deletions

File tree

bin/mn

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if 'PYTHONPATH' in os.environ:
2222

2323
from mininet.clean import cleanup
2424
from mininet.cli import CLI
25-
from mininet.log import lg, LEVELS, info, debug, error
25+
from mininet.log import lg, LEVELS, info, debug, warn, error
2626
from mininet.net import Mininet, MininetWithControlNet, VERSION
2727
from mininet.node import ( Host, CPULimitedHost, Controller, OVSController,
2828
NOX, RemoteController, DefaultController,
@@ -35,6 +35,15 @@ from mininet.topolib import TreeTopo, TorusTopo
3535
from mininet.util import custom, customConstructor
3636
from mininet.util import buildTopo
3737

38+
from functools import partial
39+
40+
# Experimental! cluster edition prototype
41+
from mininet.examples.cluster import ( MininetCluster, RemoteHost,
42+
RemoteOVSSwitch, RemoteLink,
43+
SwitchBinPlacer, RandomPlacer )
44+
from mininet.examples.clustercli import DemoCLI as ClusterCLI
45+
46+
PLACEMENT = { 'block': SwitchBinPlacer, 'random': RandomPlacer }
3847

3948
# built in topologies, created only when run
4049
TOPODEF = 'minimal'
@@ -204,6 +213,14 @@ class MininetRunner( object ):
204213
default=False, help="adds a NAT to the topology "
205214
"that connects Mininet to the physical network" )
206215
opts.add_option( '--version', action='callback', callback=version )
216+
opts.add_option( '--cluster', type='string', default=None,
217+
metavar='server1,server2...',
218+
help=( 'run on multiple servers (experimental!)' ) )
219+
opts.add_option( '--placement', type='choice',
220+
choices=PLACEMENT.keys(), default='block',
221+
metavar='block|random',
222+
help=( 'node placement for --cluster '
223+
'(experimental!) ' ) )
207224

208225
self.options, self.args = opts.parse_args()
209226

@@ -226,6 +243,8 @@ class MininetRunner( object ):
226243
def begin( self ):
227244
"Create and run mininet."
228245

246+
global CLI
247+
229248
if self.options.clean:
230249
cleanup()
231250
exit()
@@ -241,8 +260,6 @@ class MininetRunner( object ):
241260
if self.validate:
242261
self.validate( self.options )
243262

244-
inNamespace = self.options.innamespace
245-
Net = MininetWithControlNet if inNamespace else Mininet
246263
ipBase = self.options.ipbase
247264
xterms = self.options.xterms
248265
mac = self.options.mac
@@ -251,6 +268,22 @@ class MininetRunner( object ):
251268
listenPort = None
252269
if not self.options.nolistenport:
253270
listenPort = self.options.listenport
271+
272+
# Handle inNamespace, cluster options
273+
inNamespace = self.options.innamespace
274+
cluster = self.options.cluster
275+
if inNamespace and cluster:
276+
print "Please specify --innamespace OR --cluster"
277+
exit()
278+
Net = MininetWithControlNet if inNamespace else Mininet
279+
if cluster:
280+
warn( '*** WARNING: Experimental cluster mode!\n'
281+
'*** Using RemoteHost, RemoteOVSSwitch, RemoteLink\n' )
282+
host, switch, link = RemoteHost, RemoteOVSSwitch, RemoteLink
283+
CLI = ClusterCLI
284+
Net = partial( MininetCluster, servers=cluster.split( ',' ),
285+
placement=PLACEMENT[ self.options.placement ] )
286+
254287
mn = Net( topo=topo,
255288
switch=switch, host=host, controller=controller,
256289
link=link,

0 commit comments

Comments
 (0)