Package TestON :: Package drivers :: Package common :: Package cli :: Module onosdriver :: Class OnosDriver
[hide private]
[frames] | no frames]

Class OnosDriver

source code


Instance Methods [hide private]
 
__init__(self)
Initialize client
source code
 
connect(self, **connectargs)
Creates ssh handle for ONOS "bench".
source code
 
disconnect(self)
Called when Test is complete to disconnect the ONOS handle.
source code
 
getEpochMs(self)
Returns milliseconds since epoch
source code
 
onosPackage(self, opTimeout=30)
Produce a self-contained tar.gz file that can be deployed and executed on any platform with Java 7 JRE.
source code
 
onosBuild(self)
Use the pre defined script to build onos via mvn
source code
 
cleanInstall(self, skipTest=False, mciTimeout=600)
Runs mvn clean install in the root of the ONOS directory.
source code
 
gitPull(self, comp1="", fastForward=True)
Assumes that "git pull" works without login
source code
 
gitCheckout(self, branch="master")
Assumes that "git pull" works without login
source code
 
getBranchName(self) source code
 
getVersion(self, report=False)
Writes the COMMIT number to the report to be parsed by Jenkins data collector.
source code
 
createCellFile(self, benchIp, fileName, mnIpAddrs, appString, onosIpAddrs)
Creates a cell file based on arguments Required: * Bench IP address ( benchIp ) - Needed to copy the cell file over * File name of the cell file ( fileName ) * Mininet IP address ( mnIpAddrs ) - Note that only 1 ip address is supported currently * ONOS IP addresses ( onosIpAddrs ) - Must be passed in as last arguments
source code
 
setCell(self, cellname)
Calls 'cell <name>' to set the environment variables on ONOSbench
source code
 
verifyCell(self)
Calls 'onos-verify-cell' to check for cell installation
source code
 
onosCfgSet(self, ONOSIp, configName, configParam)
Uses 'onos <node-ip> cfg set' to change a parameter value of an application.
source code
 
onosCli(self, ONOSIp, cmdstr)
Uses 'onos' command to send various ONOS CLI arguments.
source code
 
onosInstall(self, options="-f", node="")
Installs ONOS bits on the designated cell machine.
source code
 
onosStart(self, nodeIp)
Calls onos command: 'onos-service [<node-ip>] start' This command is a remote management of the ONOS upstart daemon
source code
 
onosStop(self, nodeIp)
Calls onos command: 'onos-service [<node-ip>] stop' This command is a remote management of the ONOS upstart daemon
source code
 
onosUninstall(self, nodeIp="")
Calls the command: 'onos-uninstall' Uninstalls ONOS from the designated cell machine, stopping if needed
source code
 
onosDie(self, nodeIp)
Issues the command 'onos-die <node-ip>' This command calls onos-kill and also stops the node
source code
 
onosKill(self, nodeIp)
Calls the command: 'onos-kill [<node-ip>]' "Remotely, and unceremoniously kills the ONOS instance running on the specified cell machine" - Tom V
source code
 
onosRemoveRaftLogs(self)
Removes Raft / Copy cat files from ONOS to ensure a cleaner environment.
source code
 
onosStartNetwork(self, mntopo)
Calls the command 'onos-start-network [ <mininet-topo> ] "remotely starts the specified topology on the cell's mininet machine against all controllers configured in the cell." * Specify mininet topology file name for mntopo * Topo files should be placed at: ~/<your-onos-directory>/tools/test/topos
source code
 
isup(self, node="", timeout=120)
Run's onos-wait-for-start which only returns once ONOS is at run level 100(ready for use)
source code
 
pushTestIntentsShell(self, dpidSrc, dpidDst, numIntents, dirFile, onosIp, numMult="", appId="", report=True, options="")
Description:...
source code
 
getTopology(self, topologyOutput)
Definition:...
source code
 
checkStatus(self, topologyResult, numoswitch, numolink, logLevel="info")
Checks the number of switches & links that ONOS sees against the supplied values.
source code
 
tsharkPcap(self, interface, dirFile)
Capture all packet activity and store in specified directory/file
source code
 
runOnosTopoCfg(self, instanceName, jsonFile)
On ONOS bench, run this command: {ONOS_HOME}/tools/test/bin/onos-topo-cfg $OC1 filename which starts the rest and copies the json file to the onos instance
source code
 
