Package TestON :: Package drivers :: Package common :: Package cli :: Package emulator :: Module mininetclidriver :: Class MininetCliDriver
[hide private]
[frames] | no frames]

Class MininetCliDriver

source code


MininetCliDriver is the basic driver which will handle the Mininet functions

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
connect(self, **connectargs)
Here the main is the TestON instance after creating all the log handles.
source code
 
startNet(self, topoFile='', args='', mnCmd='', timeout=120)
Description: Starts Mininet accepts a topology(.py) file and/or an optional argument, to start the mininet, as a parameter.
source code
 
numSwitchesNlinks(self, topoType, depth, fanout) source code
 
calculateSwAndLinks(self)
Calculate the number of switches and links in a topo.
source code
 
pingall(self, timeout=300, shortCircuit=False, acceptableFailed=0)
Verifies the reachability of the hosts using pingall command.
source code
 
fpingHost(self, **pingParams)
Uses the fping package for faster pinging...
source code
 
pingallHosts(self, hostList)
Ping all specified IPv4 hosts
source code
 
pingIpv6Hosts(self, hostList, prefix='1000::')
IPv6 ping all hosts in hostList.
source code
 
pingHost(self, **pingParams)
Ping from one mininet host to another Currently the only supported Params: SRC and TARGET
source code
 
checkIP(self, host)
Verifies the host's ip configured or not.
source code
 
verifySSH(self, **connectargs) source code
 
moveHost(self, host, oldSw, newSw)
Moves a host from one switch to another on the fly Note: The intf between host and oldSw when detached using detach(), will still show up in the 'net' cmd, because switch.detach() doesn't affect switch.intfs[] ( which is correct behavior since the interfaces haven't moved ).
source code
 
changeIP(self, host, intf, newIP, newNetmask)
Changes the ip address of a host on the fly Ex: h2 ifconfig h2-eth0 10.0.1.2 netmask 255.255.255.0
source code
 
changeDefaultGateway(self, host, newGW)
Changes the default gateway of a host Ex: h1 route add default gw 10.0.1.2
source code
 
addStaticMACAddress(self, host, GW, macaddr)
Changes the mac address of a gateway host
source code
 
verifyStaticGWandMAC(self, host)
Verify if the static gateway and mac address assignment
source code
 
getMacAddress(self, host)
Verifies the host's ip configured or not.
source code
 
getInterfaceMACAddress(self, host, interface)
Return the IP address of the interface on the given host
source code
 
getIPAddress(self, host)
Verifies the host's ip configured or not.
source code
 
getSwitchDPID(self, switch)
return the datapath ID of the switch
source code
 
getDPID(self, switch) source code
 
getInterfaces(self, node)
return information dict about interfaces connected to the node
source code
 
dump(self) source code
 
intfs(self) source code
 
net(self) source code
 
links(self) source code
 
iperftcpAll(self, hosts, timeout=6)
Runs the iperftcp function with a given set of hosts and specified timeout.
source code
 
iperftcp(self, host1="h1", host2="h2", timeout=6)
Creates an iperf TCP test between two hosts.
source code
 
iperfudpAll(self, hosts, bandwidth="10M")
Runs the iperfudp function with a given set of hosts and specified bandwidth
source code
 
iperfudp(self, bandwidth="10M", host1="h1", host2="h2")
Creates an iperf UDP test with a specific bandwidth.
source code
 
nodes(self) source code
 
pingpair(self) source code
 
link(self, **linkargs)
Bring link( s ) between two nodes up or down
source code
 
yank(self, **yankargs)
yank a mininet switch interface to a host
source code
 
plug(self, **plugargs)
plug the yanked mininet switch interface to a switch
source code
 
dpctl(self, **dpctlargs)
Run dpctl command on all switches.
source code
 
getVersion(self) source code
 
getSwController(self, sw)
Parameters: sw: The name of an OVS switch.
source code
 
