Added new option in pingall function | MultiToSingle point intent function now returns intent ID
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 073e368..6275f9d 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -43,7 +43,7 @@
from drivers.common.cli.emulatordriver import Emulator
-class MininetCliDriver( Emulator ):
+class MininetCliDriver2( Emulator ):
"""
MininetCliDriver is the basic driver which will handle
@@ -65,7 +65,7 @@
self.name = self.options[ 'name' ]
self.handle = super(
- MininetCliDriver,
+ MininetCliDriver2,
self ).connect(
user_name=self.user_name,
ip_address=self.ip_address,
@@ -248,7 +248,7 @@
topoDict = self.numSwitchesN_links( *topoArgList )
return topoDict
- def pingall( self, timeout=300 ):
+ def pingall( self, timeout=300, shortCircuit = False ):
"""
Verifies the reachability of the hosts using pingall command.
Optional parameter timeout allows you to specify how long to
@@ -261,10 +261,35 @@
self.name +
": Checking reachabilty to the hosts using pingall" )
try:
- response = self.execute(
- cmd="pingall",
- prompt="mininet>",
- timeout=int( timeout ) )
+ if not shortCircuit:
+ response = self.execute(
+ cmd="pingall",
+ prompt="mininet>",
+ timeout=int( timeout ) )
+ else:
+ self.handle.sendline( "pingall" )
+ i = self.handle.expect( [ "mininet>","X X X",
+ pexpect.EOF,
+ pexpect.TIMEOUT ],
+ timeout )
+ if i == 0:
+ main.log.info("mininet> prompt found!")
+ response = str(self.handle.before)
+ if i == 1:
+ main.log.info( self.name + ": Cannot ping some of the Host")
+ main.log.info(str(self.handle.before))
+ response = str(self.handle.before)
+ if i == 2:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ if i == 3:
+ main.log.error( self.name + ": TIMEOUT exception found" )
+ main.log.error( self.name +
+ ": " +
+ str( self.handle.before ) )
+
except pexpect.EOF:
main.log.error( self.name + ": EOF exception found" )
main.log.error( self.name + ": " + self.handle.before )
@@ -1892,4 +1917,4 @@
if __name__ != "__main__":
import sys
- sys.modules[ __name__ ] = MininetCliDriver()
+ sys.modules[ __name__ ] = MininetCliDriver2()
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index ab37367..d20d044 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1312,10 +1312,159 @@
"intent" )
return None
else:
- # TODO: print out all the options in this message?
- main.log.info( "Multipoint-to-singlepoint intent installed" +
- " failed " )
+ match = re.search('id=0x([\da-f]+),', handle)
+ if match:
+ return match.group()[3:-1]
+ else:
+ main.log.error( "Error, intent ID not found" )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def addSinglepointToMultipointIntent(
+ self,
+ ingressDevice,
+ egressDeviceList,
+ portIngress="",
+ portEgressList=None,
+ ethType="",
+ ethSrc="",
+ ethDst="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipSrc="",
+ ipDst="",
+ tcpSrc="",
+ tcpDst="",
+ setEthSrc="",
+ setEthDst="" ):
+ """
+ Note:
+ This function assumes the format of all egress devices
+ is same. That is, all egress devices include port numbers
+ with a "/" or all egress devices could specify device
+ ids and port numbers seperately.
+ Required:
+ * EgressDeviceList: List of device ids of egress device
+ ( Atleast 2 eress devices required in the list )
+ * ingressDevice: device id of ingress 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
+ * lambdaAlloc: if True, intent will allocate lambda
+ for the specified intent
+ * ipProto: specify ip protocol
+ * ipSrc: specify ip source address
+ * ipDst: specify ip destination address
+ * tcpSrc: specify tcp source port
+ * tcpDst: specify tcp destination port
+ * setEthSrc: action to Rewrite Source MAC Address
+ * setEthDst: action to Rewrite Destination MAC Address
+ Description:
+ Adds a singlepoint-to-multipoint intent ( uni-directional ) by
+ specifying device id's and optional fields
+ Returns:
+ A string of the intent id or None on error
+
+ NOTE: This function may change depending on the
+ options developers provide for singlepoint-to-multipoint
+ intent via cli
+ """
+ try:
+ # If there are no optional arguments
+ if not ethType and not ethSrc and not ethDst\
+ and not bandwidth and not lambdaAlloc\
+ and not ipProto and not ipSrc and not ipDst\
+ and not tcpSrc and not tcpDst and not setEthSrc\
+ and not setEthDst:
+ cmd = "add-single-to-multi-intent"
+
+ else:
+ cmd = "add-single-to-multi-intent"
+
+ if ethType:
+ cmd += " --ethType " + str( ethType )
+ if ethSrc:
+ cmd += " --ethSrc " + str( ethSrc )
+ if ethDst:
+ cmd += " --ethDst " + str( ethDst )
+ if bandwidth:
+ cmd += " --bandwidth " + str( bandwidth )
+ if lambdaAlloc:
+ cmd += " --lambda "
+ if ipProto:
+ cmd += " --ipProto " + str( ipProto )
+ if ipSrc:
+ cmd += " --ipSrc " + str( ipSrc )
+ if ipDst:
+ cmd += " --ipDst " + str( ipDst )
+ if tcpSrc:
+ cmd += " --tcpSrc " + str( tcpSrc )
+ if tcpDst:
+ cmd += " --tcpDst " + str( tcpDst )
+ if setEthSrc:
+ cmd += " --setEthSrc " + str( setEthSrc )
+ if setEthDst:
+ cmd += " --setEthDst " + str( setEthDst )
+
+ # Check whether the user appended the port
+ # or provided it as an input
+
+ if "/" in ingressDevice:
+ cmd += " " + str( ingressDevice )
+ else:
+ if not portIngress:
+ main.log.error( "You must specify " +
+ "the Ingress port" )
+ return main.FALSE
+
+ cmd += " " +\
+ str( ingressDevice ) + "/" +\
+ str( portIngress )
+
+ if portEgressList is None:
+ for egressDevice in egressDeviceList:
+ if "/" in egressDevice:
+ cmd += " " + str( egressDevice )
+ else:
+ main.log.error( "You must specify " +
+ "the egress port" )
+ # TODO: perhaps more meaningful return
+ return main.FALSE
+ else:
+ if len( egressDeviceList ) == len( portEgressList ):
+ for egressDevice, portEgress in zip( egressDeviceList, portEgressList ):
+ cmd += " " + \
+ str( egressDevice ) + "/" +\
+ str( portEgress )
+
+ print "cmd= ", cmd
+ handle = self.sendline( cmd )
+ # If error, return error message
+ if re.search( "Error", handle ):
+ main.log.error( "Error in adding singlepoint-to-multipoint " +
+ "intent" )
return None
+ else:
+ match = re.search('id=0x([\da-f]+),', handle)
+ if match:
+ return match.group()[3:-1]
+ else:
+ main.log.error( "Error, intent ID not found" )
+ return None
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
return None
diff --git a/TestON/tests/OnosCHO/OnosCHO.py b/TestON/tests/OnosCHO/OnosCHO.py
index 6d7fc7c..71449b7 100644
--- a/TestON/tests/OnosCHO/OnosCHO.py
+++ b/TestON/tests/OnosCHO/OnosCHO.py
@@ -276,7 +276,7 @@
main.case(
"Assign and Balance all Mininet switches across controllers" )
main.step( "Stop any previous Mininet network topology" )
- #stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
+ stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
#time.sleep(10)
main.step( "Start Mininet with Chordal topology" )
startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
@@ -350,7 +350,7 @@
main.case(
"Assign and Balance all Mininet switches across controllers" )
main.step( "Stop any previous Mininet network topology" )
- #stopStatus = main.Mininet1.stopNet(fileName = "topoSpine" )
+ stopStatus = main.Mininet1.stopNet(fileName = "topoSpine" )
main.step( "Start Mininet with Spine topology" )
startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
time.sleep(20)