tsharkGrep(self, grep, directory, interface='eth0', grepOptions='')
Required: * grep string * directory to store results Optional: * interface - default: eth0 * grepOptions - options for grep Description: Uses tshark command to grep specific group of packets and stores the results to specified directory.
source code
 
tsharkStop(self)
Removes wireshark files from /tmp and kills all tshark processes
source code
 
ptpd(self, args)
Initiate ptp with user-specified args.
source code
 
cpLogsToDir(self, logToCopy, destDir, copyFileName="")
Copies logs to a desired directory.
source code
 
checkLogs(self, onosIp, restart=False)
runs onos-check-logs on the given onos node...
source code
 
onosStatus(self, node="")
Calls onos command: 'onos-service [<node-ip>] status'
source code
 
setIpTables(self, ip, port='', action='add', packet_type='', direction='INPUT', rule='DROP', states=True)
Description: add or remove iptables rule to DROP (default) packets from specific IP and PORT Usage: * specify action ('add' or 'remove') when removing, pass in the same argument as you would add.
source code
 
detailed_status(self, log_filename)
This method is used by STS to check the status of the controller Reports RUNNING, STARTING, STOPPED, FROZEN, ERROR (and reason)
source code
 
createLinkGraphFile(self, benchIp, ONOSIpList, deviceCount)
Create/formats the LinkGraph.cfg file based on arguments -only creates a linear topology and connects islands -evenly distributes devices -must be called by ONOSbench
source code
 
configNullDev(self, ONOSIpList, deviceCount, numPorts=10)
ONOSIpList = list of Ip addresses of nodes switches will be devided amongst deviceCount = number of switches to distribute, or list of values to use as custom distribution numPorts = number of ports per device.
source code
 
configNullLink(self, fileName="/opt/onos/apache-karaf-3.0.3/etc/linkGraph.cfg", eventRate=0)
fileName default is currently the same as the default on ONOS, specify alternate file if you want to use a different topology file than linkGraph.cfg
source code
 
getOnosIps(self)
Get all onos IPs stored in
source code
 
logReport(self, nodeIp, searchTerms, outputMode="s")
- accepts either a list or a string for "searchTerms" these terms will be searched for in the log and have their instances counted
source code
 
copyMininetFile(self, fileName, localPath, userName, ip, mnPath='~/mininet/custom/', timeout=60)
Description:...
source code
 
jvmSet(self, memory=8) source code
 
createDBFile(self, testData) source code
 
verifySummary(self, ONOSIp, *deviceCount) 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 

Initialize client

Overrides: object.__init__

connect(self, **connectargs)

source code 

Creates ssh handle for ONOS "bench". NOTE: The ip_address would come from the topo file using the host tag, the value can be an environment variable as well as a "localhost" to get the ip address needed to ssh to the "bench"

Overrides: component.Component.connect

disconnect(self)

source code 

Called when Test is complete to disconnect the ONOS handle.

Overrides: component.Component.disconnect

getEpochMs(self)

source code 

Returns milliseconds since epoch

When checking multiple nodes in a for loop, around a hundred milliseconds of difference (ascending) is generally acceptable due to calltime of the function. Few seconds, however, is not and it means clocks are off sync.

cleanInstall(self, skipTest=False, mciTimeout=600)

source code 

Runs mvn clean install in the root of the ONOS directory.
This will clean all ONOS artifacts then compile each module
Optional:
    skipTest - Does "-DskipTests -Dcheckstyle.skip -U -T 1C" which
               skip the test. This will make the building faster.
               Disregarding the credibility of the build
Returns: main.TRUE on success
On Failure, exits the test

gitPull(self, comp1="", fastForward=True)

source code 

Assumes that "git pull" works without login

If the fastForward boolean is set to true, only git pulls that can be fast forwarded will be performed. IE if you have not local commits in your branch.

This function will perform a git pull on the ONOS instance. If used as gitPull( "NODE" ) it will do git pull + NODE. This is for the purpose of pulling from other nodes if necessary.

Otherwise, this function will perform a git pull in the ONOS repository. If it has any problems, it will return main.ERROR If it successfully does a gitPull, it will return a 1 ( main.TRUE ) If it has no updates, it will return 3.

