Fix whitespace issues
Change-Id: I7c96843996f4847f9e15022f1dc6cd85e8a092f7
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 64bc40f..b6965d3 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -165,12 +165,12 @@
def getEpochMs( self ):
"""
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.
+
+ 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.
"""
try:
self.handle.sendline( 'date +%s.%N' )
@@ -816,8 +816,8 @@
def onosCfgSet( self, ONOSIp, configName, configParam ):
"""
Uses 'onos <node-ip> cfg set' to change a parameter value of an
- application.
-
+ application.
+
ex)
onos 10.0.0.1 cfg set org.onosproject.myapp appSetting 1
ONOSIp = '10.0.0.1'
@@ -834,19 +834,19 @@
self.handle.sendline( "" )
self.handle.expect( ":~" )
self.handle.sendline( cfgStr )
- self.handle.expect("cfg set")
+ self.handle.expect("cfg set")
self.handle.expect( ":~" )
-
+
paramValue = configParam.split(" ")[1]
paramName = configParam.split(" ")[0]
-
+
checkStr = ( "onos " + str(ONOSIp) + """ cfg get " """ + str(configName) + " " + paramName + """ " """)
self.handle.sendline( checkStr )
self.handle.expect( ":~" )
if "value=" + paramValue + "," in self.handle.before:
- main.log.info("cfg " + configName + " successfully set to " + configParam)
+ main.log.info("cfg " + configName + " successfully set to " + configParam)
return main.TRUE
except pexpect.ExceptionPexpect as e:
@@ -860,17 +860,17 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
-
+
time.sleep(5)
main.log.error("CFG SET FAILURE: " + configName + " " + configParam )
- main.ONOSbench.handle.sendline("onos $OC1 cfg get")
+ main.ONOSbench.handle.sendline("onos $OC1 cfg get")
main.ONOSbench.handle.expect("\$")
print main.ONOSbench.handle.before
main.ONOSbench.logReport( ONOSIp, ["ERROR","WARN","EXCEPT"], "d")
return main.FALSE
-
+
def onosCli( self, ONOSIp, cmdstr ):
"""
Uses 'onos' command to send various ONOS CLI arguments.
@@ -1489,7 +1489,7 @@
* directory to store results
Optional:
* interface - default: eth0
- * grepOptions - options for grep
+ * grepOptions - options for grep
Description:
Uses tshark command to grep specific group of packets
and stores the results to specified directory.
@@ -1503,7 +1503,7 @@
grepStr = "grep "+str(grepOptions)
else:
grepStr = "grep"
-
+
cmd = (
"sudo tshark -i " +
str( interface ) +
@@ -1853,37 +1853,37 @@
def 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
+ 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
+ ONOSIpList - list of all of the node IPs to be used
+
+ deviceCount - number of switches to be assigned
'''
main.log.step("Creating link graph configuration file." )
linkGraphPath = self.home + "/tools/package/etc/linkGraph.cfg"
- tempFile = "/tmp/linkGraph.cfg"
+ tempFile = "/tmp/linkGraph.cfg"
linkGraph = open(tempFile, 'w+')
linkGraph.write("# NullLinkProvider topology description (config file).\n")
linkGraph.write("# The NodeId is only added if the destination is another node's device.\n")
linkGraph.write("# Bugs: Comments cannot be appended to a line to be read.\n")
-
+
clusterCount = len(ONOSIpList)
-
- if type(deviceCount) is int or type(deviceCount) is str:
+
+ if type(deviceCount) is int or type(deviceCount) is str:
deviceCount = int(deviceCount)
switchList = [0]*(clusterCount+1)
baselineSwitchCount = deviceCount/clusterCount
-
+
for node in range(1, clusterCount + 1):
switchList[node] = baselineSwitchCount
for node in range(1, (deviceCount%clusterCount)+1):
switchList[node] += 1
-
+
if type(deviceCount) is list:
main.log.info("Using provided device distribution")
switchList = [0]
@@ -1901,48 +1901,48 @@
continue
linkGraph.write("graph " + ONOSIpList[node] + " {\n")
-
+
if node > 1:
#connect to last device on previous node
- line = ("\t0:5 -> " + str(lastSwitch) + ":6:" + lastIp + "\n") #ONOSIpList[node-1]
- linkGraph.write(line)
-
- lastSwitch = 0
- for switch in range (0, switchList[node]-1):
+ line = ("\t0:5 -> " + str(lastSwitch) + ":6:" + lastIp + "\n") #ONOSIpList[node-1]
+ linkGraph.write(line)
+
+ lastSwitch = 0
+ for switch in range (0, switchList[node]-1):
line = ""
line = ("\t" + str(switch) + ":" + str(myPort))
line += " -- "
line += (str(switch+1) + ":" + str(myPort-1) + "\n")
linkGraph.write(line)
- lastSwitch = switch+1
+ lastSwitch = switch+1
lastIp = ONOSIpList[node]
-
+
#lastSwitch += 1
- if node < (clusterCount):
+ if node < (clusterCount):
#connect to first device on the next node
- line = ("\t" + str(lastSwitch) + ":6 -> 0:5:" + ONOSIpList[node+1] + "\n")
+ line = ("\t" + str(lastSwitch) + ":6 -> 0:5:" + ONOSIpList[node+1] + "\n")
linkGraph.write(line)
-
+
linkGraph.write("}\n")
linkGraph.close()
#SCP
- os.system( "scp " + tempFile + " " + self.user_name + "@" + benchIp + ":" + linkGraphPath)
+ os.system( "scp " + tempFile + " " + self.user_name + "@" + benchIp + ":" + linkGraphPath)
main.log.info("linkGraph.cfg creation complete")
def 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
+ 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
'''
main.log.step("Configuring Null Device Provider" )
clusterCount = len(ONOSIpList)
- try:
-
+ try:
+
if type(deviceCount) is int or type(deviceCount) is str:
main.log.step("Creating device distribution")
deviceCount = int(deviceCount)
@@ -1954,22 +1954,22 @@
for node in range(1, (deviceCount%clusterCount)+1):
switchList[node] += 1
-
- if type(deviceCount) is list:
- main.log.info("Using provided device distribution")
-
- if len(deviceCount) == clusterCount:
+
+ if type(deviceCount) is list:
+ main.log.info("Using provided device distribution")
+
+ if len(deviceCount) == clusterCount:
switchList = ['0']
switchList.extend(deviceCount)
-
- if len(deviceCount) == (clusterCount + 1):
- if deviceCount[0] == '0' or deviceCount[0] == 0:
+
+ if len(deviceCount) == (clusterCount + 1):
+ if deviceCount[0] == '0' or deviceCount[0] == 0:
switchList = deviceCount
assert len(switchList) == (clusterCount + 1)
-
+
except AssertionError:
- main.log.error( "Bad device/Ip list match")
+ main.log.error( "Bad device/Ip list match")
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
return None
@@ -1981,14 +1981,14 @@
ONOSIp = [0]
ONOSIp.extend(ONOSIpList)
-
+
devicesString = "devConfigs = "
for node in range(1, len(ONOSIp)):
devicesString += (ONOSIp[node] + ":" + str(switchList[node] ))
if node < clusterCount:
devicesString += (",")
-
- try:
+
+ try:
self.handle.sendline("onos $OC1 cfg set org.onosproject.provider.nil.device.impl.NullDeviceProvider devConfigs " + devicesString )
self.handle.expect(":~")
self.handle.sendline("onos $OC1 cfg set org.onosproject.provider.nil.device.impl.NullDeviceProvider numPorts " + str(numPorts) )
@@ -2004,7 +2004,7 @@
time.sleep(1)
assert ("value=" + str(numPorts)) in verification and (" value=" + devicesString) in verification
-
+
except AssertionError:
main.log.error("Incorrect Config settings: " + verification)
except Exception:
@@ -2012,30 +2012,30 @@
main.cleanup()
main.exit()
- def configNullLink( self,fileName="/opt/onos/apache-karaf-3.0.3/etc/linkGraph.cfg", eventRate=0):
+ def 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
+ 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
'''
-
- try:
- self.handle.sendline("onos $OC1 cfg set org.onosproject.provider.nil.link.impl.NullLinkProvider eventRate " + str(eventRate))
- self.handle.expect(":~")
+
+ try:
+ self.handle.sendline("onos $OC1 cfg set org.onosproject.provider.nil.link.impl.NullLinkProvider eventRate " + str(eventRate))
+ self.handle.expect(":~")
self.handle.sendline("onos $OC1 cfg set org.onosproject.provider.nil.link.impl.NullLinkProvider cfgFile " + fileName )
self.handle.expect(":~")
-
- for i in range(10):
- self.handle.sendline("onos $OC1 cfg get org.onosproject.provider.nil.link.impl.NullLinkProvider")
+
+ for i in range(10):
+ self.handle.sendline("onos $OC1 cfg get org.onosproject.provider.nil.link.impl.NullLinkProvider")
self.handle.expect(":~")
verification = self.handle.before
- if (" value=" + str(eventRate)) in verification and (" value=" + fileName) in verification:
+ if (" value=" + str(eventRate)) in verification and (" value=" + fileName) in verification:
break
- else:
+ else:
time.sleep(1)
-
+
assert ("value=" + str(eventRate)) in verification and (" value=" + fileName) in verification
-
+
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -2043,7 +2043,7 @@
main.exit()
except AssertionError:
main.log.info("Settings did not post to ONOS")
- main.log.error(varification)
+ main.log.error(varification)
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.log.error(varification)
@@ -2060,33 +2060,33 @@
def 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
+ 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
+ - 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
+ - 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
+ line for each of the last 5 occurences
- returns total of the number of instances of all search terms
'''
main.log.info("========================== Log Report ===========================\n")
- if type(searchTerms) is str:
+ if type(searchTerms) is str:
searchTerms = [searchTerms]
logLines = [ [" "] for i in range(len(searchTerms)) ]
- for term in range(len(searchTerms)):
+ for term in range(len(searchTerms)):
logLines[term][0] = searchTerms[term]
- totalHits = 0
- for term in range(len(searchTerms)):
- cmd = "onos-ssh " + nodeIp + " cat /opt/onos/log/karaf.log | grep " + searchTerms[term]
+ totalHits = 0
+ for term in range(len(searchTerms)):
+ cmd = "onos-ssh " + nodeIp + " cat /opt/onos/log/karaf.log | grep " + searchTerms[term]
self.handle.sendline(cmd)
self.handle.expect(":~")
before = (self.handle.before).splitlines()
@@ -2095,25 +2095,25 @@
for line in before:
if searchTerms[term] in line and "grep" not in line:
- count[1] += 1
+ count[1] += 1
if before.index(line) > ( len(before) - 7 ):
logLines[term].append(line)
main.log.info( str(count[0]) + ": " + str(count[1]) )
- if term == len(searchTerms)-1:
+ if term == len(searchTerms)-1:
print("\n")
- totalHits += int(count[1])
+ totalHits += int(count[1])
- if outputMode != "s" and outputMode != "S":
+ if outputMode != "s" and outputMode != "S":
outputString = ""
for i in logLines:
- outputString = i[0] + ": \n"
- for x in range(1,len(i)):
- outputString += ( i[x] + "\n" )
-
+ outputString = i[0] + ": \n"
+ for x in range(1,len(i)):
+ outputString += ( i[x] + "\n" )
+
if outputString != (i[0] + ": \n"):
- main.log.info(outputString)
-
+ main.log.info(outputString)
+
main.log.info("================================================================\n")
return totalHits
@@ -2174,7 +2174,7 @@
main.exit()
def jvmSet(self, memory=8):
-
+
import os
homeDir = os.path.expanduser('~')
@@ -2192,22 +2192,22 @@
serviceConfig.close()
def createDBFile(self, testData):
-
+
filename = main.TEST + "DB"
DBString = ""
-
+
for item in testData:
- if type(item) is string:
+ if type(item) is string:
item = "'" + item + "'"
if testData.index(item) < len(testData-1):
item += ","
- DBString += str(item)
+ DBString += str(item)
DBFile = open(filename, "a")
DBFile.write(DBString)
DBFile.close()
- def verifySummary(self, ONOSIp,*deviceCount):
+ def verifySummary(self, ONOSIp,*deviceCount):
self.handle.sendline("onos " + ONOSIp + " summary")
self.handle.expect(":~")
@@ -2219,12 +2219,12 @@
#if deviceCount:
# passed = "devices=" + str(deviceCount) + "," not in summaryStr
-
+
if "SCC(s)=1," in summaryStr:
passed = True
print("Summary is verifed")
- else:
- print("Summary failed")
+ else:
+ print("Summary failed")
if deviceCount:
print" ============================="
@@ -2232,8 +2232,8 @@
print "Checkstr: " + checkStr
if checkStr not in summaryStr:
passed = False
- print("Device count failed")
- else:
- print "device count verified"
+ print("Device count failed")
+ else:
+ print "device count verified"
return passed
diff --git a/TestON/drivers/common/cli/quaggaclidriver.py b/TestON/drivers/common/cli/quaggaclidriver.py
index d325232..e89047e 100644
--- a/TestON/drivers/common/cli/quaggaclidriver.py
+++ b/TestON/drivers/common/cli/quaggaclidriver.py
@@ -381,7 +381,7 @@
chunk_size = 20
if len(routes) > chunk_size:
- num_iter = (int) (len(routes) / chunk_size)
+ num_iter = (int) (len(routes) / chunk_size)
else:
num_iter = 1;
@@ -403,7 +403,7 @@
except Exception:
main.log.warn( "Failed to add route" )
self.disconnect()
-
+
# waitTimer = 1.00 / routeRate
main.log.info("Total routes so far " + ((str) (total)) + " wait for 0 sec")
#time.sleep( 1 )
diff --git a/TestON/drivers/common/cli/tool/dpctlclidriver.py b/TestON/drivers/common/cli/tool/dpctlclidriver.py
index 1e5f839..504567c 100644
--- a/TestON/drivers/common/cli/tool/dpctlclidriver.py
+++ b/TestON/drivers/common/cli/tool/dpctlclidriver.py
@@ -44,10 +44,10 @@
self.name = self.options[ 'name' ]
self.handle = super(
- DpctlCliDriver, self ).connect( user_name=self.user_name,
- ip_address=self.ip_address,
- port=None,
- pwd=self.pwd )
+ DpctlCliDriver, self ).connect( user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=None,
+ pwd=self.pwd )
if self.handle:
main.log.info( "Connected to the host" )
return main.TRUE
@@ -64,12 +64,12 @@
addFlow create a new flow entry into flow table using "dpctl"
"""
args = utilities.parse_args( [
- "TCPIP",
+ "TCPIP",
"TCPPORT",
"INPORT",
"ACTION",
"TIMEOUT" ],
- **flowParameters )
+ **flowParameters )
cmd = "dpctl add-flow tcp:"
tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
@@ -250,10 +250,10 @@
desc_set Sets the switch description ( as returned in ofp_desc_stats ) to string ( max length is DESC_STR_LEN )
"""
args = utilities.parse_args( [
- "TCPIP",
+ "TCPIP",
"TCPPORT",
"STRING" ],
- **flowParameters )
+ **flowParameters )
tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
tcpPort = args[ "TCPPORT" ] if args[
@@ -278,10 +278,10 @@
dumpDesc Sets the switch description ( as returned in ofp_desc_stats ) to string ( max length is DESC_STR_LEN )
"""
args = utilities.parse_args( [
- "TCPIP",
+ "TCPIP",
"TCPPORT",
"STRING" ],
- **flowParameters )
+ **flowParameters )
tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1"
tcpPort = args[ "TCPPORT" ] if args[