code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def do_xterm( self, line, term='xterm' ):
"""Spawn xterm(s) for the given node(s).
Usage: xterm node1 node2 ..."""
args = line.split()
if not args:
error( 'usage: %s node1 node2 ...\n' % term )
else:
for arg in args:
if arg not in self.m... | Spawn xterm(s) for the given node(s).
Usage: xterm node1 node2 ... | do_xterm | python | mininet/mininet | mininet/cli.py | https://github.com/mininet/mininet/blob/master/mininet/cli.py | BSD-3-Clause |
def do_x( self, line ):
"""Create an X11 tunnel to the given node,
optionally starting a client.
Usage: x node [cmd args]"""
args = line.split()
if not args:
error( 'usage: x node [cmd args]...\n' )
else:
node = self.mn[ args[ 0 ] ]
... | Create an X11 tunnel to the given node,
optionally starting a client.
Usage: x node [cmd args] | do_x | python | mininet/mininet | mininet/cli.py | https://github.com/mininet/mininet/blob/master/mininet/cli.py | BSD-3-Clause |
def do_noecho( self, line ):
"""Run an interactive command with echoing turned off.
Usage: noecho [cmd args]"""
if self.isatty():
quietRun( 'stty -echo' )
self.default( line )
if self.isatty():
quietRun( 'stty echo' ) | Run an interactive command with echoing turned off.
Usage: noecho [cmd args] | do_noecho | python | mininet/mininet | mininet/cli.py | https://github.com/mininet/mininet/blob/master/mininet/cli.py | BSD-3-Clause |
def do_source( self, line ):
"""Read commands from an input file.
Usage: source <file>"""
args = line.split()
if len(args) != 1:
error( 'usage: source <file>\n' )
return
try:
with open( args[ 0 ] ) as self.inputFile:
while Tr... | Read commands from an input file.
Usage: source <file> | do_source | python | mininet/mininet | mininet/cli.py | https://github.com/mininet/mininet/blob/master/mininet/cli.py | BSD-3-Clause |
def do_dpctl( self, line ):
"""Run dpctl (or ovs-ofctl) command on all switches.
Usage: dpctl command [arg1] [arg2] ..."""
args = line.split()
if len(args) < 1:
error( 'usage: dpctl command [arg1] [arg2] ...\n' )
return
for sw in self.mn.switches:
... | Run dpctl (or ovs-ofctl) command on all switches.
Usage: dpctl command [arg1] [arg2] ... | do_dpctl | python | mininet/mininet | mininet/cli.py | https://github.com/mininet/mininet/blob/master/mininet/cli.py | BSD-3-Clause |
def do_time( self, line ):
"Measure time taken for any command in Mininet."
start = time.time()
self.onecmd(line)
elapsed = time.time() - start
self.stdout.write("*** Elapsed time: %0.6f secs\n" % elapsed) | Measure time taken for any command in Mininet. | do_time | python | mininet/mininet | mininet/cli.py | https://github.com/mininet/mininet/blob/master/mininet/cli.py | BSD-3-Clause |
def 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."""
f... | 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. | default | python | mininet/mininet | mininet/cli.py | https://github.com/mininet/mininet/blob/master/mininet/cli.py | BSD-3-Clause |
def waitForNode( self, node ):
"Wait for a node to finish, and print its output."
# Pollers
nodePoller = poll()
nodePoller.register( node.stdout )
bothPoller = poll()
bothPoller.register( self.stdin, POLLIN )
bothPoller.register( node.stdout, POLLIN )
if s... | Wait for a node to finish, and print its output. | waitForNode | python | mininet/mininet | mininet/cli.py | https://github.com/mininet/mininet/blob/master/mininet/cli.py | BSD-3-Clause |
def precmd( self, line ):
"allow for comments in the cli"
if '#' in line:
line = line.split( '#' )[ 0 ]
return line | allow for comments in the cli | precmd | python | mininet/mininet | mininet/cli.py | https://github.com/mininet/mininet/blob/master/mininet/cli.py | BSD-3-Clause |
def isReadable( poller ):
"Check whether a Poll object has a readable fd."
for fdmask in poller.poll( 0 ):
mask = fdmask[ 1 ]
if mask & POLLIN:
return True
return False | Check whether a Poll object has a readable fd. | isReadable | python | mininet/mininet | mininet/cli.py | https://github.com/mininet/mininet/blob/master/mininet/cli.py | BSD-3-Clause |
def __init__( self, name, node=None, port=None, link=None,
mac=None, **params ):
"""name: interface name (e.g. h1-eth0)
node: owning node (where this intf most likely lives)
link: parent link if we're part of a link
other arguments are passed to config()"""
... | name: interface name (e.g. h1-eth0)
node: owning node (where this intf most likely lives)
link: parent link if we're part of a link
other arguments are passed to config() | __init__ | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def cmd( self, *args, **kwargs ):
"Run a command in our owning node"
return self.node.cmd( *args, **kwargs ) | Run a command in our owning node | cmd | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def setMAC( self, macstr ):
"""Set the MAC address for an interface.
macstr: MAC address as string"""
self.mac = macstr
return ( self.ifconfig( 'down' ) +
self.ifconfig( 'hw', 'ether', macstr ) +
self.ifconfig( 'up' ) ) | Set the MAC address for an interface.
macstr: MAC address as string | setMAC | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def updateIP( self ):
"Return updated IP address based on ifconfig"
# use pexec instead of node.cmd so that we dont read
# backgrounded output from the cli.
ifconfig, _err, _exitCode = self.node.pexec(
'ifconfig %s' % self.name )
ips = self._ipMatchRegex.findall( ifco... | Return updated IP address based on ifconfig | updateIP | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def updateMAC( self ):
"Return updated MAC address based on ifconfig"
ifconfig = self.ifconfig()
macs = self._macMatchRegex.findall( ifconfig )
self.mac = macs[ 0 ] if macs else None
return self.mac | Return updated MAC address based on ifconfig | updateMAC | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def updateAddr( self ):
"Return IP address and MAC address based on ifconfig."
ifconfig = self.ifconfig()
ips = self._ipMatchRegex.findall( ifconfig )
macs = self._macMatchRegex.findall( ifconfig )
self.ip = ips[ 0 ] if ips else None
self.mac = macs[ 0 ] if macs else None... | Return IP address and MAC address based on ifconfig. | updateAddr | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def setParam( self, results, method, **param ):
"""Internal method: configure a *single* parameter
results: dict of results to update
method: config method name
param: arg=value (ignore if value=None)
value may also be list or dict"""
name, value = list( param... | Internal method: configure a *single* parameter
results: dict of results to update
method: config method name
param: arg=value (ignore if value=None)
value may also be list or dict | setParam | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def config( self, mac=None, ip=None, ifconfig=None,
up=True, **_params ):
"""Configure Node according to (optional) parameters:
mac: MAC address
ip: IP address
ifconfig: arbitrary interface configuration
Subclasses should override this method and call
... | Configure Node according to (optional) parameters:
mac: MAC address
ip: IP address
ifconfig: arbitrary interface configuration
Subclasses should override this method and call
the parent class's config(**params) | config | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def bwCmds( self, bw=None, speedup=0, use_hfsc=False, use_tbf=False,
latency_ms=None, enable_ecn=False, enable_red=False ):
"Return tc commands to set bandwidth"
cmds, parent = [], ' root '
if bw and ( bw < 0 or bw > self.bwParamMax ):
error( 'Bandwidth limit', bw, ... | Return tc commands to set bandwidth | bwCmds | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def delayCmds( parent, delay=None, jitter=None,
loss=None, max_queue_size=None ):
"Internal method: return tc commands for delay and loss"
cmds = []
if loss and ( loss < 0 or loss > 100 ):
error( 'Bad loss percentage', loss, '%%\n' )
else:
# Del... | Internal method: return tc commands for delay and loss | delayCmds | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def tc( self, cmd, tc='tc' ):
"Execute tc command for our interface"
c = cmd % (tc, self) # Add in tc command and our name
debug(" *** executing command: %s\n" % c)
return self.cmd( c ) | Execute tc command for our interface | tc | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def __init__( self, node1, node2, port1=None, port2=None,
intfName1=None, intfName2=None, addr1=None, addr2=None,
intf=Intf, cls1=None, cls2=None, params1=None,
params2=None, fast=True, **params ):
"""Create veth link to another node, making two new interfac... | Create veth link to another node, making two new interfaces.
node1: first node
node2: second node
port1: node1 port number (optional)
port2: node2 port number (optional)
intf: default interface class/constructor
cls1, cls2: optional interface-specific co... | __init__ | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def intfName( self, node, n ):
"Construct a canonical interface name node-ethN for interface n."
# Leave this as an instance method for now
assert self
return node.name + '-eth' + repr( n ) | Construct a canonical interface name node-ethN for interface n. | intfName | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def makeIntfPair( cls, intfname1, intfname2, addr1=None, addr2=None,
node1=None, node2=None, deleteIntfs=True ):
"""Create pair of interfaces
intfname1: name for interface 1
intfname2: name for interface 2
addr1: MAC address for interface 1 (optional)
... | Create pair of interfaces
intfname1: name for interface 1
intfname2: name for interface 2
addr1: MAC address for interface 1 (optional)
addr2: MAC address for interface 2 (optional)
node1: home node for interface 1 (optional)
node2: home node for interfa... | makeIntfPair | python | mininet/mininet | mininet/link.py | https://github.com/mininet/mininet/blob/master/mininet/link.py | BSD-3-Clause |
def setLogLevel( self, levelname=None ):
"""Setup loglevel.
Convenience function to support lowercase names.
levelName: level name from LEVELS"""
if levelname and levelname not in LEVELS:
print(LEVELS)
raise Exception( 'setLogLevel: unknown levelname %s' % l... | Setup loglevel.
Convenience function to support lowercase names.
levelName: level name from LEVELS | setLogLevel | python | mininet/mininet | mininet/log.py | https://github.com/mininet/mininet/blob/master/mininet/log.py | BSD-3-Clause |
def output( self, msg, *args, **kwargs ):
"""Log 'msg % args' with severity 'OUTPUT'.
To pass exception information, use the keyword argument exc_info
with a true value, e.g.
logger.warning("Houston, we have a %s", "cli output", exc_info=1)
"""
if getattr( self... | Log 'msg % args' with severity 'OUTPUT'.
To pass exception information, use the keyword argument exc_info
with a true value, e.g.
logger.warning("Houston, we have a %s", "cli output", exc_info=1)
| output | python | mininet/mininet | mininet/log.py | https://github.com/mininet/mininet/blob/master/mininet/log.py | BSD-3-Clause |
def makeListCompatible( fn ):
"""Return a new function allowing fn( 'a 1 b' ) to be called as
newfn( 'a', 1, 'b' )"""
def newfn( *args ):
"Generated function. Closure-ish."
if len( args ) == 1:
return fn( *args )
args = ' '.join( str( arg ) for arg in args )
r... | Return a new function allowing fn( 'a 1 b' ) to be called as
newfn( 'a', 1, 'b' ) | makeListCompatible | python | mininet/mininet | mininet/log.py | https://github.com/mininet/mininet/blob/master/mininet/log.py | BSD-3-Clause |
def moduleDeps( subtract=None, add=None ):
"""Handle module dependencies.
subtract: string or list of module names to remove, if already loaded
add: string or list of module names to add, if not already loaded"""
subtract = subtract if subtract is not None else []
add = add if add is not None ... | Handle module dependencies.
subtract: string or list of module names to remove, if already loaded
add: string or list of module names to add, if not already loaded | moduleDeps | python | mininet/mininet | mininet/moduledeps.py | https://github.com/mininet/mininet/blob/master/mininet/moduledeps.py | BSD-3-Clause |
def waitConnected( self, timeout=None, delay=.5 ):
"""wait for each switch to connect to a controller
timeout: time to wait, or None or True to wait indefinitely
delay: seconds to sleep per iteration
returns: True if all switches are connected"""
info( '*** Waiting for s... | wait for each switch to connect to a controller
timeout: time to wait, or None or True to wait indefinitely
delay: seconds to sleep per iteration
returns: True if all switches are connected | waitConnected | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def addHost( self, name, cls=None, **params ):
"""Add host.
name: name of host to add
cls: custom host class/constructor (optional)
params: parameters for host
returns: added host"""
# Default IP and MAC addresses
defaults = { 'ip': ipAdd( self.nextIP,... | Add host.
name: name of host to add
cls: custom host class/constructor (optional)
params: parameters for host
returns: added host | addHost | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def delNode( self, node, nodes=None):
"""Delete node
node: node to delete
nodes: optional list to delete from (e.g. self.hosts)"""
if nodes is None:
nodes = ( self.hosts if node in self.hosts else
( self.switches if node in self.switches else
... | Delete node
node: node to delete
nodes: optional list to delete from (e.g. self.hosts) | delNode | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def addSwitch( self, name, cls=None, **params ):
"""Add switch.
name: name of switch to add
cls: custom switch class/constructor (optional)
returns: added switch
side effect: increments listenPort ivar ."""
defaults = { 'listenPort': self.listenPort,
... | Add switch.
name: name of switch to add
cls: custom switch class/constructor (optional)
returns: added switch
side effect: increments listenPort ivar . | addSwitch | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def addNAT( self, name='nat0', connect=True, inNamespace=False,
**params):
"""Add a NAT to the Mininet network
name: name of NAT node
connect: switch to connect to | True (s1) | None
inNamespace: create in a network namespace
params: other NAT node par... | Add a NAT to the Mininet network
name: name of NAT node
connect: switch to connect to | True (s1) | None
inNamespace: create in a network namespace
params: other NAT node params, notably:
ip: used as default gateway address | addNAT | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def __getitem__( self, key ):
"net[ name ] operator: Return node with given name"
return self.nameToNode[ key ] | net[ name ] operator: Return node with given name | __getitem__ | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def __delitem__( self, key ):
"del net[ name ] operator - delete node with given name"
self.delNode( self.nameToNode[ key ] ) | del net[ name ] operator - delete node with given name | __delitem__ | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def __len__( self ):
"returns number of nodes in net"
return ( len( self.hosts ) + len( self.switches ) +
len( self.controllers ) ) | returns number of nodes in net | __len__ | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def __contains__( self, item ):
"returns True if net contains named node"
return item in self.nameToNode | returns True if net contains named node | __contains__ | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def keys( self ):
"return a list of all node names or net's keys"
return list( self ) | return a list of all node names or net's keys | keys | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def values( self ):
"return a list of all nodes or net's values"
return [ self[name] for name in self ] | return a list of all nodes or net's values | values | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def items( self ):
"return (key,value) tuple list for every node in net"
return zip( self.keys(), self.values() ) | return (key,value) tuple list for every node in net | items | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def randMac():
"Return a random, non-multicast MAC address"
return macColonHex( random.randint(1, 2**48 - 1) & 0xfeffffffffff |
0x020000000000 ) | Return a random, non-multicast MAC address | randMac | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def addLink( self, node1, node2, port1=None, port2=None,
cls=None, **params ):
""""Add a link from node1 to node2
node1: source node (or name)
node2: dest node (or name)
port1: source port (optional)
port2: dest port (optional)
cls: li... | "Add a link from node1 to node2
node1: source node (or name)
node2: dest node (or name)
port1: source port (optional)
port2: dest port (optional)
cls: link class (optional)
params: additional link params (optional)
returns: link object | addLink | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def delLinkBetween( self, node1, node2, index=0, allLinks=False ):
"""Delete link(s) between node1 and node2
index: index of link to delete if multiple links (0)
allLinks: ignore index and delete all such links (False)
returns: deleted link(s)"""
links = self.linksBetwee... | Delete link(s) between node1 and node2
index: index of link to delete if multiple links (0)
allLinks: ignore index and delete all such links (False)
returns: deleted link(s) | delLinkBetween | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def buildFromTopo( self, topo=None ):
"""Build mininet from a topology object
At the end of this function, everything should be connected
and up."""
# Possibly we should clean up here and/or validate
# the topo
if self.cleanup:
pass
info( '*** ... | Build mininet from a topology object
At the end of this function, everything should be connected
and up. | buildFromTopo | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def configureControlNetwork( self ):
"Control net config hook: override in subclass"
raise Exception( 'configureControlNetwork: '
'should be overriden in subclass', self ) | Control net config hook: override in subclass | configureControlNetwork | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def staticArp( self ):
"Add all-pairs ARP entries to remove the need to handle broadcast."
for src in self.hosts:
for dst in self.hosts:
if src != dst:
src.setARP( ip=dst.IP(), mac=dst.MAC() ) | Add all-pairs ARP entries to remove the need to handle broadcast. | staticArp | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def stop( self ):
"Stop the controller(s), switches and hosts"
info( '*** Stopping %i controllers\n' % len( self.controllers ) )
for controller in self.controllers:
info( controller.name + ' ' )
controller.stop()
info( '\n' )
# Unlimit cfs hosts to speed u... | Stop the controller(s), switches and hosts | stop | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def run( self, test, *args, **kwargs ):
"Perform a complete start/test/stop cycle."
self.start()
info( '*** Running test\n' )
result = test( *args, **kwargs )
self.stop()
return result | Perform a complete start/test/stop cycle. | run | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def monitor( self, hosts=None, timeoutms=-1 ):
"""Monitor a set of hosts (or all hosts by default),
and return their output, a line at a time.
hosts: (optional) set of hosts to monitor
timeoutms: (optional) timeout value in ms
returns: iterator which returns host, lin... | Monitor a set of hosts (or all hosts by default),
and return their output, a line at a time.
hosts: (optional) set of hosts to monitor
timeoutms: (optional) timeout value in ms
returns: iterator which returns host, line | monitor | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def _parsePing( pingOutput ):
"Parse ping output and return packets sent, received."
# Check for downed link
if 'connect: Network is unreachable' in pingOutput:
return 1, 0
r = r'(\d+) packets transmitted, (\d+)( packets)? received'
m = re.search( r, pingOutput )
... | Parse ping output and return packets sent, received. | _parsePing | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def ping( self, hosts=None, timeout=None ):
"""Ping between all specified hosts.
hosts: list of hosts
timeout: time to wait for a response, as string
returns: ploss packet loss percentage"""
# should we check if running?
packets = 0
lost = 0
ploss... | Ping between all specified hosts.
hosts: list of hosts
timeout: time to wait for a response, as string
returns: ploss packet loss percentage | ping | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def _parsePingFull( pingOutput ):
"Parse ping output and return all data."
errorTuple = (1, 0, 0, 0, 0, 0)
# Check for downed link
r = r'[uU]nreachable'
m = re.search( r, pingOutput )
if m is not None:
return errorTuple
r = r'(\d+) packets transmitted,... | Parse ping output and return all data. | _parsePingFull | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def pingFull( self, hosts=None, timeout=None ):
"""Ping between all specified hosts and return all data.
hosts: list of hosts
timeout: time to wait for a response, as string
returns: all ping data; see function body."""
# should we check if running?
# Each value ... | Ping between all specified hosts and return all data.
hosts: list of hosts
timeout: time to wait for a response, as string
returns: all ping data; see function body. | pingFull | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def pingPair( self ):
"""Ping between first two hosts, useful for testing.
returns: ploss packet loss percentage"""
hosts = [ self.hosts[ 0 ], self.hosts[ 1 ] ]
return self.ping( hosts=hosts ) | Ping between first two hosts, useful for testing.
returns: ploss packet loss percentage | pingPair | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def _iperfVals( iperfcsv, serverip ):
"""Return iperf CSV as dict
iperfcsv: iperf -y C output
serverip: iperf server IP address
"""
fields = 'date cip cport sip sport ipver interval sent rate'
lines = iperfcsv.strip().split('\n')
svals = {}
for line ... | Return iperf CSV as dict
iperfcsv: iperf -y C output
serverip: iperf server IP address
| _iperfVals | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def configLinkStatus( self, src, dst, status ):
"""Change status of src <-> dst links.
src: node name
dst: node name
status: string {up, down}"""
if src not in self.nameToNode:
error( 'src not in network: %s\n' % src )
elif dst not in self.nameToNode:... | Change status of src <-> dst links.
src: node name
dst: node name
status: string {up, down} | configLinkStatus | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def interact( self ):
"Start network and run our simple CLI."
self.start()
result = CLI( self )
self.stop()
return result | Start network and run our simple CLI. | interact | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def configureRoutedControlNetwork( self, ip='192.168.123.1',
prefixLen=16 ):
"""Configure a routed control network on controller and switches.
For use with the user datapath only right now."""
controller = self.controllers[ 0 ]
info( controller.n... | Configure a routed control network on controller and switches.
For use with the user datapath only right now. | configureRoutedControlNetwork | python | mininet/mininet | mininet/net.py | https://github.com/mininet/mininet/blob/master/mininet/net.py | BSD-3-Clause |
def __init__( self, name, inNamespace=True, **params ):
"""name: name of node
inNamespace: in network namespace?
privateDirs: list of private directory strings or tuples
params: Node parameters (see config() for details)"""
# Make sure class actually works
self.... | name: name of node
inNamespace: in network namespace?
privateDirs: list of private directory strings or tuples
params: Node parameters (see config() for details) | __init__ | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def fdToNode( cls, fd ):
"""Return node corresponding to given file descriptor.
fd: file descriptor
returns: node"""
node = cls.outToNode.get( fd )
return node or cls.inToNode.get( fd ) | Return node corresponding to given file descriptor.
fd: file descriptor
returns: node | fdToNode | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def _popen( self, cmd, **params ):
"""Internal method: spawn and return a process
cmd: command to run (list)
params: parameters to Popen()"""
# Leave this is as an instance method for now
assert self
popen = Popen( cmd, **params ) # pylint: disable=consider-using... | Internal method: spawn and return a process
cmd: command to run (list)
params: parameters to Popen() | _popen | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def read( self, size=1024 ):
"""Buffered read from node, potentially blocking.
size: maximum number of characters to return"""
count = len( self.readbuf )
if count < size:
data = os.read( self.stdout.fileno(), size - count )
self.readbuf += self.decoder.decode(... | Buffered read from node, potentially blocking.
size: maximum number of characters to return | read | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def readline( self ):
"""Buffered readline from node, potentially blocking.
returns: line (minus newline) or None"""
self.readbuf += self.read( 1024 )
if '\n' not in self.readbuf:
return None
pos = self.readbuf.find( '\n' )
line = self.readbuf[ 0: pos ]
... | Buffered readline from node, potentially blocking.
returns: line (minus newline) or None | readline | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def terminate( self ):
"Send kill signal to Node and clean up after it."
self.unmountPrivateDirs()
if self.shell:
if self.shell.poll() is None:
os.killpg( self.shell.pid, signal.SIGHUP )
self.cleanup() | Send kill signal to Node and clean up after it. | terminate | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def waitReadable( self, timeoutms=None ):
"""Wait until node's output is readable.
timeoutms: timeout in ms or None to wait indefinitely.
returns: result of poll()"""
if len( self.readbuf ) == 0:
return self.pollOut.poll( timeoutms )
return None | Wait until node's output is readable.
timeoutms: timeout in ms or None to wait indefinitely.
returns: result of poll() | waitReadable | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def sendCmd( self, *args, **kwargs ):
"""Send a command, followed by a command to echo a sentinel,
and return without waiting for the command to complete.
args: command and arguments, or string
printPid: print command's PID? (False)"""
assert self.shell and not self.wait... | Send a command, followed by a command to echo a sentinel,
and return without waiting for the command to complete.
args: command and arguments, or string
printPid: print command's PID? (False) | sendCmd | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def monitor( self, timeoutms=None, findPid=True ):
"""Monitor and return the output of a command.
Set self.waiting to False if command has completed.
timeoutms: timeout in ms or None to wait indefinitely
findPid: look for PID from mnexec -p"""
ready = self.waitReadable( ... | Monitor and return the output of a command.
Set self.waiting to False if command has completed.
timeoutms: timeout in ms or None to wait indefinitely
findPid: look for PID from mnexec -p | monitor | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def waitOutput( self, verbose=False, findPid=True ):
"""Wait for a command to complete.
Completion is signaled by a sentinel character, ASCII(127)
appearing in the output stream. Wait for the sentinel and return
the output, including trailing newline.
verbose: print ... | Wait for a command to complete.
Completion is signaled by a sentinel character, ASCII(127)
appearing in the output stream. Wait for the sentinel and return
the output, including trailing newline.
verbose: print output interactively | waitOutput | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def cmd( self, *args, **kwargs ):
"""Send a command, wait for output, and return it.
cmd: string"""
verbose = kwargs.get( 'verbose', False )
log = info if verbose else debug
log( '*** %s : %s\n' % ( self.name, args ) )
if self.shell:
self.sendCmd( *args, **... | Send a command, wait for output, and return it.
cmd: string | cmd | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def popen( self, *args, **kwargs ):
"""Return a Popen() object in our namespace
args: Popen() args, single list, or string
kwargs: Popen() keyword args"""
defaults = { 'stdout': PIPE, 'stderr': PIPE,
'mncmd':
[ 'mnexec', '-da', str( self.pi... | Return a Popen() object in our namespace
args: Popen() args, single list, or string
kwargs: Popen() keyword args | popen | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def pexec( self, *args, **kwargs ):
"""Execute a command using popen
returns: out, err, exitcode"""
popen = self.popen( *args, stdin=PIPE, stdout=PIPE, stderr=PIPE,
**kwargs )
# Warning: this can fail with large numbers of fds!
out, err = popen.comm... | Execute a command using popen
returns: out, err, exitcode | pexec | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def newPort( self ):
"Return the next port number to allocate."
if len( self.ports ) > 0:
return max( self.ports.values() ) + 1
return self.portBase | Return the next port number to allocate. | newPort | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def addIntf( self, intf, port=None, moveIntfFn=moveIntf ):
"""Add an interface.
intf: interface
port: port number (optional, typically OpenFlow port number)
moveIntfFn: function to move interface (optional)"""
if port is None:
port = self.newPort()
se... | Add an interface.
intf: interface
port: port number (optional, typically OpenFlow port number)
moveIntfFn: function to move interface (optional) | addIntf | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def delIntf( self, intf ):
"""Remove interface from Node's known interfaces
Note: to fully delete interface, call intf.delete() instead"""
port = self.ports.get( intf )
if port is not None:
del self.intfs[ port ]
del self.ports[ intf ]
del self.name... | Remove interface from Node's known interfaces
Note: to fully delete interface, call intf.delete() instead | delIntf | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def intf( self, intf=None ):
"""Return our interface object with given string name,
default intf if name is falsy (None, empty string, etc).
or the input intf arg.
Having this fcn return its arg for Intf objects makes it
easier to construct functions with flexible input ar... | Return our interface object with given string name,
default intf if name is falsy (None, empty string, etc).
or the input intf arg.
Having this fcn return its arg for Intf objects makes it
easier to construct functions with flexible input args for
interfaces (those that ac... | intf | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def connectionsTo( self, node):
"Return [ intf1, intf2... ] for all intfs that connect self to node."
# We could optimize this if it is important
connections = []
for intf in self.intfList():
link = intf.link
if link:
node1, node2 = link.intf1.node... | Return [ intf1, intf2... ] for all intfs that connect self to node. | connectionsTo | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def deleteIntfs( self, checkName=True ):
"""Delete all of our interfaces.
checkName: only delete interfaces that contain our name"""
# In theory the interfaces should go away after we shut down.
# However, this takes time, so we're better off removing them
# explicitly so that... | Delete all of our interfaces.
checkName: only delete interfaces that contain our name | deleteIntfs | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def setDefaultRoute( self, intf=None ):
"""Set the default route to go through intf.
intf: Intf or {dev <intfname> via <gw-ip> ...}"""
# Note setParam won't call us if intf is none
if isinstance( intf, BaseString ) and ' ' in intf:
params = intf
else:
p... | Set the default route to go through intf.
intf: Intf or {dev <intfname> via <gw-ip> ...} | setDefaultRoute | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def IP( self, intf=None ):
"Return IP address of a node or specific interface."
return self.intf( intf ).IP() | Return IP address of a node or specific interface. | IP | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def MAC( self, intf=None ):
"Return MAC address of a node or specific interface."
return self.intf( intf ).MAC() | Return MAC address of a node or specific interface. | MAC | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def intfIsUp( self, intf=None ):
"Check if an interface is up."
return self.intf( intf ).isUp() | Check if an interface is up. | intfIsUp | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def config( self, mac=None, ip=None,
defaultRoute=None, lo='up', **_params ):
"""Configure Node according to (optional) parameters:
mac: MAC address for default interface
ip: IP address for default interface
ifconfig: arbitrary interface configuration
... | Configure Node according to (optional) parameters:
mac: MAC address for default interface
ip: IP address for default interface
ifconfig: arbitrary interface configuration
Subclasses should override this method and call
the parent class's config(**params) | config | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def intfList( self ):
"List of our interfaces sorted by port number"
return [ self.intfs[ p ] for p in sorted( self.intfs.keys() ) ] | List of our interfaces sorted by port number | intfList | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def intfNames( self ):
"The names of our interfaces sorted by port number"
return [ str( i ) for i in self.intfList() ] | The names of our interfaces sorted by port number | intfNames | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def checkSetup( cls ):
"Make sure our class and superclasses are set up"
clas = cls
while clas and not getattr( clas, 'isSetup', True ):
clas.setup()
clas.isSetup = True
# Make pylint happy
clas = getattr( type( clas ), '__base__', None ) | Make sure our class and superclasses are set up | checkSetup | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def setup( cls ):
"Make sure our class dependencies are available"
pathCheck( 'mnexec', 'ifconfig', moduleName='Mininet') | Make sure our class dependencies are available | setup | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def cgroupSet( self, param, value, resource='cpu' ):
"Set a cgroup parameter and return its value"
cmd = [ 'cgset', '-r', "%s.%s=%s" % (
resource, param, value), '/' + self.name ]
errFail( cmd )
nvalue = self.cgroupGet( param, resource )
if nvalue != str( value ):
... | Set a cgroup parameter and return its value | cgroupSet | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def popen( self, *args, **kwargs ):
"""Return a Popen() object in node's namespace
args: Popen() args, single list, or string
kwargs: Popen() keyword args"""
# Tell mnexec to execute command in our cgroup
mncmd = kwargs.pop( 'mncmd', [ 'mnexec', '-g', self.name,
... | Return a Popen() object in node's namespace
args: Popen() args, single list, or string
kwargs: Popen() keyword args | popen | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def cleanup( self ):
"Clean up Node, then clean up our cgroup"
super( CPULimitedHost, self ).cleanup()
retry( retries=3, delaySecs=.1, fn=self.cgroupDel ) | Clean up Node, then clean up our cgroup | cleanup | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def checkRtGroupSched( cls ):
"Check (Ubuntu,Debian) kernel config for CONFIG_RT_GROUP_SCHED for RT"
if not cls._rtGroupSched:
release = quietRun( 'uname -r' ).strip('\r\n')
output = quietRun( 'grep CONFIG_RT_GROUP_SCHED /boot/config-%s' %
release )... | Check (Ubuntu,Debian) kernel config for CONFIG_RT_GROUP_SCHED for RT | checkRtGroupSched | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def rtInfo( self, f ):
"Internal method: return parameters for RT bandwidth"
pstr, qstr = 'rt_period_us', 'rt_runtime_us'
# RT uses wall clock time for period and quota
quota = int( self.period_us * f )
return pstr, qstr, self.period_us, quota | Internal method: return parameters for RT bandwidth | rtInfo | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def cfsInfo( self, f ):
"Internal method: return parameters for CFS bandwidth"
pstr, qstr = 'cfs_period_us', 'cfs_quota_us'
if self.cgversion == 'cgroup2':
pstr, qstr = 'max', ''
# CFS uses wall clock time for period and CPU time for quota.
quota = int( self.period_us... | Internal method: return parameters for CFS bandwidth | cfsInfo | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def setCPUs( self, cores, mems=0 ):
"Specify (real) cores that our cgroup can run on"
if not cores:
return
if isinstance( cores, list ):
cores = ','.join( [ str( c ) for c in cores ] )
self.cgroupSet( resource='cpuset', param='cpus',
value=... | Specify (real) cores that our cgroup can run on | setCPUs | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def config( self, cpu=-1, cores=None, **params ):
"""cpu: desired overall system CPU fraction
cores: (real) core(s) this host can run on
params: parameters for Node.config()"""
r = Node.config( self, **params )
self.initCgroups()
# Was considering cpu={'cpu': cpu , ... | cpu: desired overall system CPU fraction
cores: (real) core(s) this host can run on
params: parameters for Node.config() | config | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def __init__( self, name, dpid=None, opts='', listenPort=None, **params):
"""dpid: dpid hex string (or None to derive from name, e.g. s1 -> 1)
opts: additional switch options
listenPort: port to listen on for dpctl connections"""
Node.__init__( self, name, **params )
self.d... | dpid: dpid hex string (or None to derive from name, e.g. s1 -> 1)
opts: additional switch options
listenPort: port to listen on for dpctl connections | __init__ | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def defaultDpid( self, dpid=None ):
"Return correctly formatted dpid from dpid or switch name (s1 -> 1)"
if dpid:
# Remove any colons and make sure it's a good hex number
dpid = dpid.replace( ':', '' )
assert len( dpid ) <= self.dpidLen and int( dpid, 16 ) >= 0
... | Return correctly formatted dpid from dpid or switch name (s1 -> 1) | defaultDpid | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def sendCmd( self, *cmd, **kwargs ):
"""Send command to Node.
cmd: string"""
kwargs.setdefault( 'printPid', False )
if not self.execed:
return Node.sendCmd( self, *cmd, **kwargs )
else:
error( '*** Error: %s has execed and cannot accept commands' %
... | Send command to Node.
cmd: string | sendCmd | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def connected( self ):
"Is the switch connected to a controller? (override this method)"
# Assume that we are connected by default to whatever we need to
# be connected to. This should be overridden by any OpenFlow
# switch, but not by a standalone bridge.
debug( 'Assuming', repr... | Is the switch connected to a controller? (override this method) | connected | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def __init__( self, name, dpopts='--no-slicing', **kwargs ):
"""Init.
name: name for the switch
dpopts: additional arguments to ofdatapath (--no-slicing)"""
Switch.__init__( self, name, **kwargs )
pathCheck( 'ofdatapath', 'ofprotocol',
moduleName='the Ope... | Init.
name: name for the switch
dpopts: additional arguments to ofdatapath (--no-slicing) | __init__ | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
def setup( cls ):
"Ensure any dependencies are loaded; if not, try to load them."
if not os.path.exists( '/dev/net/tun' ):
moduleDeps( add=TUN ) | Ensure any dependencies are loaded; if not, try to load them. | setup | python | mininet/mininet | mininet/node.py | https://github.com/mininet/mininet/blob/master/mininet/node.py | BSD-3-Clause |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.