gitCheckout(self, branch="master")

source code 

Assumes that "git pull" works without login

This function will perform a git git checkout on the ONOS instance. If used as gitCheckout( "branch" ) it will do git checkout of the "branch".

Otherwise, this function will perform a git checkout of the master branch of the ONOS repository. If it has any problems, it will return main.ERROR. If the branch was already the specified branch, or the git checkout was successful then the function will return main.TRUE.

createCellFile(self, benchIp, fileName, mnIpAddrs, appString, onosIpAddrs)

source code 

Creates a cell file based on arguments
Required:
    * Bench IP address ( benchIp )
        - Needed to copy the cell file over
    * File name of the cell file ( fileName )
    * Mininet IP address ( mnIpAddrs )
        - Note that only 1 ip address is
          supported currently
    * ONOS IP addresses ( onosIpAddrs )
        - Must be passed in as last arguments

NOTE: Assumes cells are located at:
    ~/<self.home>/tools/test/cells/

onosCfgSet(self, ONOSIp, configName, configParam)

source code 

Uses 'onos <node-ip> cfg set' to change a parameter value of an
application.

ex)
    onos 10.0.0.1 cfg set org.onosproject.myapp appSetting 1
ONOSIp = '10.0.0.1'
configName = 'org.onosproject.myapp'
configParam = 'appSetting 1'

onosCli(self, ONOSIp, cmdstr)

source code 

Uses 'onos' command to send various ONOS CLI arguments.
Required:
    * ONOSIp: specify the ip of the cell machine
    * cmdstr: specify the command string to send

This function is intended to expose the entire karaf
CLI commands for ONOS. Try to use this function first
before attempting to write a ONOS CLI specific driver
function.
You can see a list of available 'cmdstr' arguments
by starting onos, and typing in 'onos' to enter the
onos> CLI. Then, type 'help' to see the list of
available commands.

onosInstall(self, options="-f", node="")

source code 

Installs ONOS bits on the designated cell machine. If -f option is provided, it also forces an uninstall. Presently, install also includes onos-push-bits and onos-config within. The node option allows you to selectively only push the jar files to certain onos nodes

Returns: main.TRUE on success and main.FALSE on failure

onosRemoveRaftLogs(self)

source code 

Removes Raft / Copy cat files from ONOS to ensure
a cleaner environment.

Description:
    Stops all ONOS defined in the cell,
    wipes the raft / copycat log files

onosStartNetwork(self, mntopo)

source code 

Calls the command 'onos-start-network [ <mininet-topo> ]
"remotely starts the specified topology on the cell's
mininet machine against all controllers configured in the
cell."
* Specify mininet topology file name for mntopo
* Topo files should be placed at:
  ~/<your-onos-directory>/tools/test/topos

NOTE: This function will take you to the mininet prompt

isup(self, node="", timeout=120)

source code 

Run's onos-wait-for-start which only returns once ONOS is at run level 100(ready for use)

Returns: main.TRUE if ONOS is running and main.FALSE on timeout

pushTestIntentsShell(self, dpidSrc, dpidDst, numIntents, dirFile, onosIp, numMult="", appId="", report=True, options="")

source code 

Description:
    Use the linux prompt to push test intents to
    better parallelize the results than the CLI
Required:
    * dpidSrc: specify source dpid
    * dpidDst: specify destination dpid
    * numIntents: specify number of intents to push
    * dirFile: specify directory and file name to save
      results
    * onosIp: specify the IP of ONOS to install on
NOTE:
    You must invoke this command at linux shell prompt

getTopology(self, topologyOutput)

source code 

Definition:
    Loads a json topology output
Return:
    topology = current ONOS topology

checkStatus(self, topologyResult, numoswitch, numolink, logLevel="info")

source code 

Checks the number of switches & links that ONOS sees against the
supplied values. By default this will report to main.log, but the
log level can be specific.

Params: ip = ip used for the onos cli
        numoswitch = expected number of switches
        numolink = expected number of links
        logLevel = level to log to.
        Currently accepts 'info', 'warn' and 'report'


logLevel can

Returns: main.TRUE if the number of switches and links are correct,
         main.FALSE if the number of switches and links is incorrect,
         and main.ERROR otherwise

