Package TestON :: Package drivers :: Package common :: Package api :: Package controller :: Module onosrestdriver :: Class OnosRestDriver
[hide private]
[frames] | no frames]

Class OnosRestDriver

source code


Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
connect(self, **connectargs)
Connection will establish to the remote host using ssh.
source code
 
send(self, ip, port, url, base="/onos/v1", method="GET", query=None, data=None)
Arguments: str ip: ONOS IP Address str port: ONOS REST Port str url: ONOS REST url path.
source code
 
intents(self, ip="DEFAULT", port="DEFAULT")
Description:...
source code
 
intent(self, intentId, appId="org.onosproject.cli", ip="DEFAULT", port="DEFAULT")
Description:...
source code
 
apps(self, ip="DEFAULT", port="DEFAULT")
Description:...
source code
 
activateApp(self, appName, ip="DEFAULT", port="DEFAULT", check=True)
Decription:...
source code
 
deactivateApp(self, appName, ip="DEFAULT", port="DEFAULT", check=True)
Required:...
source code
 
getApp(self, appName, project="org.onosproject.", ip="DEFAULT", port="DEFAULT")
Decription:...
source code
 
addHostIntent(self, hostIdOne, hostIdTwo, appId='org.onosproject.cli', ip="DEFAULT", port="DEFAULT")
Description: Adds a host-to-host intent ( bidirectional ) by specifying the two hosts.
source code
 
addPointIntent(self, ingressDevice, egressDevice, appId='org.onosproject.cli', ingressPort="", egressPort="", ethType="", ethSrc="", ethDst="", bandwidth="", lambdaAlloc=False, ipProto="", ipSrc="", ipDst="", tcpSrc="", tcpDst="", ip="DEFAULT", port="DEFAULT")
Description: Adds a point-to-point intent ( uni-directional ) by specifying device id's and optional fields Required: * ingressDevice: device id of ingress device * egressDevice: device id of egress device Optional: * ethType: specify ethType * ethSrc: specify ethSrc ( i.e.
source code
 
removeIntent(self, intentId, appId='org.onosproject.cli', ip="DEFAULT", port="DEFAULT")
Remove intent for specified application id and intent id; Returns None for exception
source code
 
getIntentsId(self, ip="DEFAULT", port="DEFAULT")
Returns a list of intents id; Returns None for exception
source code
 
removeAllIntents(self, intentIdList='ALL', appId='org.onosproject.cli', ip="DEFAULT", port="DEFAULT", delay=5)
Description:...
source code
 
hosts(self, ip="DEFAULT", port="DEFAULT")
Description:...
source code
 
getHost(self, mac, vlan="-1", ip="DEFAULT", port="DEFAULT")
Description: Gets the information from the given host Required: str mac - MAC address of the host Optional: str vlan - VLAN tag of the host, defaults to -1 Returns: Return the host id from the hosts/mac/vlan output in REST api whose 'id' contains mac/vlan; Returns None for exception; Returns main.FALSE if error on requests
source code
 
topology(self, ip="DEFAULT", port="DEFAULT")
Description:...
source code
 
getIntentState(self, intentsId, intentsJson=None, ip="DEFAULT", port="DEFAULT")
Description: Get intent state.
source code
 
checkIntentState(self, intentsId="ALL", expectedState='INSTALLED', ip="DEFAULT", port="DEFAULT")
Description: Check intents state based on expected state which defaults to INSTALLED state Required: intentsId - List of intents ID to be checked Optional: expectedState - Check the expected state(s) of each intents state in the list.
source code
 
flows(self, ip="DEFAULT", port="DEFAULT")
Description:...
source code
 
getFlows(self, device, flowId=0, ip="DEFAULT", port="DEFAULT")
Description:...
source code
 
addFlow(self, deviceId, appId=0, ingressPort="", egressPort="", ethType="", ethSrc="", ethDst="", bandwidth="", lambdaAlloc=False, ipProto="", ipSrc="", ipDst="", tcpSrc="", tcpDst="", ip="DEFAULT", port="DEFAULT")
Description: Creates a single flow in the specified device Required: * deviceId: id of the device Optional: * ingressPort: port ingress device * egressPort: port of egress device * ethType: specify ethType * ethSrc: specify ethSrc ( i.e.
source code
 
removeFlow(self, deviceId, flowId, ip="DEFAULT", port="DEFAULT")
Description:...
source code
 
checkFlowsState(self, ip="DEFAULT", port="DEFAULT")
Description:...
source code

Inherited from component.Component: __getattr__, cleanup, close_log_handles, config, disconnect, execute, 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 

Connection will establish to the remote host using ssh. It will take user_name ,ip_address and password as arguments<br> and will return the handle.

Overrides: component.Component.connect

send(self, ip, port, url, base="/onos/v1", method="GET", query=None, data=None)

source code 

Arguments:
    str ip: ONOS IP Address
    str port: ONOS REST Port
    str url: ONOS REST url path.
             NOTE that this is is only the relative path. IE "/devices"
    str base: The base url for the given REST api. Applications could
              potentially have their own base url
    str method: HTTP method type
    dict query: Dictionary to be sent in the query string for
                 the request
    dict data: Dictionary to be sent in the body of the request

intents(self, ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Gets a list of dictionary of all intents in the system
Returns:
    A list of dictionary of intents in string type to match the cli
    version for now; Returns main.FALSE if error on request;
    Returns None for exception

intent(self, intentId, appId="org.onosproject.cli", ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Get the specific intent information of the given application ID and
    intent ID
Required:
    str intentId - Intent id in hexadecimal form
Optional:
    str appId - application id of intent
Returns:
    Returns an information dictionary of the given intent;
    Returns main.FALSE if error on requests; Returns None for exception
NOTE:
    The GET /intents REST api command accepts  application id but the
    api will get updated to accept application name instead

apps(self, ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Returns all the current application installed in the system
Returns:
    List of dictionary of installed application; Returns main.FALSE for
    error on request; Returns None for exception

activateApp(self, appName, ip="DEFAULT", port="DEFAULT", check=True)

source code 

Decription:
    Activate an app that is already installed in ONOS
Optional:
    bool check - If check is True, method will check the status
                 of the app after the command is issued
Returns:
    Returns main.TRUE if the command was successfully or main.FALSE
    if the REST responded with an error or given incorrect input;
    Returns None for exception

deactivateApp(self, appName, ip="DEFAULT", port="DEFAULT", check=True)

source code 

Required:
    Deactivate an app that is already activated in ONOS
Optional:
    bool check - If check is True, method will check the status of the
    app after the command is issued
Returns:
    Returns main.TRUE if the command was successfully sent
    main.FALSE if the REST responded with an error or given
    incorrect input; Returns None for exception

getApp(self, appName, project="org.onosproject.", ip="DEFAULT", port="DEFAULT")

source code 

Decription:
    Gets the informaion of the given application
Required:
    str name - Name of onos application
Returns:
    Returns a dictionary of information ONOS application in string type;
    Returns main.FALSE if error on requests; Returns None for exception

addHostIntent(self, hostIdOne, hostIdTwo, appId='org.onosproject.cli', ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Adds a host-to-host intent ( bidirectional ) by
    specifying the two hosts.
Required:
    * hostIdOne: ONOS host id for host1
    * hostIdTwo: ONOS host id for host2
Optional:
    str appId - Application name of intent identifier
Returns:
    Returns main.TRUE for successful requests; Returns main.FALSE if
    error on requests; Returns None for exceptions

addPointIntent(self, ingressDevice, egressDevice, appId='org.onosproject.cli', ingressPort="", egressPort="", ethType="", ethSrc="", ethDst="", bandwidth="", lambdaAlloc=False, ipProto="", ipSrc="", ipDst="", tcpSrc="", tcpDst="", ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Adds a point-to-point intent ( uni-directional ) by
    specifying device id's and optional fields
Required:
    * ingressDevice: device id of ingress device
    * egressDevice: device id of egress device
Optional:
    * ethType: specify ethType
    * ethSrc: specify ethSrc ( i.e. src mac addr )
    * ethDst: specify ethDst ( i.e. dst mac addr )
    * bandwidth: specify bandwidth capacity of link (TODO)
    * lambdaAlloc: if True, intent will allocate lambda
      for the specified intent (TODO)
    * ipProto: specify ip protocol
    * ipSrc: specify ip source address with mask eg. ip#/24
    * ipDst: specify ip destination address eg. ip#/24
    * tcpSrc: specify tcp source port
    * tcpDst: specify tcp destination port
Returns:
    Returns main.TRUE for successful requests; Returns main.FALSE if
    no ingress|egress port found and if error on requests;
    Returns None for exceptions
NOTE:
    The ip and port option are for the requests input's ip and port
    of the ONOS node

removeAllIntents(self, intentIdList='ALL', appId='org.onosproject.cli', ip="DEFAULT", port="DEFAULT", delay=5)

source code 

Description:
    Remove all the intents
Returns:
    Returns main.TRUE if all intents are removed, otherwise returns
    main.FALSE; Returns None for exception

hosts(self, ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Get a list of dictionary of all discovered hosts
Returns:
    Returns a list of dictionary of information of the hosts currently
    discovered by ONOS; Returns main.FALSE if error on requests;
    Returns None for exception

getHost(self, mac, vlan="-1", ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Gets the information from the given host
Required:
    str mac - MAC address of the host
Optional:
    str vlan - VLAN tag of the host, defaults to -1
Returns:
    Return the host id from the hosts/mac/vlan output in REST api
    whose 'id' contains mac/vlan; Returns None for exception;
    Returns main.FALSE if error on requests

NOTE:
    Not sure what this function should do, any suggestion?

topology(self, ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Gets the overview of network topology
Returns:
    Returns a dictionary containing information about network topology;
    Returns None for exception

getIntentState(self, intentsId, intentsJson=None, ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Get intent state.
    Accepts a single intent ID (string type) or a list of intent IDs.
    Returns the state(string type) of the id if a single intent ID is
    accepted.
Required:
    intentId: intent ID (string type)
    intentsJson: parsed json object from the onos:intents api
Returns:
    Returns a dictionary with intent IDs as the key and its
    corresponding states as the values; Returns None for invalid IDs or
    Type error and any exceptions
NOTE:
    An intent's state consist of INSTALLED,WITHDRAWN etc.

checkIntentState(self, intentsId="ALL", expectedState='INSTALLED', ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Check intents state based on expected state which defaults to
    INSTALLED state
Required:
    intentsId - List of intents ID to be checked
Optional:
    expectedState - Check the expected state(s) of each intents
                    state in the list.
                    *NOTE: You can pass in a list of expected state,
                    Eg: expectedState = [ 'INSTALLED' , 'INSTALLING' ]
Return:
    Returns main.TRUE only if all intent are the same as expected states
    , otherwise, returns main.FALSE; Returns None for general exception

flows(self, ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Get flows currently added to the system
NOTE:
    The flows -j cli command has completely different format than
    the REST output; Returns None for exception

getFlows(self, device, flowId=0, ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Gets all the flows of the device or get a specific flow in the
    device by giving its flow ID
Required:
    str device - device/switch Id
Optional:
    int/hex flowId - ID of the flow

addFlow(self, deviceId, appId=0, ingressPort="", egressPort="", ethType="", ethSrc="", ethDst="", bandwidth="", lambdaAlloc=False, ipProto="", ipSrc="", ipDst="", tcpSrc="", tcpDst="", ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Creates a single flow in the specified device
Required:
    * deviceId: id of the device
Optional:
    * ingressPort: port ingress device
    * egressPort: port  of egress device
    * ethType: specify ethType
    * ethSrc: specify ethSrc ( i.e. src mac addr )
    * ethDst: specify ethDst ( i.e. dst mac addr )
    * ipProto: specify ip protocol
    * ipSrc: specify ip source address with mask eg. ip#/24
    * ipDst: specify ip destination address eg. ip#/24
    * tcpSrc: specify tcp source port
    * tcpDst: specify tcp destination port
Returns:
    Returns main.TRUE for successful requests; Returns main.FALSE
    if error on requests;
    Returns None for exceptions
NOTE:
    The ip and port option are for the requests input's ip and port
    of the ONOS node

removeFlow(self, deviceId, flowId, ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Remove specific device flow
Required:
    str deviceId - id of the device
    str flowId - id of the flow
Return:
    Returns main.TRUE if successfully deletes flows, otherwise
    Returns main.FALSE, Returns None on error

checkFlowsState(self, ip="DEFAULT", port="DEFAULT")

source code 

Description:
    Check if all the current flows are in ADDED state
Return:
    returnValue - Returns main.TRUE only if all flows are in
                  return main.FALSE otherwise;
                  Returns None for exception