assignSwController(self, sw, ip, port="6633", ptcp="")
Description: Assign switches to the controllers ( for ovs use only ) Required: sw - Name of the switch.
source code
 
deleteSwController(self, sw)
Removes the controller target from sw
source code
 
addSwitch(self, sw, **kwargs)
adds a switch to the mininet topology NOTE: This uses a custom mn function.
source code
 
delSwitch(self, sw)
delete a switch from the mininet topology NOTE: This uses a custom mn function.
source code
 
addLink(self, node1, node2)
add a link to the mininet topology NOTE: This uses a custom mn function.
source code
 
delLink(self, node1, node2)
delete a link from the mininet topology NOTE: This uses a custom mn function.
source code
 
addHost(self, hostname, **kwargs)
Add a host to the mininet topology NOTE: This uses a custom mn function.
source code
 
delHost(self, hostname)
delete a host from the mininet topology NOTE: This uses a custom mn function.
source code
 
disconnect(self)
Called at the end of the test to stop the mininet and disconnect the handle.
source code
 
stopNet(self, fileName="", timeout=5)
Stops mininet.
source code
 
arping(self, host="", ip="10.128.20.211", ethDevice="")
Description: Sends arp message from mininet host for hosts discovery Required: host - hosts name Optional: ip - ip address that does not exist in the network so there would be no reply.
source code
 
decToHex(self, num) source code
 
getSwitchFlowCount(self, switch)
return the Flow Count of the switch
source code
 
checkFlows(self, sw, dumpFormat=None) source code
 
getFlowTable(self, protoVersion, sw)
Returns certain fields of an OVS flow table.
source code
 
flowComp(self, flow1, flow2) source code
 
startTcpdump(self, filename, intf="eth0", port="port 6633")
Runs tpdump on an interface and saves the file intf can be specified, or the default eth0 is used
source code
 
stopTcpdump(self)
pkills tcpdump
source code
 
getPorts(self, nodeName, verbose=False)
Read ports from a Mininet switch.
source code
 
getSwitches(self, verbose=False)
Read switches from Mininet.
source code
 
getHosts(self, verbose=False)
Read hosts from Mininet.
source code
 
getLinks(self)
Gathers information about current Mininet links.
source code
 
compareSwitches(self, switches, switchesJson, portsJson)
Compare mn and onos switches switchesJson: parsed json object from the onos devices api
source code
 
compareLinks(self, switches, links, linksJson)
Compare mn and onos links linksJson: parsed json object from the onos links api
source code
 
compareHosts(self, hosts, hostsJson)
Compare mn and onos Hosts.
source code
 
getHostsOld(self)
Returns a list of all hosts Don't ask questions just use it
source code
 
getSwitch(self)
Returns a list of all switches Again, don't ask question just use it...
source code
 
update(self)
updates the port address and status information for each port in mn
source code
 
assignVLAN(self, host, intf, vlan)
Add vlan tag to a host.
source code
 
execute(self, **execparams)
It facilitates the command line execution of a given command. (Inherited from TestON.drivers.common.clidriver.CLI)
source code
 
onfail(self) (Inherited from TestON.drivers.common.clidriver.CLI) source code
 
remove_contol_chars(self, response) (Inherited from TestON.drivers.common.clidriver.CLI) source code
 
runAsSudoUser(self, handle, pwd, default) (Inherited from TestON.drivers.common.clidriver.CLI) source code
 
secureCopy(self, user_name, ip_address, filepath, pwd, dst_path)
Connection will establish to the remote host using ssh. (Inherited from TestON.drivers.common.clidriver.CLI)
source code

Inherited from component.Component: __getattr__, cleanup, close_log_handles, config, experimentRun, get_version, log

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

connect(self, **connectargs)

source code 

Here the main is the TestON instance after creating all the log handles.

Overrides: component.Component.connect

startNet(self, topoFile='', args='', mnCmd='', timeout=120)

source code 

