[ONOS-2424] Move flowTable functions from remotemininetdriver to mininetdriver
also refactor getFlowTables
remove unused function
Change-Id: I7be74b4222d4b680e82a22eeded8b6a615783a16
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index e988577..af660d7 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -1733,6 +1733,58 @@
main.cleanup()
main.exit()
+ def getFlowTable( self, protoVersion, sw ):
+ """
+ Returns certain fields of an OVS flow table. Will force output to
+ either OF 1.0 or 1.3 format for consistency.
+
+ TODO add option to look at cookies. ignoring them for now
+
+ NOTE: Use format to force consistent flow table output across
+ versions
+ """
+ try:
+ self.handle.sendline( "" )
+ self.handle.expect( "mininet>" )
+ command = "sh ovs-ofctl dump-flows " + sw
+ if protoVersion == 1.0:
+ command += " -F OpenFlow10-table_id | awk '{OFS=\",\" ;" +\
+ " print $1 $3 $6 $7 $8}' | "
+ elif protoVersion == 1.3:
+ command += " -O OpenFlow13 | awk '{OFS=\",\" ;" +\
+ " print $1 $3 $6 $7}' | "
+ else:
+ main.log.error(
+ "Unknown protoVersion in getFlowTable(). given: (" +
+ str( type( protoVersion ) ) +
+ ") '" + str( protoVersion ) + "'" )
+ return None
+ command += "cut -d ',' -f 2- | sort -n -k1 -r"
+ self.handle.sendline( command )
+ self.handle.expect( "sort" )
+ self.handle.expect( "OFPST_FLOW" )
+ response = self.handle.before
+ return response
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except pexpect.TIMEOUT:
+ main.log.exception( self.name + ": Timeout exception: " )
+ return None
+
+ def flowComp( self, flow1, flow2 ):
+ if flow1 == flow2:
+ return main.TRUE
+ else:
+ main.log.info( "Flow tables do not match, printing tables:" )
+ main.log.info( "Flow Table 1:" )
+ main.log.info( flow1 )
+ main.log.info( "Flow Table 2:" )
+ main.log.info( flow2 )
+ return main.FALSE
+
def startTcpdump( self, filename, intf="eth0", port="port 6633" ):
"""
Runs tpdump on an interface and saves the file
diff --git a/TestON/drivers/common/cli/emulator/remotemininetdriver.py b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
index f11c172..6b7197f 100644
--- a/TestON/drivers/common/cli/emulator/remotemininetdriver.py
+++ b/TestON/drivers/common/cli/emulator/remotemininetdriver.py
@@ -112,31 +112,6 @@
main.log.warn( outputs )
return main.TRUE
- def arping( self, host="", ip="10.128.20.211" ):
- """
- Description:
- Sends arp message from mininet host for hosts discovery
- Required:
- host - hosts name
- Optional:
- ip - ip address that does not exist in the network so there would
- be no reply.
- """
- cmd = " py " + host + ".cmd(\"arping -c 1 " + ip + "\")"
- try:
- main.log.warn( "Sending: " + cmd )
- self.handle.sendline( cmd )
- response = self.handle.before
- self.handle.sendline( "" )
- self.handle.expect( "mininet>" )
- return main.TRUE
-
- except pexpect.EOF:
- main.log.error( self.name + ": EOF exception found" )
- main.log.error( self.name + ": " + self.handle.before )
- main.cleanup()
- main.exit()
-
def pingLong( self, **pingParams ):
"""
Starts a continuous ping on the mininet host outputting
@@ -480,63 +455,6 @@
main.log.error( "Connection failed to the host" )
return main.TRUE
- def getFlowTable( self, protoVersion, sw ):
- """
- TODO document usage
- TODO add option to look at cookies. ignoring them for now
-
- print "get_flowTable(" + str( protoVersion ) +" " + str( sw ) +")"
- NOTE: Use format to force consistent flow table output across
- versions
- """
- try:
- self.handle.sendline( "cd" )
- self.handle.expect( "\$" )
- if protoVersion == 1.0:
- command = "sudo ovs-ofctl dump-flows " + sw + \
- " -F OpenFlow10-table_id | awk '{OFS=\",\" ; print $1 $3 $6 \
- $7 $8}' | cut -d ',' -f 2- | sort -n -k1 -r"
- self.handle.sendline( command )
- self.handle.expect( "sort" )
- self.handle.expect( "OFPST_FLOW" )
- response = self.handle.before
- # print "response=", response
- return response
- elif protoVersion == 1.3:
- command = "sudo ovs-ofctl dump-flows " + sw + \
- " -O OpenFlow13 | awk '{OFS=\",\" ; print $1 $3 $6 $7}'\
- | cut -d ',' -f 2- | sort -n -k1 -r"
- self.handle.sendline( command )
- self.handle.expect( "sort" )
- self.handle.expect( "OFPST_FLOW" )
- response = self.handle.before
- # print "response=", response
- return response
- else:
- main.log.error(
- "Unknown protoVersion in get_flowTable(). given: (" +
- str( type( protoVersion ) ) +
- ") '" + str( protoVersion ) + "'" )
- except pexpect.EOF:
- main.log.error( self.name + ": EOF exception found" )
- main.log.error( self.name + ": " + self.handle.before )
- main.cleanup()
- main.exit()
- except pexpect.TIMEOUT:
- main.log.exception( self.name + ": Timeout exception: " )
- return None
-
- def flowComp( self, flow1, flow2 ):
- if flow1 == flow2:
- return main.TRUE
- else:
- main.log.info( "Flow tables do not match, printing tables:" )
- main.log.info( "Flow Table 1:" )
- main.log.info( flow1 )
- main.log.info( "Flow Table 2:" )
- main.log.info( flow2 )
- return main.FALSE
-
def setIpTablesOUTPUT( self, dstIp, dstPort, action='add',
packetType='tcp', rule='DROP' ):
"""
diff --git a/TestON/tests/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HAclusterRestart/HAclusterRestart.py
index 8205ac9..85c5a3a 100644
--- a/TestON/tests/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HAclusterRestart/HAclusterRestart.py
@@ -1407,7 +1407,7 @@
global flows
flows = []
for i in range( 1, 29 ):
- flows.append( main.Mininet2.getFlowTable( 1.3, "s" + str( i ) ) )
+ flows.append( main.Mininet1.getFlowTable( 1.3, "s" + str( i ) ) )
if flowCheck == main.FALSE:
for table in flows:
main.log.warn( table )
@@ -2052,9 +2052,9 @@
flows2 = []
for i in range( 28 ):
main.log.info( "Checking flow table on s" + str( i + 1 ) )
- tmpFlows = main.Mininet2.getFlowTable( 1.3, "s" + str( i + 1 ) )
+ tmpFlows = main.Mininet1.getFlowTable( 1.3, "s" + str( i + 1 ) )
flows2.append( tmpFlows )
- tempResult = main.Mininet2.flowComp(
+ tempResult = main.Mininet1.flowComp(
flow1=flows[ i ],
flow2=tmpFlows )
FlowTables = FlowTables and tempResult
diff --git a/TestON/tests/HAminorityRestart/HAminorityRestart.py b/TestON/tests/HAminorityRestart/HAminorityRestart.py
index 94482ea..1103309 100644
--- a/TestON/tests/HAminorityRestart/HAminorityRestart.py
+++ b/TestON/tests/HAminorityRestart/HAminorityRestart.py
@@ -1380,7 +1380,7 @@
global flows
flows = []
for i in range( 1, 29 ):
- flows.append( main.Mininet2.getFlowTable( 1.3, "s" + str( i ) ) )
+ flows.append( main.Mininet1.getFlowTable( 1.3, "s" + str( i ) ) )
if flowCheck == main.FALSE:
for table in flows:
main.log.warn( table )
@@ -1995,9 +1995,9 @@
flows2 = []
for i in range( 28 ):
main.log.info( "Checking flow table on s" + str( i + 1 ) )
- tmpFlows = main.Mininet2.getFlowTable( 1.3, "s" + str( i + 1 ) )
+ tmpFlows = main.Mininet1.getFlowTable( 1.3, "s" + str( i + 1 ) )
flows2.append( tmpFlows )
- tempResult = main.Mininet2.flowComp(
+ tempResult = main.Mininet1.flowComp(
flow1=flows[ i ],
flow2=tmpFlows )
FlowTables = FlowTables and tempResult
diff --git a/TestON/tests/HAsanity/HAsanity.py b/TestON/tests/HAsanity/HAsanity.py
index b52943c..9cbb10a 100644
--- a/TestON/tests/HAsanity/HAsanity.py
+++ b/TestON/tests/HAsanity/HAsanity.py
@@ -1391,7 +1391,7 @@
global flows
flows = []
for i in range( 1, 29 ):
- flows.append( main.Mininet2.getFlowTable( 1.3, "s" + str( i ) ) )
+ flows.append( main.Mininet1.getFlowTable( 1.3, "s" + str( i ) ) )
if flowCheck == main.FALSE:
for table in flows:
main.log.warn( table )
@@ -1955,9 +1955,9 @@
flows2 = []
for i in range( 28 ):
main.log.info( "Checking flow table on s" + str( i + 1 ) )
- tmpFlows = main.Mininet2.getFlowTable( 1.3, "s" + str( i + 1 ) )
+ tmpFlows = main.Mininet1.getFlowTable( 1.3, "s" + str( i + 1 ) )
flows2.append( tmpFlows )
- tempResult = main.Mininet2.flowComp(
+ tempResult = main.Mininet1.flowComp(
flow1=flows[ i ],
flow2=tmpFlows )
FlowTables = FlowTables and tempResult
diff --git a/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py b/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py
index 1fa2e33..3dbc561 100644
--- a/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py
+++ b/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py
@@ -1038,7 +1038,7 @@
global flows
flows = []
for i in range( 1, 29 ):
- flows.append( main.Mininet2.getFlowTable( 1.3, "s" + str( i ) ) )
+ flows.append( main.Mininet1.getFlowTable( 1.3, "s" + str( i ) ) )
if flowCheck == main.FALSE:
for table in flows:
main.log.warn( table )
@@ -1359,9 +1359,9 @@
flows2 = []
for i in range( 28 ):
main.log.info( "Checking flow table on s" + str( i + 1 ) )
- tmpFlows = main.Mininet2.getFlowTable( 1.3, "s" + str( i + 1 ) )
+ tmpFlows = main.Mininet1.getFlowTable( 1.3, "s" + str( i + 1 ) )
flows2.append( tmpFlows )
- tempResult = main.Mininet2.flowComp(
+ tempResult = main.Mininet1.flowComp(
flow1=flows[ i ],
flow2=tmpFlows )
FlowTables = FlowTables and tempResult