Run codecheck script on FUNCnetconf
Change-Id: If73187519cd3a6548b0714547e90c6c7a0b9cb31
diff --git a/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py b/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py
index 7154a28..757487f 100644
--- a/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py
+++ b/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py
@@ -1,5 +1,6 @@
# Testing the NETCONF protocol within ONOS
+
class FUNCnetconf:
def __init__( self ):
@@ -19,7 +20,6 @@
- Install ONOS package
- Build ONOS package
"""
-
main.case( "Constructing test variables and building ONOS package" )
main.step( "Constructing test variables" )
main.caseExplanation = "This test case is mainly for loading " +\
@@ -55,10 +55,10 @@
main.configName = main.params[ 'CONFIGURE' ][ 'cfgName' ]
main.configPass = main.params[ 'CONFIGURE' ][ 'cfgPass' ]
main.configPort = main.params[ 'CONFIGURE' ][ 'cfgAppPort' ]
- main.cycle = 0 # How many times FUNCintent has run through its tests
+ main.cycle = 0 # How many times FUNCintent has run through its tests
gitPull = main.params[ 'GIT' ][ 'pull' ]
- main.cellData = {} # for creating cell file
+ main.cellData = {} # for creating cell file
main.hostsData = {}
main.CLIs = []
main.CLIs2 = []
@@ -69,7 +69,7 @@
print main.ONOSip
# Assigning ONOS cli handles to a list
- for i in range( 1, main.maxNodes + 1 ):
+ for i in range( 1, main.maxNodes + 1 ):
main.CLIs.append( getattr( main, 'ONOSrest' + str( i ) ) )
main.CLIs2.append( getattr( main, 'ONOScli' + str( i ) ) )
@@ -80,9 +80,9 @@
".py" )
main.netconfFunction = imp.load_source( wrapperFile2,
- main.dependencyPath +
- wrapperFile2 +
- ".py" )
+ main.dependencyPath +
+ wrapperFile2 +
+ ".py" )
main.topo = imp.load_source( wrapperFile3,
main.dependencyPath +
@@ -102,7 +102,7 @@
main.log.error( "Did not properly created list of ONOS CLI handle" )
stepResult = main.FALSE
except Exception as e:
- main.log.exception(e)
+ main.log.exception( e )
main.cleanup()
main.exit()
@@ -139,7 +139,6 @@
- Install ONOS cluster
- Connect to cli
"""
-
main.cycle += 1
# main.scale[ 0 ] determines the current number of ONOS controller
@@ -150,14 +149,10 @@
main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
" node(s) ONOS cluster"
-
-
#kill off all onos processes
main.log.info( "Safety check, killing all ONOS processes" +
" before initiating environment setup" )
-
-
time.sleep( main.startUpSleep )
main.step( "Uninstalling ONOS package" )
onosUninstallResult = main.TRUE
@@ -177,7 +172,7 @@
tempOnosIp = []
for i in range( main.numCtrls ):
- tempOnosIp.append( main.ONOSip[i] )
+ tempOnosIp.append( main.ONOSip[ i ] )
main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
"temp", main.Mininet1.ip_address,
@@ -189,7 +184,7 @@
stepResult = cellResult and verifyResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Successfully applied cell to " + \
+ onpass="Successfully applied cell to " +
"environment",
onfail="Failed to apply cell to environment " )
@@ -217,7 +212,7 @@
main.step( "Set up ONOS secure SSH" )
secureSshResult = main.TRUE
for i in range( int( main.numCtrls ) ):
- secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
+ secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[ i ] )
utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
onpass="Test step PASS",
onfail="Test step FAIL" )
@@ -281,14 +276,14 @@
main.node = main.CLIs2[ i ]
ip = main.ONOSip[ i ]
main.node.ip_address = ip
- scpResult = scpResult and main.ONOSbench.scp( main.node ,
- "/opt/onos/log/karaf.log",
- "/tmp/karaf.log",
- direction="from" )
+ scpResult = scpResult and main.ONOSbench.scp( main.node,
+ "/opt/onos/log/karaf.log",
+ "/tmp/karaf.log",
+ direction="from" )
copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
if scpResult and copyResult:
- stepResult = main.TRUE and stepResult
+ stepResult = main.TRUE and stepResult
else:
stepResult = main.FALSE and stepResult
utilities.assert_equals( expect=main.TRUE,
@@ -364,7 +359,7 @@
main.testName = "Uploading the configuration"
main.case( main.testName + " Test - " + str( main.numCtrls ) +
" NODES(S)" )
- main.step( "Sending the configuration file")
+ main.step( "Sending the configuration file" )
main.assertReturnString = "Assertion result for sending the configuration file"
testResult = main.FALSE
diff --git a/TestON/tests/FUNC/FUNCnetconf/dependencies/netconf.py b/TestON/tests/FUNC/FUNCnetconf/dependencies/netconf.py
index 27ead3e..4b0ce12 100644
--- a/TestON/tests/FUNC/FUNCnetconf/dependencies/netconf.py
+++ b/TestON/tests/FUNC/FUNCnetconf/dependencies/netconf.py
@@ -7,24 +7,25 @@
import json
import os
+
def __init__( self ):
self.default = ''
+
def startApp( main ):
"""
This function starts the netconf app in all onos nodes and ensures that
the OF-Config server is running on the node to be configured
"""
-
startResult = main.FALSE
startResult = main.CLIs[ 0 ].activateApp( appName="org.onosproject.netconf" )
return startResult
+
def startOFC( main ):
"""
This function uses pexpect pxssh class to activate the ofc-server daemon on OC2
"""
-
startResult = main.FALSE
try:
main.ONOSbench.handle.sendline( "" )
@@ -46,6 +47,7 @@
main.cleanup()
main.exit()
+
def createConfig( main ):
"""
This function writes a configuration file that can later be sent to the
@@ -55,8 +57,8 @@
"""
createCfgResult = main.FALSE
# TODO, add ability to set Manufacturer, Hardware and Software versions
- main.cfgJson = '{ "devices":{ "netconf:'+ main.configDeviceIp + ":" +\
- main.configDevicePort + '":' + '{ "basic":{ "driver":"'+\
+ main.cfgJson = '{ "devices":{ "netconf:' + main.configDeviceIp + ":" +\
+ main.configDevicePort + '":' + '{ "basic":{ "driver":"' +\
main.configDriver + '" } } }, "apps": { "' +\
main.configApps + '":{ "devices":[ { "username":' +\
main.configName + ', "password":' + main.configPass +\
@@ -70,7 +72,7 @@
# configured.
# main.cfgJson = json.loads( main.cfgJson )
# main.cfgJson = json.dumps( main.cfgJson, sort_keys=True,
- # indent=4, separators=(',', ': '))
+ # indent=4, separators=( ',', ': ' ) )
print main.cfgJson
file.write( main.cfgJson )
if file:
@@ -78,12 +80,13 @@
file.close()
return createCfgResult
else:
- main.log.error( "There was an error opening the file")
+ main.log.error( "There was an error opening the file" )
return createCfgResult
except:
- main.log.exception( "There was an error opening the file")
+ main.log.exception( "There was an error opening the file" )
return createCfgResult
+
def sendConfig( main ):
"""
This function prepares the command needed to upload the configuration
@@ -95,13 +98,14 @@
configResult = main.FALSE
sendResult = main.CLIs[ 0 ].send( url=url, method=method, data=data )
main.log.info( "Device configuration request response code: " + str( sendResult[ 0 ] ) )
- if ( 200 <= sendResult[ 0 ] <= 299):
+ if ( 200 <= sendResult[ 0 ] <= 299 ):
configResult = main.TRUE
else:
configResult = main.FALSE
return configResult
+
def devices( main ):
"""
This function get the list of devices from the REST API, the ONOS CLI, and
@@ -123,7 +127,7 @@
main.log.info( "API device availability result: " + str( apiDict[ 0 ].get( "available" ) ) )
main.log.info( "CLI device availability result: " + str( cliDict[ 0 ].get( "available" ) ) )
- if apiDict[ 0 ].get( "available" ) == True and cliDict[ 0 ].get( "available" ) == True:
+ if apiDict[ 0 ].get( "available" ) and cliDict[ 0 ].get( "available" ):
availResult = main.TRUE
main.log.info( "API device type result: " + apiDict[ 0 ].get( "type" ) )
main.log.info( "CLI device type result: " + cliDict[ 0 ].get( "type" ) )
diff --git a/TestON/tests/FUNC/FUNCnetconf/dependencies/startUp.py b/TestON/tests/FUNC/FUNCnetconf/dependencies/startUp.py
index bf2a2b6..8122586 100644
--- a/TestON/tests/FUNC/FUNCnetconf/dependencies/startUp.py
+++ b/TestON/tests/FUNC/FUNCnetconf/dependencies/startUp.py
@@ -1,16 +1,15 @@
"""
This wrapper function is use for starting up onos instance
"""
-
import time
import os
import json
+
def onosBuild( main, gitBranch ):
"""
This includes pulling ONOS and building it using maven install
"""
-
buildResult = main.FALSE
# Git checkout a branch of ONOS
@@ -18,10 +17,10 @@
# Does the git pull on the branch that was checked out
if not checkOutResult:
main.log.warn( "Failed to checked out " + gitBranch +
- " branch")
+ " branch" )
else:
main.log.info( "Successfully checked out " + gitBranch +
- " branch")
+ " branch" )
gitPullResult = main.ONOSbench.gitPull()
if gitPullResult == main.ERROR:
main.log.error( "Error pulling git branch" )
@@ -32,7 +31,3 @@
buildResult = main.ONOSbench.cleanInstall()
return buildResult
-
-
-
-
diff --git a/TestON/tests/FUNC/FUNCnetconf/dependencies/topo.py b/TestON/tests/FUNC/FUNCnetconf/dependencies/topo.py
index b44e3fc..7217d4d 100644
--- a/TestON/tests/FUNC/FUNCnetconf/dependencies/topo.py
+++ b/TestON/tests/FUNC/FUNCnetconf/dependencies/topo.py
@@ -1,11 +1,11 @@
"""
These functions can be used for topology comparisons
"""
-
import time
import os
import json
+
def getAllDevices( main ):
"""
Return a list containing the devices output from each ONOS node
@@ -13,9 +13,9 @@
devices = []
threads = []
for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[i].devices,
+ t = main.Thread( target=main.CLIs[ i ].devices,
name="devices-" + str( i ),
- args=[ ] )
+ args=[] )
threads.append( t )
t.start()
@@ -24,6 +24,7 @@
devices.append( t.result )
return devices
+
def getAllHosts( main ):
"""
Return a list containing the hosts output from each ONOS node
@@ -32,9 +33,9 @@
ipResult = main.TRUE
threads = []
for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[i].hosts,
+ t = main.Thread( target=main.CLIs[ i ].hosts,
name="hosts-" + str( i ),
- args=[ ] )
+ args=[] )
threads.append( t )
t.start()
@@ -43,6 +44,7 @@
hosts.append( t.result )
return hosts
+
def getAllPorts( main ):
"""
Return a list containing the ports output from each ONOS node
@@ -50,9 +52,9 @@
ports = []
threads = []
for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[i].ports,
+ t = main.Thread( target=main.CLIs[ i ].ports,
name="ports-" + str( i ),
- args=[ ] )
+ args=[] )
threads.append( t )
t.start()
@@ -61,6 +63,7 @@
ports.append( t.result )
return ports
+
def getAllLinks( main ):
"""
Return a list containing the links output from each ONOS node
@@ -68,9 +71,9 @@
links = []
threads = []
for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[i].links,
+ t = main.Thread( target=main.CLIs[ i ].links,
name="links-" + str( i ),
- args=[ ] )
+ args=[] )
threads.append( t )
t.start()
@@ -79,6 +82,7 @@
links.append( t.result )
return links
+
def getAllClusters( main ):
"""
Return a list containing the clusters output from each ONOS node
@@ -86,9 +90,9 @@
clusters = []
threads = []
for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[i].clusters,
+ t = main.Thread( target=main.CLIs[ i ].clusters,
name="clusters-" + str( i ),
- args=[ ] )
+ args=[] )
threads.append( t )
t.start()
@@ -96,5 +100,3 @@
t.join()
clusters.append( t.result )
return clusters
-
-