Mininet Python API Reference Manual
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
mininet.cli.CLI Class Reference

Simple command-line interface to talk to nodes. More...

Inheritance diagram for mininet.cli.CLI:

Public Member Functions

def __init__ (self, mininet, stdin=sys.stdin, script=None, **kwargs)
 Start and run interactive or batch mode CLI. More...
 
def initReadline (cls)
 Set up history if readline is available. More...
 
def run (self)
 Run our cmdloop(), catching KeyboardInterrupt.
 
def emptyline (self)
 Don't repeat last command when you hit return.
 
def getLocals (self)
 Local variable bindings for py command.
 
def do_help (self, line)
 Describe available CLI commands.
 
def do_nodes (self, _line)
 List all nodes.
 
def do_ports (self, _line)
 display ports and interfaces for each switch
 
def do_net (self, _line)
 List network connections.
 
def do_sh (self, line)
 Run an external shell command. More...
 
def do_py (self, line)
 Evaluate a Python expression. More...
 
def do_px (self, line)
 Execute a Python statement. More...
 
def do_pingall (self, line)
 Ping between all hosts.
 
def do_pingpair (self, _line)
 Ping between first two hosts, useful for testing.
 
def do_pingallfull (self, _line)
 Ping between all hosts, returns all ping results.
 
def do_pingpairfull (self, _line)
 Ping between first two hosts, returns all ping results.
 
def do_iperf (self, line)
 Simple iperf TCP test between two (optionally specified) hosts. More...
 
def do_iperfudp (self, line)
 Simple iperf UDP test between two (optionally specified) hosts. More...
 
def do_intfs (self, _line)
 List interfaces.
 
def do_dump (self, _line)
 Dump node info.
 
def do_link (self, line)
 Bring link(s) between two nodes up or down. More...
 
def do_xterm (self, line, term='xterm')
 Spawn xterm(s) for the given node(s). More...
 
def do_x (self, line)
 Create an X11 tunnel to the given node, optionally starting a client. More...
 
def do_gterm (self, line)
 Spawn gnome-terminal(s) for the given node(s). More...
 
def do_exit (self, _line)
 Exit.
 
def do_quit (self, line)
 Exit.
 
def do_EOF (self, line)
 Exit.
 
def isatty (self)
 Is our standard input a tty?
 
def do_noecho (self, line)
 Run an interactive command with echoing turned off. More...
 
def do_source (self, line)
 Read commands from an input file. More...
 
def do_dpctl (self, line)
 Run dpctl (or ovs-ofctl) command on all switches. More...
 
def do_time (self, line)
 Measure time taken for any command in Mininet.
 
def do_links (self, _line)
 Report on links.
 
def do_switch (self, line)
 Starts or stops a switch.
 
def do_wait (self, _line)
 Wait until all switches have connected to a controller.
 
def default (self, line)
 Called on an input line when the command prefix is not recognized. More...
 
def waitForNode (self, node)
 Wait for a node to finish, and print its output.
 
def precmd (self, line)
 allow for comments in the cli
 

Public Attributes

 mn
 
 locals
 
 inPoller
 
 inputFile
 
 readlineInited
 

Static Public Attributes

string prompt = 'mininet> '
 
bool readlineInited = False
 
tuple helpStr
 

Detailed Description

Simple command-line interface to talk to nodes.

Constructor & Destructor Documentation

◆ __init__()

def mininet.cli.CLI.__init__ (   self,
  mininet,
  stdin = sys.stdin,
  script = None,
**  kwargs 
)

Start and run interactive or batch mode CLI.

Parameters
mininetMininet network object
stdinstandard input for CLI
scriptscript to run in batch mode

Member Function Documentation

◆ default()

def mininet.cli.CLI.default (   self,
  line 
)

Called on an input line when the command prefix is not recognized.

Overridden to run shell commands when a node is the first CLI argument. Past the first CLI argument, node names are automatically replaced with corresponding IP addrs.

◆ do_dpctl()

def mininet.cli.CLI.do_dpctl (   self,
  line 
)

Run dpctl (or ovs-ofctl) command on all switches.

Parameters
Usagedpctl command [arg1] [arg2] ...

◆ do_gterm()

def mininet.cli.CLI.do_gterm (   self,
  line 
)

Spawn gnome-terminal(s) for the given node(s).

Parameters
Usagegterm node1 node2 ...

◆ do_iperf()

def mininet.cli.CLI.do_iperf (   self,
  line 
)

Simple iperf TCP test between two (optionally specified) hosts.

Parameters
Usageiperf node1 node2

◆ do_iperfudp()

def mininet.cli.CLI.do_iperfudp (   self,
  line 
)

Simple iperf UDP test between two (optionally specified) hosts.

Parameters
Usageiperfudp bw node1 node2

◆ do_link()

def mininet.cli.CLI.do_link (   self,
  line 
)

Bring link(s) between two nodes up or down.

Parameters
Usagelink node1 node2 [up/down]

◆ do_noecho()

def mininet.cli.CLI.do_noecho (   self,
  line 
)

Run an interactive command with echoing turned off.

Parameters
Usagenoecho [cmd args]

◆ do_px()

def mininet.cli.CLI.do_px (   self,
  line 
)

Execute a Python statement.

Node names may be used, e.g.: px print h1.cmd('ls')

◆ do_py()

def mininet.cli.CLI.do_py (   self,
  line 
)

Evaluate a Python expression.

Node names may be used, e.g.: py h1.cmd('ls')

◆ do_sh()

def mininet.cli.CLI.do_sh (   self,
  line 
)

Run an external shell command.

Parameters
Usagesh [cmd args]

◆ do_source()

def mininet.cli.CLI.do_source (   self,
  line 
)

Read commands from an input file.

Parameters
Usagesource <file>

◆ do_x()

def mininet.cli.CLI.do_x (   self,
  line 
)

Create an X11 tunnel to the given node, optionally starting a client.

Parameters
Usagex node [cmd args]

◆ do_xterm()

def mininet.cli.CLI.do_xterm (   self,
  line,
  term = 'xterm' 
)

Spawn xterm(s) for the given node(s).

Parameters
Usagexterm node1 node2 ...

◆ initReadline()

def mininet.cli.CLI.initReadline (   cls)

Set up history if readline is available.

Write out history file

Member Data Documentation

◆ helpStr

tuple mininet.cli.CLI.helpStr
static
Initial value:
= (
'You may also send a command to a node using:\n'
' <node> command {args}\n'
'For example:\n'
' mininet> h1 ifconfig\n'
'\n'
'The interpreter automatically substitutes IP addresses\n'
'for node names when a node is the first arg, so commands\n'
'like\n'
' mininet> h2 ping h3\n'
'should work.\n'
'\n'
'Some character-oriented interactive commands require\n'
'noecho:\n'
' mininet> noecho h2 vi foo.py\n'
'However, starting up an xterm/gterm is generally better:\n'
' mininet> xterm h2\n\n'
)

The documentation for this class was generated from the following file: