Reverting core/ and drivers/ directories before change 15514
This reverts commit 23fb21617769f4320de93b5b1805c6ec3ca9b809.
Change-Id: I0c116f8d7195c75c7ef17f296843924d3e2a0961
diff --git a/TestON/drivers/common/api/controller/onosrestdriver.py b/TestON/drivers/common/api/controller/onosrestdriver.py
old mode 100644
new mode 100755
index b5d2062..312f1f1
--- a/TestON/drivers/common/api/controller/onosrestdriver.py
+++ b/TestON/drivers/common/api/controller/onosrestdriver.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
Created on 07-08-2015
-Copyright 2015 Open Networking Foundation ( ONF )
+Copyright 2015 Open Networking Foundation (ONF)
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -48,7 +48,7 @@
except Exception as e:
main.log.exception( e )
try:
- if os.getenv( str( self.ip_address ) ) is not None:
+ if os.getenv( str( self.ip_address ) ) != None:
self.ip_address = os.getenv( str( self.ip_address ) )
else:
main.log.info( self.name + ": ip set to " + self.ip_address )
@@ -74,12 +74,12 @@
if isinstance( jsonObject, str ):
jsonObject = json.loads( jsonObject )
return json.dumps( jsonObject, sort_keys=True,
- indent=4, separators=( ',', ': ' ) )
+ indent=4, separators=(',', ': '))
except ( TypeError, ValueError ):
main.log.exception( "Error parsing jsonObject" )
return None
- def send( self, url, ip="DEFAULT", port="DEFAULT", base="/onos/v1", method="GET",
+ def send( self, url, ip = "DEFAULT", port = "DEFAULT", base="/onos/v1", method="GET",
query=None, data=None, debug=False ):
"""
Arguments:
@@ -94,25 +94,25 @@
the request
dict data: Dictionary to be sent in the body of the request
"""
- # TODO: Authentication - simple http ( user,pass ) tuple
+ # TODO: Authentication - simple http (user,pass) tuple
# TODO: should we maybe just pass kwargs straight to response?
# TODO: Do we need to allow for other protocols besides http?
# ANSWER: Not yet, but potentially https with certificates
if ip == "DEFAULT":
- main.log.warn( "No ip given, reverting to ip from topo file" )
- ip = self.ip_address
+ main.log.warn( "No ip given, reverting to ip from topo file" )
+ ip = self.ip_address
if port == "DEFAULT":
- main.log.warn( "No port given, reverting to port " +
- "from topo file" )
- port = self.port
+ main.log.warn( "No port given, reverting to port " +
+ "from topo file" )
+ port = self.port
try:
path = "http://" + str( ip ) + ":" + str( port ) + base + url
if self.user_name and self.pwd:
- main.log.info( "user/passwd is: " + self.user_name + "/" + self.pwd )
- auth = ( self.user_name, self.pwd )
+ main.log.info("user/passwd is: " + self.user_name + "/" + self.pwd)
+ auth = (self.user_name, self.pwd)
else:
- auth = None
+ auth=None
main.log.info( "Sending request " + path + " using " +
method.upper() + " method." )
response = requests.request( method.upper(),
@@ -148,7 +148,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( url="/intents", ip=ip, port=port )
+ response = self.send( url="/intents", ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -195,7 +195,7 @@
port = self.port
# NOTE: REST url requires the intent id to be in decimal form
query = "/" + str( appId ) + "/" + str( intentId )
- response = self.send( url="/intents" + query, ip=ip, port=port )
+ response = self.send( url="/intents" + query, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -229,7 +229,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( url="/applications", ip=ip, port=port )
+ response = self.send( url="/applications", ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -273,7 +273,7 @@
query = "/" + str( appName ) + "/active"
response = self.send( method="POST",
url="/applications" + query,
- ip=ip, port=port )
+ ip = ip, port = port)
if response:
output = response[ 1 ]
app = json.loads( output )
@@ -329,7 +329,7 @@
query = "/" + str( appName ) + "/active"
self.send( method="DELETE",
url="/applications" + query,
- ip=ip, port=port )
+ ip = ip, port = port )
response = self.getApp( appName, ip, port )
if response:
output = response[ 1 ]
@@ -383,7 +383,7 @@
port = self.port
query = "/" + str( appName )
response = self.send( url="/applications" + query,
- ip=ip, port=port )
+ ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
return response
@@ -414,17 +414,17 @@
error on requests; Returns None for exceptions
"""
try:
- intentJson = { "two": str( hostIdTwo ),
- "selector": { "criteria": [] }, "priority": 7,
- "treatment": { "deferred": [], "instructions": [] },
- "appId": appId, "one": str( hostIdOne ),
- "type": "HostToHostIntent",
- "constraints": [ { "type": "LinkTypeConstraint",
- "types": [ "OPTICAL" ],
- "inclusive": 'false' } ] }
+ intentJson = {"two": str( hostIdTwo ),
+ "selector": {"criteria": []}, "priority": 7,
+ "treatment": {"deferred": [], "instructions": []},
+ "appId": appId, "one": str( hostIdOne ),
+ "type": "HostToHostIntent",
+ "constraints": [{"type": "LinkTypeConstraint",
+ "types": ["OPTICAL"],
+ "inclusive": 'false' }]}
if vlanId:
- intentJson[ 'selector' ][ 'criteria' ].append( { "type": "VLAN_VID",
- "vlanId": vlanId } )
+ intentJson[ 'selector' ][ 'criteria' ].append( { "type":"VLAN_VID",
+ "vlanId":vlanId } )
output = None
if ip == "DEFAULT":
main.log.warn( "No ip given, reverting to ip from topo file" )
@@ -434,7 +434,7 @@
"from topo file" )
port = self.port
response = self.send( method="POST",
- url="/intents", ip=ip, port=port,
+ url="/intents", ip = ip, port = port,
data=json.dumps( intentJson ) )
if response:
if "201" in str( response[ 0 ] ):
@@ -485,9 +485,9 @@
* 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 )
+ * bandwidth: specify bandwidth capacity of link (TODO)
* lambdaAlloc: if True, intent will allocate lambda
- for the specified intent ( TODO )
+ 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
@@ -520,63 +520,63 @@
main.log.debug( self.name + ": Egress port not specified" )
return main.FALSE
- intentJson = { "ingressPoint": { "device": ingressDevice,
- "port": ingressPort },
- "selector": { "criteria": [] },
- "priority": 55,
- "treatment": { "deferred": [],
- "instructions": [] },
- "egressPoint": { "device": egressDevice,
- "port": egressPort },
- "appId": appId,
- "type": "PointToPointIntent",
- "constraints": [ { "type": "LinkTypeConstraint",
- "types": [ "OPTICAL" ],
- "inclusive": "false" } ] }
+ intentJson ={ "ingressPoint": { "device": ingressDevice,
+ "port": ingressPort },
+ "selector": { "criteria": [] },
+ "priority": 55,
+ "treatment": { "deferred": [],
+ "instructions": [] },
+ "egressPoint": { "device": egressDevice,
+ "port": egressPort },
+ "appId": appId,
+ "type": "PointToPointIntent",
+ "constraints": [ { "type": "LinkTypeConstraint",
+ "types": [ "OPTICAL" ],
+ "inclusive": "false" } ] }
# if protected:
- # intentJson[ 'constraints' ].append( { "type": "Protection", "types": [ "Protection" ], "inclusive": "true" } )
+ # intentJson['constraints'].append( { "type": "Protection", "types": ["Protection"], "inclusive": "true" } )
if ethType == "IPV4":
intentJson[ 'selector' ][ 'criteria' ].append( {
- "type": "ETH_TYPE",
- "ethType": 2048 } )
+ "type":"ETH_TYPE",
+ "ethType":2048 } )
elif ethType:
intentJson[ 'selector' ][ 'criteria' ].append( {
- "type": "ETH_TYPE",
- "ethType": ethType } )
+ "type":"ETH_TYPE",
+ "ethType":ethType } )
if ethSrc:
intentJson[ 'selector' ][ 'criteria' ].append(
- { "type": "ETH_SRC",
- "mac": ethSrc } )
+ { "type":"ETH_SRC",
+ "mac":ethSrc } )
if ethDst:
intentJson[ 'selector' ][ 'criteria' ].append(
- { "type": "ETH_DST",
- "mac": ethDst } )
+ { "type":"ETH_DST",
+ "mac":ethDst } )
if ipSrc:
intentJson[ 'selector' ][ 'criteria' ].append(
- { "type": "IPV4_SRC",
- "ip": ipSrc } )
+ { "type":"IPV4_SRC",
+ "ip":ipSrc } )
if ipDst:
intentJson[ 'selector' ][ 'criteria' ].append(
- { "type": "IPV4_DST",
- "ip": ipDst } )
+ { "type":"IPV4_DST",
+ "ip":ipDst } )
if tcpSrc:
intentJson[ 'selector' ][ 'criteria' ].append(
- { "type": "TCP_SRC",
+ { "type":"TCP_SRC",
"tcpPort": tcpSrc } )
if tcpDst:
intentJson[ 'selector' ][ 'criteria' ].append(
- { "type": "TCP_DST",
+ { "type":"TCP_DST",
"tcpPort": tcpDst } )
if ipProto:
intentJson[ 'selector' ][ 'criteria' ].append(
- { "type": "IP_PROTO",
+ { "type":"IP_PROTO",
"protocol": ipProto } )
if vlanId:
intentJson[ 'selector' ][ 'criteria' ].append(
- { "type": "VLAN_VID",
+ { "type":"VLAN_VID",
"vlanId": vlanId } )
# TODO: Bandwidth and Lambda will be implemented if needed
@@ -590,7 +590,7 @@
"from topo file" )
port = self.port
response = self.send( method="POST",
- url="/intents", ip=ip, port=port,
+ url="/intents", ip = ip, port = port,
data=json.dumps( intentJson ) )
main.log.debug( intentJson )
@@ -613,26 +613,26 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
- def addSinglepointToMultipointIntent( self,
- ingressDevice,
- egressDeviceList,
- portEgressList,
- appId='org.onosproject.cli',
- portIngress="",
- ethType="",
- ethSrc="",
- ethDst="",
- bandwidth="",
- lambdaAlloc=False,
- ipProto="",
- ipSrc="",
- ipDst="",
- tcpSrc="",
- tcpDst="",
- partial=False,
- ip="DEFAULT",
- port="DEFAULT",
- vlanId="" ):
+ def addSinglepointToMultipointIntent(self,
+ ingressDevice,
+ egressDeviceList,
+ portEgressList,
+ appId='org.onosproject.cli',
+ portIngress="",
+ ethType="",
+ ethSrc="",
+ ethDst="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipSrc="",
+ ipDst="",
+ tcpSrc="",
+ tcpDst="",
+ partial=False,
+ ip="DEFAULT",
+ port="DEFAULT",
+ vlanId="" ):
"""
Description:
Adds a point-to-multi point intent ( uni-directional ) by
@@ -647,9 +647,9 @@
* 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 )
+ * bandwidth: specify bandwidth capacity of link (TODO)
* lambdaAlloc: if True, intent will allocate lambda
- for the specified intent ( TODO )
+ 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
@@ -694,7 +694,7 @@
"appId": appId,
"type": "SinglePointToMultiPointIntent",
"constraints": [ { "type": "LinkTypeConstraint",
- "types": [ "OPTICAL" ],
+ "types": ["OPTICAL"],
"inclusive": "false" } ] }
index = 0
@@ -752,16 +752,16 @@
"from topo file" )
port = self.port
response = self.send( method="POST",
- url="/intents", ip=ip, port=port,
- data=json.dumps( intentJson ) )
+ url="/intents", ip=ip, port=port,
+ data=json.dumps( intentJson ) )
- main.log.debug( intentJson )
+ main.log.debug(intentJson)
if response:
if "201" in str( response[ 0 ] ):
main.log.info( self.name + ": Successfully POST point" +
" intent between ingress: " + ingressDevice +
- " and egress: " + str( egressDeviceList ) + " devices" )
+ " and egress: " + str(egressDeviceList) + " devices" )
return main.TRUE
else:
main.log.error( "Error with REST request, response was: " + str( response ) )
@@ -795,7 +795,7 @@
# NOTE: REST url requires the intent id to be in decimal form
query = "/" + str( appId ) + "/" + str( int( intentId, 16 ) )
response = self.send( method="DELETE",
- url="/intents" + query, ip=ip, port=port )
+ url="/intents" + query, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
return main.TRUE
@@ -834,7 +834,7 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
- def removeAllIntents( self, intentIdList='ALL', appId='org.onosproject.cli',
+ def removeAllIntents( self, intentIdList ='ALL',appId='org.onosproject.cli',
ip="DEFAULT", port="DEFAULT", delay=5 ):
"""
Description:
@@ -864,7 +864,7 @@
import time
time.sleep( delay )
intentRemain = len( json.loads( self.intents() ) )
- if all( result == main.TRUE for result in results ) and \
+ if all( result==main.TRUE for result in results ) and \
intentRemain == 0:
main.log.info( self.name + ": All intents are removed " )
return main.TRUE
@@ -900,7 +900,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( url="/hosts", ip=ip, port=port )
+ response = self.send( url="/hosts", ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -945,12 +945,12 @@
"from topo file" )
port = self.port
query = "/" + mac + "/" + vlan
- response = self.send( url="/hosts" + query, ip=ip, port=port )
+ response = self.send( url="/hosts" + query, ip = ip, port = port )
if response:
- # NOTE: What if the person wants other values? would it be better
- # to have a function that gets a key and return a value instead?
- # This function requires mac and vlan and returns an ID which
- # makes this current function useless
+ # NOTE: What if the person wants other values? would it be better
+ # to have a function that gets a key and return a value instead?
+ # This function requires mac and vlan and returns an ID which
+ # makes this current function useless
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
hostId = json.loads( output ).get( 'id' )
@@ -983,7 +983,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( url="/topology", ip=ip, port=port )
+ response = self.send( url="/topology", ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -1019,7 +1019,7 @@
main.log.warn( "No port given, reverting to port " +
"from topo file" )
port = self.port
- response = self.send( url="/devices", ip=ip, port=port )
+ response = self.send( url="/devices", ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -1043,11 +1043,11 @@
"""
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
+ 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 )
+ 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
@@ -1095,7 +1095,7 @@
main.cleanAndExit()
def checkIntentState( self, intentsId="ALL", expectedState='INSTALLED',
- ip="DEFAULT", port="DEFAULT" ):
+ ip="DEFAULT", port="DEFAULT"):
"""
Description:
Check intents state based on expected state which defaults to
@@ -1103,7 +1103,7 @@
Required:
intentsId - List of intents ID to be checked
Optional:
- expectedState - Check the expected state( s ) of each intents
+ 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' ]
@@ -1227,7 +1227,7 @@
if flowId:
url += "/" + str( int( flowId ) )
print url
- response = self.send( url=url, ip=ip, port=port )
+ response = self.send( url=url, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -1262,9 +1262,9 @@
The ip and port option are for the requests input's ip and port
of the ONOS node
"""
+
try:
- if debug:
- main.log.debug( "Adding flow: " + self.pprint( flowJson ) )
+ if debug: main.log.debug( "Adding flow: " + self.pprint( flowJson ) )
output = None
if ip == "DEFAULT":
main.log.warn( "No ip given, reverting to ip from topo file" )
@@ -1275,7 +1275,7 @@
port = self.port
url = "/flows/" + deviceId
response = self.send( method="POST",
- url=url, ip=ip, port=port,
+ url=url, ip = ip, port = port,
data=json.dumps( flowJson ) )
if response:
if "201" in str( response[ 0 ] ):
@@ -1330,9 +1330,9 @@
* ethDst: specify ethDst ( i.e. dst mac addr )
* ipProto: specify ip protocol
* ipSrc: specify ip source address with mask eg. ip#/24
- as a tuple ( type, ip# )
+ as a tuple (type, ip#)
* ipDst: specify ip destination address eg. ip#/24
- as a tuple ( type, ip# )
+ as a tuple (type, ip#)
* tcpSrc: specify tcp source port
* tcpDst: specify tcp destination port
Returns:
@@ -1344,75 +1344,75 @@
of the ONOS node
"""
try:
- flowJson = { "priority": priority,
- "isPermanent": "true",
- "timeout": 0,
- "deviceId": deviceId,
- "treatment": { "instructions": [] },
- "selector": { "criteria": [] } }
+ flowJson = { "priority":priority,
+ "isPermanent":"true",
+ "timeout":0,
+ "deviceId":deviceId,
+ "treatment":{"instructions":[]},
+ "selector": {"criteria":[]}}
if appId:
flowJson[ "appId" ] = appId
if groupId:
flowJson[ 'treatment' ][ 'instructions' ].append( {
- "type": "GROUP",
- "groupId": groupId } )
+ "type":"GROUP",
+ "groupId":groupId } )
if egressPort:
flowJson[ 'treatment' ][ 'instructions' ].append( {
- "type": "OUTPUT",
- "port": egressPort } )
+ "type":"OUTPUT",
+ "port":egressPort } )
if ingressPort:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "IN_PORT",
- "port": ingressPort } )
+ "type":"IN_PORT",
+ "port":ingressPort } )
if ethType:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "ETH_TYPE",
- "ethType": ethType } )
+ "type":"ETH_TYPE",
+ "ethType":ethType } )
if ethSrc:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "ETH_SRC",
- "mac": ethSrc } )
+ "type":"ETH_SRC",
+ "mac":ethSrc } )
if ethDst:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "ETH_DST",
- "mac": ethDst } )
+ "type":"ETH_DST",
+ "mac":ethDst } )
if vlan:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "VLAN_VID",
- "vlanId": vlan } )
+ "type":"VLAN_VID",
+ "vlanId":vlan } )
if mpls:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "MPLS_LABEL",
- "label": mpls } )
+ "type":"MPLS_LABEL",
+ "label":mpls } )
if ipSrc:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": ipSrc[ 0 ],
- "ip": ipSrc[ 1 ] } )
+ "type":ipSrc[0],
+ "ip":ipSrc[1] } )
if ipDst:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": ipDst[ 0 ],
- "ip": ipDst[ 1 ] } )
+ "type":ipDst[0],
+ "ip":ipDst[1] } )
if tcpSrc:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "TCP_SRC",
+ "type":"TCP_SRC",
"tcpPort": tcpSrc } )
if tcpDst:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "TCP_DST",
+ "type":"TCP_DST",
"tcpPort": tcpDst } )
if udpSrc:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "UDP_SRC",
+ "type":"UDP_SRC",
"udpPort": udpSrc } )
if udpDst:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "UDP_DST",
+ "type":"UDP_DST",
"udpPort": udpDst } )
if ipProto:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "IP_PROTO",
+ "type":"IP_PROTO",
"protocol": ipProto } )
return self.sendFlow( deviceId=deviceId, flowJson=flowJson, debug=debug )
@@ -1448,7 +1448,7 @@
# NOTE: REST url requires the intent id to be in decimal form
query = "/" + str( deviceId ) + "/" + str( int( flowId ) )
response = self.send( method="DELETE",
- url="/flows" + query, ip=ip, port=port )
+ url="/flows" + query, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
return main.TRUE
@@ -1463,7 +1463,7 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
- def checkFlowsState( self, ip="DEFAULT", port="DEFAULT" ):
+ def checkFlowsState( self , ip="DEFAULT", port="DEFAULT" ):
"""
Description:
Check if all the current flows are in ADDED state
@@ -1516,7 +1516,7 @@
url += "/" + subjectKey
if configKey:
url += "/" + configKey
- response = self.send( url=url, ip=ip, port=port )
+ response = self.send( url=url, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -1566,7 +1566,7 @@
if configKey:
url += "/" + configKey
response = self.send( method="POST",
- url=url, ip=ip, port=port,
+ url=url, ip = ip, port = port,
data=json.dumps( cfgJson ) )
if response:
if 200 <= response[ 0 ] <= 299:
@@ -1611,7 +1611,7 @@
if configKey:
url += "/" + configKey
response = self.send( method="DELETE",
- url=url, ip=ip, port=port )
+ url=url, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
main.log.info( self.name + ": Successfully delete cfg" )
@@ -1628,30 +1628,30 @@
main.cleanAndExit()
def createFlowBatch( self,
- numSw=1,
- swIndex=1,
- batchSize=1,
- batchIndex=1,
- deviceIdpreFix="of:",
- appId=0,
- deviceID="",
- ingressPort="",
- egressPort="",
- ethType="",
- ethSrc="",
- ethDst="",
- vlan="",
- ipProto="",
- ipSrc=(),
- ipDst=(),
- tcpSrc="",
- tcpDst="",
- udpDst="",
- udpSrc="",
- mpls="",
- ip="DEFAULT",
- port="DEFAULT",
- debug=False ):
+ numSw = 1,
+ swIndex = 1,
+ batchSize = 1,
+ batchIndex = 1,
+ deviceIdpreFix = "of:",
+ appId=0,
+ deviceID="",
+ ingressPort="",
+ egressPort="",
+ ethType="",
+ ethSrc="",
+ ethDst="",
+ vlan="",
+ ipProto="",
+ ipSrc=(),
+ ipDst=(),
+ tcpSrc="",
+ tcpDst="",
+ udpDst="",
+ udpSrc="",
+ mpls="",
+ ip="DEFAULT",
+ port="DEFAULT",
+ debug=False ):
"""
Description:
Creates batches of MAC-rule flows for POST.
@@ -1668,9 +1668,9 @@
* ethDst: specify ethDst ( i.e. dst mac addr )
* ipProto: specify ip protocol
* ipSrc: specify ip source address with mask eg. ip#/24
- as a tuple ( type, ip# )
+ as a tuple (type, ip#)
* ipDst: specify ip destination address eg. ip#/24
- as a tuple ( type, ip# )
+ as a tuple (type, ip#)
* tcpSrc: specify tcp source port
* tcpDst: specify tcp destination port
Returns:
@@ -1681,110 +1681,111 @@
The ip and port option are for the requests input's ip and port
of the ONOS node
"""
- # from pprint import pprint
+ #from pprint import pprint
flowJsonList = []
- flowJsonBatch = { "flows": flowJsonList }
+ flowJsonBatch = {"flows":flowJsonList}
dev = swIndex
- for fl in range( 1, batchSize + 1 ):
- flowJson = { "priority": 100,
- "deviceId": "",
- "isPermanent": "true",
- "timeout": 0,
- "treatment": { "instructions": [] },
- "selector": { "criteria": [] } }
+ for fl in range(1, batchSize + 1):
+ flowJson = { "priority":100,
+ "deviceId":"",
+ "isPermanent":"true",
+ "timeout":0,
+ "treatment":{"instructions":[]},
+ "selector": {"criteria":[]}}
- # main.log.info( "fl: " + str( fl ) )
+ #main.log.info("fl: " + str(fl))
if dev <= numSw:
- deviceId = deviceIdpreFix + "{0:0{1}x}".format( dev, 16 )
- # print deviceId
- flowJson[ 'deviceId' ] = deviceId
+ deviceId = deviceIdpreFix + "{0:0{1}x}".format(dev,16)
+ #print deviceId
+ flowJson['deviceId'] = deviceId
dev += 1
else:
dev = 1
- deviceId = deviceIdpreFix + "{0:0{1}x}".format( dev, 16 )
- # print deviceId
- flowJson[ 'deviceId' ] = deviceId
+ deviceId = deviceIdpreFix + "{0:0{1}x}".format(dev,16)
+ #print deviceId
+ flowJson['deviceId'] = deviceId
dev += 1
# ethSrc starts with "0"; ethDst starts with "1"
# 2 Hex digit of device number; 5 digits of batch index number; 5 digits of batch size
- ethS = "%02X" % int( "0" + "{0:0{1}b}".format( dev, 7 ), 2 ) + \
- "{0:0{1}x}".format( batchIndex, 5 ) + "{0:0{1}x}".format( fl, 5 )
- ethSrc = ':'.join( ethS[ i:i + 2 ] for i in range( 0, len( ethS ), 2 ) )
- ethD = "%02X" % int( "1" + "{0:0{1}b}".format( dev, 7 ), 2 ) + \
- "{0:0{1}x}".format( batchIndex, 5 ) + "{0:0{1}x}".format( fl, 5 )
- ethDst = ':'.join( ethD[ i:i + 2 ] for i in range( 0, len( ethD ), 2 ) )
+ ethS = "%02X" %int( "0" + "{0:0{1}b}".format(dev,7), 2 ) + \
+ "{0:0{1}x}".format(batchIndex,5) + "{0:0{1}x}".format(fl,5)
+ ethSrc = ':'.join(ethS[i:i+2] for i in range(0,len(ethS),2))
+ ethD = "%02X" %int( "1" + "{0:0{1}b}".format(dev,7), 2 ) + \
+ "{0:0{1}x}".format(batchIndex,5) + "{0:0{1}x}".format(fl,5)
+ ethDst = ':'.join(ethD[i:i+2] for i in range(0,len(ethD),2))
if appId:
flowJson[ "appId" ] = appId
if egressPort:
flowJson[ 'treatment' ][ 'instructions' ].append( {
- "type": "OUTPUT",
- "port": egressPort } )
+ "type":"OUTPUT",
+ "port":egressPort } )
if ingressPort:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "IN_PORT",
- "port": ingressPort } )
+ "type":"IN_PORT",
+ "port":ingressPort } )
if ethType:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "ETH_TYPE",
- "ethType": ethType } )
+ "type":"ETH_TYPE",
+ "ethType":ethType } )
if ethSrc:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "ETH_SRC",
- "mac": ethSrc } )
+ "type":"ETH_SRC",
+ "mac":ethSrc } )
if ethDst:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "ETH_DST",
- "mac": ethDst } )
+ "type":"ETH_DST",
+ "mac":ethDst } )
if vlan:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "VLAN_VID",
- "vlanId": vlan } )
+ "type":"VLAN_VID",
+ "vlanId":vlan } )
if mpls:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "MPLS_LABEL",
- "label": mpls } )
+ "type":"MPLS_LABEL",
+ "label":mpls } )
if ipSrc:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": ipSrc[ 0 ],
- "ip": ipSrc[ 1 ] } )
+ "type":ipSrc[0],
+ "ip":ipSrc[1] } )
if ipDst:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": ipDst[ 0 ],
- "ip": ipDst[ 1 ] } )
+ "type":ipDst[0],
+ "ip":ipDst[1] } )
if tcpSrc:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "TCP_SRC",
+ "type":"TCP_SRC",
"tcpPort": tcpSrc } )
if tcpDst:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "TCP_DST",
+ "type":"TCP_DST",
"tcpPort": tcpDst } )
if udpSrc:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "UDP_SRC",
+ "type":"UDP_SRC",
"udpPort": udpSrc } )
if udpDst:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "UDP_DST",
+ "type":"UDP_DST",
"udpPort": udpDst } )
if ipProto:
flowJson[ 'selector' ][ 'criteria' ].append( {
- "type": "IP_PROTO",
+ "type":"IP_PROTO",
"protocol": ipProto } )
- # pprint( flowJson )
- flowJsonList.append( flowJson )
+ #pprint(flowJson)
+ flowJsonList.append(flowJson)
- main.log.info( "Number of flows in batch: " + str( len( flowJsonList ) ) )
- flowJsonBatch[ 'flows' ] = flowJsonList
- # pprint( flowJsonBatch )
+ main.log.info("Number of flows in batch: " + str( len(flowJsonList) ) )
+ flowJsonBatch['flows'] = flowJsonList
+ #pprint(flowJsonBatch)
return flowJsonBatch
+
def sendFlowBatch( self, batch={}, ip="DEFAULT", port="DEFAULT", debug=False ):
"""
Description:
@@ -1802,8 +1803,7 @@
import time
try:
- if debug:
- main.log.debug( "Adding flow: " + self.pprint( batch ) )
+ if debug: main.log.debug( "Adding flow: " + self.pprint( batch ) )
output = None
if ip == "DEFAULT":
main.log.warn( "No ip given, reverting to ip from topo file" )
@@ -1814,10 +1814,10 @@
port = self.port
url = "/flows/"
response = self.send( method="POST",
- url=url, ip=ip, port=port,
+ url=url, ip = ip, port = port,
data=json.dumps( batch ) )
- # main.log.info( "Post response is: ", str( response[ 0 ] ) )
- if response[ 0 ] == 200:
+ #main.log.info("Post response is: ", str(response[0]))
+ if response[0] == 200:
main.log.info( self.name + ": Successfully POST flow batch" )
return main.TRUE, response
else:
@@ -1834,7 +1834,7 @@
main.cleanAndExit()
def removeFlowBatch( self, batch={},
- ip="DEFAULT", port="DEFAULT" ):
+ ip="DEFAULT", port="DEFAULT" ):
"""
Description:
Remove a batch of flows
@@ -1856,8 +1856,8 @@
# NOTE: REST url requires the intent id to be in decimal form
response = self.send( method="DELETE",
- url="/flows/", ip=ip, port=port,
- data=json.dumps( batch ) )
+ url="/flows/", ip = ip, port = port,
+ data = json.dumps(batch) )
if response:
if 200 <= response[ 0 ] <= 299:
return main.TRUE
@@ -1882,7 +1882,7 @@
import json
try:
# either onos:topology or 'topology' will work in CLI
- topology = json.loads( topologyOutput )
+ topology = json.loads(topologyOutput)
main.log.debug( topology )
return topology
except pexpect.EOF:
@@ -1914,7 +1914,7 @@
"""
try:
topology = self.getTopology( self.topology() )
- # summary = self.summary()
+ #summary = self.summary()
if topology == {}:
return main.ERROR
output = ""
@@ -1978,7 +1978,7 @@
"appCookie": appCookie,
"groupId": groupId,
"buckets": bucketList
- }
+ }
return self.sendGroup( deviceId=deviceId, groupJson=groupJson, ip="DEFAULT", port="DEFAULT", debug=False )
except ( AttributeError, TypeError ):
@@ -2004,8 +2004,7 @@
of the ONOS node
"""
try:
- if debug:
- main.log.debug( "Adding group: " + self.pprint( groupJson ) )
+ if debug: main.log.debug( "Adding group: " + self.pprint( groupJson ) )
output = None
if ip == "DEFAULT":
main.log.warn( "No ip given, reverting to ip from topo file" )
@@ -2016,7 +2015,7 @@
port = self.port
url = "/groups/" + deviceId
response = self.send( method="POST",
- url=url, ip=ip, port=port,
+ url=url, ip = ip, port = port,
data=json.dumps( groupJson ) )
if response:
if "201" in str( response[ 0 ] ):
@@ -2065,8 +2064,8 @@
if deviceId:
url += "/" + deviceId
if appCookie:
- url += "/" + appCookie
- response = self.send( url=url, ip=ip, port=port )
+ url += "/" + appCookie
+ response = self.send( url=url, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
output = response[ 1 ]
@@ -2113,7 +2112,7 @@
port = self.port
query = "/" + str( deviceId ) + "/" + str( appCookie )
response = self.send( method="DELETE",
- url="/groups" + query, ip=ip, port=port )
+ url="/groups" + query, ip = ip, port = port )
if response:
if 200 <= response[ 0 ] <= 299:
return main.TRUE
@@ -2127,3 +2126,4 @@
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
+
diff --git a/TestON/drivers/common/api/controllerdriver.py b/TestON/drivers/common/api/controllerdriver.py
index 0c3305c..956374c 100644
--- a/TestON/drivers/common/api/controllerdriver.py
+++ b/TestON/drivers/common/api/controllerdriver.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
Created on 29-Nov-2012
-Copyright 2012 Open Networking Foundation ( ONF )
+Copyright 2012 Open Networking Foundation (ONF)
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -32,3 +32,4 @@
def __init__( self ):
super( Controller, self ).__init__()
+
diff --git a/TestON/drivers/common/api/dockerapidriver.py b/TestON/drivers/common/api/dockerapidriver.py
index 3b9b77a..3fac610 100644
--- a/TestON/drivers/common/api/dockerapidriver.py
+++ b/TestON/drivers/common/api/dockerapidriver.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
-Copyright 2016 Open Networking Foundation ( ONF )
+Copyright 2016 Open Networking Foundation (ONF)
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -9,7 +9,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- ( at your option ) any later version.
+ (at your option) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,6 +19,7 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
+
import json
import os
import re
@@ -27,7 +28,6 @@
from docker import errors
from drivers.common.apidriver import API
-
class DockerApiDriver( API ):
def __init__( self ):
@@ -55,7 +55,7 @@
self.home = "/var/tmp"
self.handle = super( DockerApiDriver, self ).connect()
- self.dockerClient = Client( base_url='unix://var/run/docker.sock' )
+ self.dockerClient = Client(base_url='unix://var/run/docker.sock')
return self.handle
except Exception as e:
main.log.exception( e )
@@ -72,29 +72,29 @@
if imageDict[ 'RepoTags' ] is not None:
if len( imageDict[ 'RepoTags' ] ) > 1:
duplicateTagDetected = 1
- imageListToSend.append( imageDict[ 'RepoTags' ][ 0 ].encode( 'UTF8' ).split( ':' )[ 1 ] )
+ imageListToSend.append( imageDict['RepoTags'][0].encode('UTF8').split(':')[1] )
return imageListToSend, duplicateTagDetected
except Exception as e:
main.log.exception( e )
- def dockerPull( self, onosRepo="onosproject/onos", onosTag="latest" ):
+ def dockerPull( self, onosRepo ="onosproject/onos", onosTag="latest" ):
"""
Pulls Docker image from repository
"""
try:
main.log.info( self.name +
- ": Pulling Docker image " + onosRepo + ":" + onosTag )
- for line in self.dockerClient.pull( repository=onosRepo,
- tag=onosTag, stream=True ):
- print "#",
- main.log.info( json.dumps( json.loads( line ), indent=4 ) )
+ ": Pulling Docker image " + onosRepo + ":"+ onosTag )
+ for line in self.dockerClient.pull( repository = onosRepo, \
+ tag = onosTag, stream = True ):
+ print "#",
+ main.log.info(json.dumps(json.loads(line), indent =4))
- # response = json.dumps( json.load( pullResult ), indent=4 )
+ #response = json.dumps( json.load( pullResult ), indent=4 )
if re.search( "for onosproject/onos:" + onosTag, line ):
main.log.info( "onos docker image pulled is: " + line )
return main.TRUE
else:
- main.log.error( "Failed to download image from: " + onosRepo + ":" + onosTag )
+ main.log.error( "Failed to download image from: " + onosRepo +":"+ onosTag )
main.log.error( "Error respone: " )
main.log.error( line )
return main.FALSE
@@ -109,17 +109,17 @@
try:
main.log.info( self.name +
": Creating Docker container for node: " + onosNode )
- response = self.dockerClient.create_container( image=onosImage,
- tty=True, name=onosNode, detach=True )
- # print response
- # print response.get( "Id" )
- # print response.get( "Warnings" )
- if( str( response.get( "Warnings" ) ) == 'None' ):
- main.log.info( "Created container for node: " + onosNode + "; container id is: " + response.get( "Id" ) )
- return ( main.TRUE, response.get( "Id" ) )
+ response = self.dockerClient.create_container( image=onosImage, \
+ tty=True, name=onosNode, detach=True )
+ #print response
+ #print response.get("Id")
+ #print response.get("Warnings")
+ if( str( response.get("Warnings") ) == 'None' ):
+ main.log.info( "Created container for node: " + onosNode + "; container id is: " + response.get("Id") )
+ return ( main.TRUE, response.get("Id") )
else:
main.log.info( "Noticed warnings during create" )
- return ( main.FALSE, null )
+ return ( main.FALSE, null)
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
@@ -131,7 +131,7 @@
try:
main.log.info( self.name +
": Starting Docker conatiner Id " + ctID )
- response = self.dockerClient.start( container=ctID )
+ response = self.dockerClient.start( container = ctID )
if response is None:
main.log.info( "Started container for Id: " + ctID )
return main.TRUE
@@ -157,11 +157,11 @@
main.log.info( "Noticed warnings during stop" )
return main.FALSE
except errors.NotFound:
- main.log.info( ctName + " not found! Continue on tests..." )
+ main.log.info( ctName + " not found! Continue on tests...")
return main.TRUE
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
- # main.cleanAndExit()
+ #main.cleanAndExit()
def dockerRestartCT( self, ctName ):
"""
@@ -181,27 +181,27 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
- def dockerCheckCTName( self, ctName ):
+ def dockerCheckCTName( self, ctName):
"""
Check Docker conatiner status
"""
try:
main.log.info( self.name +
": Checking Docker Status for CT with 'Names' " + ctName )
- namelist = [ response[ "Names" ] for response in self.dockerClient.containers( all=True ) if not [] ]
- main.log.info( "Name list is: " + str( namelist ) )
- if( [ ctName ] in namelist ):
+ namelist = [response["Names"] for response in self.dockerClient.containers(all=True) if not []]
+ main.log.info("Name list is: " + str(namelist) )
+ if( [ctName] in namelist):
main.log.info( "Container " + ctName + " exists" )
return main.TRUE
else:
main.log.info( "Container " + ctName + " does not exist" )
return main.FALSE
except errors.NotFound:
- main.log.warn( ctName + "not found! Continue with the tests..." )
+ main.log.warn( ctName + "not found! Continue with the tests...")
return main.FALSE
except Exception:
main.log.exception( self.name + ": Uncaught exception! Continue tests..." )
- # main.cleanAndExit()
+ #main.cleanAndExit()
def dockerRemoveCT( self, ctName ):
"""
@@ -215,15 +215,15 @@
main.log.info( "Removed container for node: " + ctName )
return main.TRUE
else:
- main.log.info( "Noticed warnings during Remove " + ctName )
+ main.log.info( "Noticed warnings during Remove " + ctName)
return main.FALSE
- main.log.exception( self.name + ": not found, continuing..." )
+ main.log.exception(self.name + ": not found, continuing...")
except errors.NotFound:
- main.log.warn( ctName + "not found! Continue with the tests..." )
+ main.log.warn( ctName + "not found! Continue with the tests...")
return main.TRUE
except Exception:
main.log.exception( self.name + ": Uncaught exception! Continuing..." )
- # main.cleanAndExit()
+ #main.cleanAndExit()
def dockerRemoveImage( self, imageRepoTag=None ):
"""
@@ -234,13 +234,13 @@
main.log.info( "No docker image found" )
return rmResult
else:
- imageList = [ image[ "Id" ] for image in self.dockerClient.images()
- if image[ "RepoTags" ] is None
- or imageRepoTag in image[ "RepoTags" ] ]
+ imageList = [ image["Id"] for image in self.dockerClient.images()
+ if image["RepoTags"] is None
+ or imageRepoTag in image["RepoTags"] ]
for id in imageList:
try:
main.log.info( self.name + ": Removing Docker image " + id )
- response = self.dockerClient.remove_image( id, force=True )
+ response = self.dockerClient.remove_image(id, force = True)
if response is None:
main.log.info( "Removed Docker image: " + id )
rmResult = rmResult and main.TRUE
@@ -248,12 +248,12 @@
main.log.info( "Noticed warnings during Remove " + id )
rmResult = rmResult and main.FALSE
except errors.NotFound:
- main.log.warn( image + "not found! Continue with the tests..." )
+ main.log.warn( image + "not found! Continue with the tests...")
rmResult = rmResult and main.TRUE
except Exception:
main.log.exception( self.name + ": Uncaught exception! Continuing..." )
rmResult = rmResult and main.FALSE
- # main.cleanAndExit()
+ #main.cleanAndExit()
return rmResult
def fetchLatestClusterFile( self, branch="master" ):
@@ -263,7 +263,7 @@
try:
command = "wget -N https://raw.githubusercontent.com/opennetworkinglab/\
onos/" + branch + "/tools/package/bin/onos-form-cluster"
- subprocess.call( command ) # output checks are missing for now
+ subprocess.call( command ) # output checks are missing for now
command = "chmod u+x " + "onos-form-cluster"
subprocess.call( command )
return main.TRUE
@@ -276,7 +276,7 @@
From ONOS cluster for IP addresses in onosIPs list
"""
try:
- onosIPs = " ".join( onosIPs )
+ onosIPs = " ".join(onosIPs)
command = "{}/onos-form-cluster -u {} -p {} {}".format( cmdPath,
user,
passwd,
@@ -285,7 +285,7 @@
if result == 0:
return main.TRUE
else:
- main.log.info( "Something is not right in forming cluster>" )
+ main.log.info("Something is not right in forming cluster>")
return main.FALSE
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
@@ -297,10 +297,11 @@
"""
try:
output = self.dockerClient.inspect_container( ctName )
- nodeIP = output[ 'NetworkSettings' ][ 'IPAddress' ]
- main.log.info( " Docker IP " + str( nodeIP ) )
- return str( nodeIP )
+ nodeIP = output['NetworkSettings']['IPAddress']
+ main.log.info( " Docker IP " + str(nodeIP) )
+ return str(nodeIP)
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
+
diff --git a/TestON/drivers/common/api/fvtapidriver.py b/TestON/drivers/common/api/fvtapidriver.py
index c44d32d..4f20c89 100644
--- a/TestON/drivers/common/api/fvtapidriver.py
+++ b/TestON/drivers/common/api/fvtapidriver.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""
Created on 26-Oct-2012
-Copyright 2012 Open Networking Foundation ( ONF )
+Copyright 2012 Open Networking Foundation (ONF)
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -25,7 +25,8 @@
fvtapidriver is the basic driver which will handle the fvtapidriver functions
-""""""
+"""
+"""
There are two changes required in flowvisor-test framework :
1. In ~/flowvisortests/tests/templatetest.py line : 15 comment 'basic_logger = None'
@@ -187,3 +188,4 @@
# self.logfile_handler.close()
return main.TRUE
+