Description:
    Starts Mininet accepts a topology(.py) file and/or an optional
    argument, to start the mininet, as a parameter.
    Can also send regular mininet command to load up desired topology.
    Eg. Pass in a string 'sudo mn --topo=tree,3,3' to mnCmd
Options:
    topoFile = file path for topology file (.py)
    args = extra option added when starting the topology from the file
    mnCmd = Mininet command use to start topology
Returns:
        main.TRUE if the mininet starts successfully, main.FALSE
        otherwise

pingall(self, timeout=300, shortCircuit=False, acceptableFailed=0)

source code 

Verifies the reachability of the hosts using pingall command.
Optional parameter timeout allows you to specify how long to
wait for pingall to complete
Optional:
timeout( seconds ) - How long to wait before breaking the pingall
shortCircuit - Break the pingall based on the number of failed hosts
               ping
acceptableFailed - Set the number of acceptable failed pings for the
                   function to still return main.TRUE
Returns:
main.TRUE if pingall completes with no pings dropped
otherwise main.FALSE

fpingHost(self, **pingParams)

source code 

Uses the fping package for faster pinging... *requires fping to be installed on machine running mininet

pingallHosts(self, hostList)

source code 

Ping all specified IPv4 hosts

Acceptable hostList:

  • [ 'h1','h2','h3','h4' ]

Returns main.TRUE if all hosts specified can reach each other

Returns main.FALSE if one or more of hosts specified cannot reach each other

pingIpv6Hosts(self, hostList, prefix='1000::')

source code 

IPv6 ping all hosts in hostList. If no prefix passed this will use default prefix of 1000:


Returns main.TRUE if all hosts specified can reach each other

Returns main.FALSE if one or more of hosts specified cannot reach each other

iperftcpAll(self, hosts, timeout=6)

source code 

Runs the iperftcp function with a given set of hosts and specified timeout.

@parm:
    timeout: The defualt timeout is 6 sec to allow enough time for a successful test to complete,
     and short enough to stop an unsuccessful test from quiting and cleaning up mininet.

iperftcp(self, host1="h1", host2="h2", timeout=6)

source code 

Creates an iperf TCP test between two hosts. Returns main.TRUE if test results
are valid.

@parm:
    timeout: The defualt timeout is 6 sec to allow enough time for a successful test to complete,
     and short enough to stop an unsuccessful test from quiting and cleaning up mininet.

iperfudp(self, bandwidth="10M", host1="h1", host2="h2")

source code 

Creates an iperf UDP test with a specific bandwidth. Returns true if results are valid.

getSwController(self, sw)

source code 

Parameters:
    sw: The name of an OVS switch. Example "s1"
Return:
    The output of the command from the mininet cli
    or main.FALSE on timeout

assignSwController(self, sw, ip, port="6633", ptcp="")

source code 

Description:
    Assign switches to the controllers ( for ovs use only )
Required:
    sw - Name of the switch. This can be a list or a string.
    ip - Ip addresses of controllers. This can be a list or a string.
Optional:
    port - ONOS use port 6633, if no list of ports is passed, then
           the all the controller will use 6633 as their port number
    ptcp - ptcp number, This can be a string or a list that has
           the same length as switch. This is optional and not required
           when using ovs switches.
NOTE: If switches and ptcp are given in a list type they should have the
      same length and should be in the same order, Eg. sw=[ 's1' ... n ]
      ptcp=[ '6637' ... n ], s1 has ptcp number 6637 and so on.

Return:
    Returns main.TRUE if mininet correctly assigned switches to
    controllers, otherwise it will return main.FALSE or an appropriate
    exception(s)

addSwitch(self, sw, **kwargs)

source code 

adds a switch to the mininet topology
NOTE: This uses a custom mn function. MN repo should be on
    dynamic_topo branch
NOTE: cannot currently specify what type of switch
required params:
    sw = name of the new switch as a string
optional keywords:
    dpid = "dpid"
returns: main.FALSE on an error, else main.TRUE

delSwitch(self, sw)

source code 

delete a switch from the mininet topology
NOTE: This uses a custom mn function. MN repo should be on
    dynamic_topo branch
required params:
    sw = name of the switch as a string
returns: main.FALSE on an error, else main.TRUE

addLink(self, node1, node2)

source code 

add a link to the mininet topology
NOTE: This uses a custom mn function. MN repo should be on
     dynamic_topo branch
NOTE: cannot currently specify what type of link
required params:
node1 = the string node name of the first endpoint of the link
node2 = the string node name of the second endpoint of the link
returns: main.FALSE on an error, else main.TRUE

delLink(self, node1, node2)

source code 

delete a link from the mininet topology
NOTE: This uses a custom mn function. MN repo should be on
     dynamic_topo branch
required params:
node1 = the string node name of the first endpoint of the link
node2 = the string node name of the second endpoint of the link
returns: main.FALSE on an error, else main.TRUE

addHost(self, hostname, **kwargs)

source code 

Add a host to the mininet topology
NOTE: This uses a custom mn function. MN repo should be on
    dynamic_topo branch
NOTE: cannot currently specify what type of host
required params:
    hostname = the string hostname
optional key-value params
    switch = "switch name"
    returns: main.FALSE on an error, else main.TRUE

delHost(self, hostname)

source code 

delete a host from the mininet topology
NOTE: This uses a custom mn function. MN repo should be on
    dynamic_topo branch
NOTE: this uses a custom mn function
required params:
hostname = the string hostname
returns: main.FALSE on an error, else main.TRUE

disconnect(self)

source code 

Called at the end of the test to stop the mininet and disconnect the handle.

Overrides: component.Component.disconnect

stopNet(self, fileName="", timeout=5)

source code 

Stops mininet.
Returns main.TRUE if the mininet successfully stops and
        main.FALSE if the pexpect handle does not exist.

Will cleanup and exit the test if mininet fails to stop

getFlowTable(self, protoVersion, sw)

source code 

Returns certain fields of an OVS flow table. Will force output to
either OF 1.0 or 1.3 format for consistency.

TODO add option to look at cookies. ignoring them for now

 NOTE: Use format to force consistent flow table output across
 versions

getPorts(self, nodeName, verbose=False)

source code 

Read ports from a Mininet switch.

Returns a json structure containing information about the ports of the given switch.

getSwitches(self, verbose=False)

source code 

Read switches from Mininet.

Returns a dictionary whose keys are the switch names and the value is a dictionary containing information about the switch.

getHosts(self, verbose=False)

source code 

Read hosts from Mininet.

Returns a dictionary whose keys are the host names and the value is a dictionary containing information about the host.

getLinks(self)

source code 

Gathers information about current Mininet links. These links may not
be up if one of the ports is down.

Returns a list of dictionaries with link endpoints.

The dictionary structure is:
    { 'node1': str( node1 name )
      'node2': str( node2 name )
      'port1': str( port1 of_port )
      'port2': str( port2 of_port ) }
Note: The port number returned is the eth#, not necessarily the of_port
      number. In Mininet, for OVS switch, these should be the same. For
      hosts, this is just the eth#.

compareSwitches(self, switches, switchesJson, portsJson)

source code 

   Compare mn and onos switches
   switchesJson: parsed json object from the onos devices api

Dependencies:
    1. numpy - "sudo pip install numpy"

compareHosts(self, hosts, hostsJson)

source code 

Compare mn and onos Hosts.
Since Mininet hosts are quiet, ONOS will only know of them when they
speak. For this reason, we will only check that the hosts in ONOS
stores are in Mininet, and not vice versa.

Arguments:
    hostsJson: parsed json object from the onos hosts api
Returns:

assignVLAN(self, host, intf, vlan)

source code 

Add vlan tag to a host.
Dependencies:
    This class depends on the "vlan" package
    $ sudo apt-get install vlan
Configuration:
    Load the 8021q module into the kernel
    $sudo modprobe 8021q

    To make this setup permanent:
    $ sudo su -c 'echo "8021q" >> /etc/modules'