tsharkPcap(self, interface, dirFile)

source code 

Capture all packet activity and store in specified
directory/file

Required:
    * interface: interface to capture
    * dir: directory/filename to store pcap

tsharkGrep(self, grep, directory, interface='eth0', grepOptions='')

source code 

Required:
    * grep string
    * directory to store results
Optional:
    * interface - default: eth0
    * grepOptions - options for grep
Description:
    Uses tshark command to grep specific group of packets
    and stores the results to specified directory.
    The timestamp is hardcoded to be in epoch

ptpd(self, args)

source code 

Initiate ptp with user-specified args.
Required:
    * args: specify string of args after command
      'sudo ptpd'

cpLogsToDir(self, logToCopy, destDir, copyFileName="")

source code 

Copies logs to a desired directory.
Current implementation of ONOS deletes its karaf
logs on every iteration. For debugging purposes,
you may want to use this function to capture
certain karaf logs. ( or any other logs if needed )
Localtime will be attached to the filename

Required:
    * logToCopy: specify directory and log name to
      copy.
      ex ) /opt/onos/log/karaf.log.1
      For copying multiple files, leave copyFileName
      empty and only specify destDir -
      ex ) /opt/onos/log/karaf*
    * destDir: specify directory to copy to.
      ex ) /tmp/
Optional:
    * copyFileName: If you want to rename the log
      file, specify copyFileName. This will not work
      with multiple file copying

checkLogs(self, onosIp, restart=False)

source code 

runs onos-check-logs on the given onos node
If restart is True, use the old version of onos-check-logs which
    does not print the full stacktrace, but shows the entire log file,
    including across restarts
returns the response

setIpTables(self, ip, port='', action='add', packet_type='', direction='INPUT', rule='DROP', states=True)

source code 

Description:
    add or remove iptables rule to DROP (default) packets from
    specific IP and PORT
Usage:
* specify action ('add' or 'remove')
  when removing, pass in the same argument as you would add. It will
  delete that specific rule.
* specify the ip to block
* specify the destination port to block (defaults to all ports)
* optional packet type to block (default tcp)
* optional iptables rule (default DROP)
* optional direction to block (default 'INPUT')
* States boolean toggles adding all supported tcp states to the
  firewall rule
Returns:
    main.TRUE on success or
    main.FALSE if given invalid input or
    main.ERROR if there is an error in response from iptables
WARNING:
* This function uses root privilege iptables command which may result
  in unwanted network errors. USE WITH CAUTION

createLinkGraphFile(self, benchIp, ONOSIpList, deviceCount)

source code 

Create/formats the LinkGraph.cfg file based on arguments
    -only creates a linear topology and connects islands
    -evenly distributes devices
    -must be called by ONOSbench

    ONOSIpList - list of all of the node IPs to be used

    deviceCount - number of switches to be assigned

configNullDev(self, ONOSIpList, deviceCount, numPorts=10)

source code 

ONOSIpList = list of Ip addresses of nodes switches will be devided amongst deviceCount = number of switches to distribute, or list of values to use as custom distribution numPorts = number of ports per device. Defaults to 10 both in this function and in ONOS. Optional arg

logReport(self, nodeIp, searchTerms, outputMode="s")

source code 

- accepts either a list or a string for "searchTerms" these
  terms will be searched for in the log and have their
  instances counted

- nodeIp is the ip of the node whos log is to be scanned

- output modes:
    "s" -   Simple. Quiet output mode that just prints
            the occurences of each search term

    "d" -   Detailed. Prints number of occurences as well as the entire
            line for each of the last 5 occurences

- returns total of the number of instances of all search terms

copyMininetFile(self, fileName, localPath, userName, ip, mnPath='~/mininet/custom/', timeout=60)

source code 

Description:
    Copy mininet topology file from dependency folder in the test folder
    and paste it to the mininet machine's mininet/custom folder
Required:
    fileName - Name of the topology file to copy
    localPath - File path of the mininet topology file
    userName - User name of the mininet machine to send the file to
    ip - Ip address of the mininet machine
Optional:
    mnPath - of the mininet directory to send the file to
Return:
    Return main.TRUE if successfully copied the file otherwise
    return main.FALSE