Merge "corrected sendline and expect statements in pingAllhosts, pingIpv6Hosts"
diff --git a/TestON/config/teston.cfg b/TestON/config/teston.cfg
index c7442f6..b255f45 100644
--- a/TestON/config/teston.cfg
+++ b/TestON/config/teston.cfg
@@ -11,9 +11,5 @@
<class>Logger</class>
</logger>
- <responseparser>
- <file>core/jsonparser.py</file>
- <class>JsonParser</class>
- </responseparser>
</config>
diff --git a/TestON/core/dicttoobject.py b/TestON/core/dicttoobject.py
deleted file mode 100644
index 13c2aa6..0000000
--- a/TestON/core/dicttoobject.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env python
-
-class DictToObject( dict ):
- def __init__( self, data = None ):
- super( DictToObject, self ).__init__()
- if data:
- self.__update( data, {} )
-
- def __update( self, data, did ):
- dataid = id(data)
- did[ dataid ] = self
-
- for k in data:
- dkid = id(data[k])
- if did.has_key(dkid):
- self[k] = did[dkid]
- elif isinstance( data[k], DictToObject ):
- self[k] = data[k]
- elif isinstance( data[k], dict ):
- obj = DictToObject()
- obj.__update( data[k], did )
- self[k] = obj
- obj = None
- else:
- self[k] = data[k]
-
- def __getattr__( self, key ):
- return self.get( key, None )
-
- def __setattr__( self, key, value ):
- if isinstance(value,dict):
- self[key] = DictToObject( value )
- else:
- self[key] = value
-
- def update( self, *args ):
- for obj in args:
- for k in obj:
- if isinstance(obj[k],dict):
- self[k] = DictToObject( obj[k] )
- else:
- self[k] = obj[k]
- return self
-
- def merge( self, *args ):
- for obj in args:
- for k in obj:
- if self.has_key(k):
- if isinstance(self[k],list) and isinstance(obj[k],list):
- self[k] += obj[k]
- elif isinstance(self[k],list):
- self[k].append( obj[k] )
- elif isinstance(obj[k],list):
- self[k] = [self[k]] + obj[k]
- elif isinstance(self[k],DictToObject) and isinstance(obj[k],Object):
- self[k].merge( obj[k] )
- elif isinstance(self[k],DictToObject) and isinstance(obj[k],dict):
- self[k].merge( obj[k] )
- else:
- self[k] = [ self[k], obj[k] ]
- else:
- if isinstance(obj[k],dict):
- self[k] = DictToObject( obj[k] )
- else:
- self[k] = obj[k]
- return self
-
diff --git a/TestON/core/iniparser.py b/TestON/core/iniparser.py
deleted file mode 100644
index c416b4f..0000000
--- a/TestON/core/iniparser.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#/usr/bin/env python
-'''
-Created on 07-Jan-2013
-
-@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
-
- 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.
-
- TestON is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
-
-
-'''
-
-import re
-from configobj import ConfigObj
-class iniparser:
- '''
- Manages authoring, parsing and execution of the test. Sub components are
- Test-Topology parser
- Module that parses the test from plain English and topology
- from a specification file and prepares for execution.
- Test sequencer
- Module that executes the tests case by case,
- step by step adding ability for step by step pause and debug later.
- Object loader
- Module that connects and loads all the component connection objects
- for access in the test
- '''
- def __init__(self) :
- self.default = ''
-
- def parse(self,fileName):
- '''
- This will parse the params or topo or cfg file and return content in the file as Dictionary
- '''
- self.fileName = fileName
- matchFileName = re.match(r'(.*)\.(params|topo)',self.fileName,re.M|re.I)
- if matchFileName:
- try :
- parsedInfo = ConfigObj(self.fileName)
- return parsedInfo
- except Exception:
- print "There is no such file to parse "+fileName
- else:
- return 0
-
- def parseParams(self,paramsPath):
- '''
- It will take the params file path and will return the params dictionary
- '''
-
- paramsPath = re.sub("\.","/",paramsPath)
- paramsPath = re.sub("tests|examples","",paramsPath)
- #print main.tests_path+"/"+paramsPath+".params"
- params = self.parse(main.tests_path+paramsPath+".params")
- paramsAsString = str(params)
- return eval(paramsAsString)
-
- def parseTopology(self,topologyPath):
- '''
- It will take topology file path and will return topology dictionary
- '''
- topologyPath = re.sub("\.","/",topologyPath)
- topologyPath = re.sub("tests|examples","",topologyPath)
- topology = self.parse(main.tests_path+"/"+topologyPath+".topo")
- topoAsString = str(topology)
- return eval(topoAsString)
-
diff --git a/TestON/core/jsonparser.py b/TestON/core/jsonparser.py
deleted file mode 100644
index c33a9b0..0000000
--- a/TestON/core/jsonparser.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#/usr/bin/env python
-'''
-Created on 07-Jan-2013
-
-@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
-
- 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.
-
- TestON is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
-
- 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
-class JsonParser:
- '''
- Module that parses the response Json to Dictionary and Vice versa.
- '''
- def __init__(self) :
- self.default = ''
-
- def response_parse(self,json_response):
- '''
- This will parse the json formatted string and return content as Dictionary
- '''
- response_dict = {}
- try :
- response_dict = json.loads(json_response)
- except Exception:
- main.log.error("Json Parser is unable to parse the string")
- return response_dict
-
- '''
-
- def dict_json(self,response_dict):
-
- # This will parse the Python Dictionary and return content as Json string.
-
- json_response = {}
- try :
- json_response = json.dumps(response_dict)
- except Exception:
- main.log.error("Json Parser is unable to parse the string")
- return json_response
- '''
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index 5bc702b..ae6fc4e 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -179,7 +179,7 @@
options = driver_options)
if not connect_result:
- self.log.error("Exiting form the test execution because the connecting to the "+component+" component failed.")
+ self.log.error("Exiting from the test execution because the connecting to the "+component+" component failed.")
self.exit()
vars(self)[component] = driverObject
@@ -441,6 +441,7 @@
self.exit()
result = re.sub("(.*)drivers","",result)
+ result = re.sub("\/\/","/",result)
result = re.sub("\.py","",result)
result = re.sub("\.pyc","",result)
result = re.sub("\/",".",result)
diff --git a/TestON/core/xmlparser.py b/TestON/core/xmlparser.py
index fea0ce9..e2cfb1d 100644
--- a/TestON/core/xmlparser.py
+++ b/TestON/core/xmlparser.py
@@ -39,10 +39,10 @@
try :
parsedInfo = xmldict.xml_to_dict(xml)
return parsedInfo
- except Exception:
- print "There is no such file to parse " + fileName
+ except Exception as e:
+ print "Error parsing file " + fileName + ": " + e.message
else :
- print "file name is not correct"
+ print "File name is not correct"
def parseParams(self,paramsPath):
'''
diff --git a/TestON/tests/CHOtest/CHOtest.params b/TestON/tests/CHOtest/CHOtest.params
index 44a9858..fe54e05 100644
--- a/TestON/tests/CHOtest/CHOtest.params
+++ b/TestON/tests/CHOtest/CHOtest.params
@@ -26,7 +26,7 @@
</CTRL>
<TOPO1>
- <topo>~/TestON/tests/CHOtest/Dependencies/topoAtt.py</topo>
+ <topo>topoAtt.py</topo>
<numSwitches>25</numSwitches>
<numHosts>25</numHosts>
<numLinks>114</numLinks>
@@ -34,7 +34,7 @@
</TOPO1>
<TOPO2>
- <topo>~/TestON/tests/CHOtest/Dependencies/topoChordal.py</topo>
+ <topo>topoChordal.py</topo>
<numSwitches>25</numSwitches>
<numHosts>25</numHosts>
<numLinks>600</numLinks>
@@ -42,7 +42,7 @@
</TOPO2>
<TOPO3>
- <topo>~/TestON/tests/CHOtest/Dependencies/topoSpine.py</topo>
+ <topo>topoSpine.py</topo>
<numSwitches>78</numSwitches>
<numHosts>68</numHosts>
<numLinks>284</numLinks>
diff --git a/TestON/tests/CHOtest/CHOtest.py b/TestON/tests/CHOtest/CHOtest.py
index 140d089..6e58b68 100644
--- a/TestON/tests/CHOtest/CHOtest.py
+++ b/TestON/tests/CHOtest/CHOtest.py
@@ -176,7 +176,11 @@
main.step( "Start Mininet with Att topology" )
main.newTopo = main.params['TOPO1']['topo']
- startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
+ mininetDir = main.Mininet1.home + "/custom/"
+ topoPath = main.testDir + "/" + main.TEST + "/Dependencies/" + main.newTopo
+ main.ONOSbench.secureCopy(main.Mininet1.user_name, main.Mininet1.ip_address, topoPath, mininetDir, direction="to")
+ topoPath = mininetDir + main.newTopo
+ startStatus = main.Mininet1.startNet(topoFile = topoPath)
main.step( "Assign switches to controllers" )
for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
@@ -237,8 +241,12 @@
main.step( "Stop any previous Mininet network topology" )
stopStatus = main.Mininet1.stopNet(fileName = "topoAtt" )
- main.step( "Start Mininet with Chordal topology" )
- startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
+ main.step("Start Mininet with Chordal topology")
+ mininetDir = main.Mininet1.home + "/custom/"
+ topoPath = main.testDir + "/" + main.TEST + "/Dependencies/" + main.newTopo
+ main.ONOSbench.secureCopy(main.Mininet1.user_name, main.Mininet1.ip_address, topoPath, mininetDir, direction="to")
+ topoPath = mininetDir + main.newTopo
+ startStatus = main.Mininet1.startNet(topoFile = topoPath)
main.step( "Assign switches to controllers" )
@@ -296,8 +304,14 @@
"Assign and Balance all Mininet switches across controllers" )
main.step( "Stop any previous Mininet network topology" )
stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
- main.step( "Start Mininet with Spine topology" )
- startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
+
+ main.step("Start Mininet with Spine topology")
+ mininetDir = main.Mininet1.home + "/custom/"
+ topoPath = main.testDir + "/" + main.TEST + "/Dependencies/" + main.newTopo
+ main.ONOSbench.secureCopy(main.Mininet1.user_name, main.Mininet1.ip_address, topoPath, mininetDir, direction="to")
+ topoPath = mininetDir + main.newTopo
+ startStatus = main.Mininet1.startNet(topoFile = topoPath)
+
time.sleep(60)
main.step( "Assign switches to controllers" )
@@ -2123,6 +2137,7 @@
def CASE10( self ):
import time
+ import re
"""
Remove all Intents
"""
diff --git a/TestON/tests/FUNCintentRest/Dependency/FuncIntentFunction.py b/TestON/tests/FUNCintentRest/Dependency/FuncIntentFunction.py
new file mode 100644
index 0000000..6bbbb84
--- /dev/null
+++ b/TestON/tests/FUNCintentRest/Dependency/FuncIntentFunction.py
@@ -0,0 +1,1061 @@
+"""
+ Wrapper functions for FuncIntent
+ This functions include Onosclidriver and Mininetclidriver driver functions
+ Author: kelvin@onlab.us
+"""
+import time
+import copy
+import json
+
+def __init__( self ):
+ self.default = ''
+
+def hostIntent( main,
+ name,
+ host1,
+ host2,
+ onosNode=0,
+ host1Id="",
+ host2Id="",
+ mac1="",
+ mac2="",
+ vlan1="-1",
+ vlan2="-1",
+ sw1="",
+ sw2="",
+ expectedLink=0 ):
+ """
+ Description:
+ Verify add-host-intent
+ Steps:
+ - Discover hosts
+ - Add host intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ Required:
+ name - Type of host intent to add eg. IPV4 | VLAN | Dualstack
+ host1 - Name of first host
+ host2 - Name of second host
+ Optional:
+ onosNode - ONOS node to install the intents in main.CLIs[ ]
+ 0 by default so that it will always use the first
+ ONOS node
+ host1Id - ONOS id of the first host eg. 00:00:00:00:00:01/-1
+ host2Id - ONOS id of the second host
+ mac1 - Mac address of first host
+ mac2 - Mac address of the second host
+ vlan1 - Vlan tag of first host, defaults to -1
+ vlan2 - Vlan tag of second host, defaults to -1
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+ """
+
+ # Assert variables
+ assert main, "There is no main variable"
+ assert name, "variable name is empty"
+ assert host1 and host2, "You must specify hosts"
+
+ global itemName
+ itemName = name
+ h1Id = host1Id
+ h2Id = host2Id
+ h1Mac = mac1
+ h2Mac = mac2
+ vlan1 = vlan1
+ vlan2 = vlan2
+ hostNames = [ host1 , host2 ]
+ intentsId = []
+ stepResult = main.TRUE
+ pingResult = main.TRUE
+ intentResult = main.TRUE
+ removeIntentResult = main.TRUE
+ flowResult = main.TRUE
+ topoResult = main.TRUE
+ linkDownResult = main.TRUE
+ linkUpResult = main.TRUE
+ onosNode = int( onosNode )
+
+ if main.hostsData:
+ if not h1Mac:
+ h1Mac = main.hostsData[ host1 ][ 'mac' ]
+ if not h2Mac:
+ h2Mac = main.hostsData[ host2 ][ 'mac' ]
+ if main.hostsData[ host1 ][ 'vlan' ] != '-1':
+ vlan1 = main.hostsData[ host1 ][ 'vlan' ]
+ if main.hostsData[ host2 ][ 'vlan' ] != '-1':
+ vlan2 = main.hostsData[ host2 ][ 'vlan' ]
+ if not h1Id:
+ h1Id = main.hostsData[ host1 ][ 'id' ]
+ if not h2Id:
+ h2Id = main.hostsData[ host2 ][ 'id' ]
+
+ assert h1Id and h2Id, "You must specify host IDs"
+ if not ( h1Id and h2Id ):
+ main.log.info( "There are no host IDs" )
+ return main.FALSE
+
+ # Discover hosts using arping
+ if not main.hostsData:
+ main.log.info( itemName + ": Discover host using arping" )
+ main.Mininet1.arping( host=host1 )
+ main.Mininet1.arping( host=host2 )
+ h1Id = main.CLIs[ 0 ].getHost( mac=h1Mac )
+ h2Id = main.CLIs[ 0 ].getHost( mac=h2Mac )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+
+ # Adding host intents
+ main.log.info( itemName + ": Adding host intents" )
+
+ intent1 = main.CLIs[ onosNode ].addHostIntent( hostIdOne=h1Id,
+ hostIdTwo=h2Id )
+
+ time.sleep( main.hostIntentSleep )
+ intentsId = main.CLIs[ 0 ].getIntentsId()
+ print intentsId
+
+ # Check intents state
+ time.sleep( main.checkIntentSleep )
+ intentResult = checkIntentState( main, intentsId )
+ checkFlowsCount( main )
+
+ # Check intents state again if first check fails...
+ if not intentResult:
+ intentResult = checkIntentState( main, intentsId )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ # Ping hosts
+ firstPingResult = pingallHosts( main, hostNames )
+ if not firstPingResult:
+ main.log.debug( "First ping failed, there must be" +
+ " something wrong with ONOS performance" )
+
+ # Ping hosts again...
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ # Test rerouting if these variables exist
+ if sw1 and sw2 and expectedLink:
+ # link down
+ linkDownResult = link( main, sw1, sw2, "down" )
+ intentResult = intentResult and checkIntentState( main, intentsId )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link down
+ if linkDownResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link down" )
+ else:
+ main.log.error( itemName + ": Failed to bring link down" )
+
+ # link up
+ linkUpResult = link( main, sw1, sw2, "up" )
+ time.sleep( main.rerouteSleep )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, main.numLinks )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link up
+ if linkUpResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link back up" )
+ else:
+ main.log.error( itemName + ": Failed to bring link back up" )
+
+ # Remove all intents
+ removeIntentResult = removeAllIntents( main )
+
+ stepResult = pingResult and linkDownResult and linkUpResult \
+ and intentResult and removeIntentResult
+
+ return stepResult
+
+def pointIntent( main,
+ name,
+ host1,
+ host2,
+ onosNode=0,
+ deviceId1="",
+ deviceId2="",
+ port1="",
+ port2="",
+ ethType="",
+ mac1="",
+ mac2="",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ip1="",
+ ip2="",
+ tcp1="",
+ tcp2="",
+ sw1="",
+ sw2="",
+ expectedLink=0 ):
+
+ """
+ Description:
+ Verify add-point-intent
+ Steps:
+ - Get device ids | ports
+ - Add point intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ Required:
+ name - Type of point intent to add eg. IPV4 | VLAN | Dualstack
+ host1 - Name of first host
+ host2 - Name of second host
+ Optional:
+ onosNode - ONOS node to install the intents in main.CLIs[ ]
+ 0 by default so that it will always use the first
+ ONOS node
+ deviceId1 - ONOS device id of the first switch, the same as the
+ location of the first host eg. of:0000000000000001/1,
+ located at device 1 port 1
+ deviceId2 - ONOS device id of the second switch
+ port1 - The port number where the first host is attached
+ port2 - The port number where the second host is attached
+ ethType - Ethernet type eg. IPV4, IPV6
+ mac1 - Mac address of first host
+ mac2 - Mac address of the second host
+ bandwidth - Bandwidth capacity
+ lambdaAlloc - Allocate lambda, defaults to False
+ ipProto - IP protocol
+ ip1 - IP address of first host
+ ip2 - IP address of second host
+ tcp1 - TCP port of first host
+ tcp2 - TCP port of second host
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+ """
+
+ assert main, "There is no main variable"
+ assert name, "variable name is empty"
+ assert host1 and host2, "You must specify hosts"
+
+ global itemName
+ itemName = name
+ host1 = host1
+ host2 = host2
+ hostNames = [ host1, host2 ]
+ intentsId = []
+
+ pingResult = main.TRUE
+ intentResult = main.TRUE
+ removeIntentResult = main.TRUE
+ flowResult = main.TRUE
+ topoResult = main.TRUE
+ linkDownResult = main.TRUE
+ linkUpResult = main.TRUE
+ onosNode = int( onosNode )
+
+ # Adding bidirectional point intents
+ main.log.info( itemName + ": Adding point intents" )
+ intent1 = main.CLIs[ onosNode ].addPointIntent( ingressDevice=deviceId1,
+ egressDevice=deviceId2,
+ ingressPort=port1,
+ egressPort=port2,
+ ethType=ethType,
+ ethSrc=mac1,
+ ethDst=mac2,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc=ip1,
+ ipDst=ip2,
+ tcpSrc=tcp1,
+ tcpDst=tcp2 )
+
+ intent2 = main.CLIs[ onosNode ].addPointIntent( ingressDevice=deviceId2,
+ egressDevice=deviceId1,
+ ingressPort=port2,
+ egressPort=port1,
+ ethType=ethType,
+ ethSrc=mac2,
+ ethDst=mac1,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc=ip2,
+ ipDst=ip1,
+ tcpSrc=tcp2,
+ tcpDst=tcp1 )
+ intentsId = main.CLIs[ 0 ].getIntentsId()
+ print intentsId
+
+ # Check intents state
+ time.sleep( main.checkIntentSleep )
+ intentResult = checkIntentState( main, intentsId )
+ # Check flows count in each node
+ checkFlowsCount( main )
+
+ # Check intents state again if first check fails...
+ if not intentResult:
+ intentResult = checkIntentState( main, intentsId )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ # Ping hosts
+ firstPingResult = pingallHosts( main, hostNames )
+ if not firstPingResult:
+ main.log.debug( "First ping failed, there must be" +
+ " something wrong with ONOS performance" )
+
+ # Ping hosts again...
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ # Test rerouting if these variables exist
+ if sw1 and sw2 and expectedLink:
+ # link down
+ linkDownResult = link( main, sw1, sw2, "down" )
+ intentResult = intentResult and checkIntentState( main, intentsId )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link down
+ if linkDownResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link down" )
+ else:
+ main.log.error( itemName + ": Failed to bring link down" )
+
+ # link up
+ linkUpResult = link( main, sw1, sw2, "up" )
+ time.sleep( main.rerouteSleep )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, main.numLinks )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link up
+ if linkUpResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link back up" )
+ else:
+ main.log.error( itemName + ": Failed to bring link back up" )
+
+ # Remove all intents
+ removeIntentResult = removeAllIntents( main )
+
+ stepResult = pingResult and linkDownResult and linkUpResult \
+ and intentResult and removeIntentResult
+
+ return stepResult
+
+def singleToMultiIntent( main,
+ name,
+ hostNames,
+ onosNode=0,
+ devices="",
+ ports=None,
+ ethType="",
+ macs=None,
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="",
+ sw2="",
+ expectedLink=0 ):
+ """
+ Verify Single to Multi Point intents
+ NOTE:If main.hostsData is not defined, variables data should be passed
+ in the same order index wise. All devices in the list should have the
+ same format, either all the devices have its port or it doesn't.
+ eg. hostName = [ 'h1', 'h2' ,.. ]
+ devices = [ 'of:0000000000000001', 'of:0000000000000002', ...]
+ ports = [ '1', '1', ..]
+ ...
+ Description:
+ Verify add-single-to-multi-intent iterates through the list of given
+ host | devices and add intents
+ Steps:
+ - Get device ids | ports
+ - Add single to multi point intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ Required:
+ name - Type of point intent to add eg. IPV4 | VLAN | Dualstack
+ hostNames - List of host names
+ Optional:
+ onosNode - ONOS node to install the intents in main.CLIs[ ]
+ 0 by default so that it will always use the first
+ ONOS node
+ devices - List of device ids in the same order as the hosts
+ in hostNames
+ ports - List of port numbers in the same order as the device in
+ devices
+ ethType - Ethernet type eg. IPV4, IPV6
+ macs - List of hosts mac address in the same order as the hosts in
+ hostNames
+ bandwidth - Bandwidth capacity
+ lambdaAlloc - Allocate lambda, defaults to False
+ ipProto - IP protocol
+ ipAddresses - IP addresses of host in the same order as the hosts in
+ hostNames
+ tcp - TCP ports in the same order as the hosts in hostNames
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+ """
+
+ assert main, "There is no main variable"
+ assert hostNames, "You must specify hosts"
+ assert devices or main.hostsData, "You must specify devices"
+
+ global itemName
+ itemName = name
+ tempHostsData = {}
+ intentsId = []
+ onosNode = int( onosNode )
+
+ macsDict = {}
+ ipDict = {}
+ if hostNames and devices:
+ if len( hostNames ) != len( devices ):
+ main.log.debug( "hosts and devices does not have the same length" )
+ #print "len hostNames = ", len( hostNames )
+ #print "len devices = ", len( devices )
+ return main.FALSE
+ if ports:
+ if len( ports ) != len( devices ):
+ main.log.error( "Ports and devices does " +
+ "not have the same length" )
+ #print "len devices = ", len( devices )
+ #print "len ports = ", len( ports )
+ return main.FALSE
+ else:
+ main.log.info( "Device Ports are not specified" )
+ if macs:
+ for i in range( len( devices ) ):
+ macsDict[ devices[ i ] ] = macs[ i ]
+
+ elif hostNames and not devices and main.hostsData:
+ devices = []
+ main.log.info( "singleToMultiIntent function is using main.hostsData" )
+ for host in hostNames:
+ devices.append( main.hostsData.get( host ).get( 'location' ) )
+ macsDict[ main.hostsData.get( host ).get( 'location' ) ] = \
+ main.hostsData.get( host ).get( 'mac' )
+ ipDict[ main.hostsData.get( host ).get( 'location' ) ] = \
+ main.hostsData.get( host ).get( 'ipAddresses' )
+ #print main.hostsData
+
+ #print 'host names = ', hostNames
+ #print 'devices = ', devices
+ #print "macsDict = ", macsDict
+
+ pingResult = main.TRUE
+ intentResult = main.TRUE
+ removeIntentResult = main.TRUE
+ flowResult = main.TRUE
+ topoResult = main.TRUE
+ linkDownResult = main.TRUE
+ linkUpResult = main.TRUE
+
+ devicesCopy = copy.copy( devices )
+ if ports:
+ portsCopy = copy.copy( ports )
+ main.log.info( itemName + ": Adding single point to multi point intents" )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+
+ # Adding bidirectional point intents
+ for i in range( len( devices ) ):
+ ingressDevice = devicesCopy[ i ]
+ egressDeviceList = copy.copy( devicesCopy )
+ egressDeviceList.remove( ingressDevice )
+ if ports:
+ portIngress = portsCopy[ i ]
+ portEgressList = copy.copy( portsCopy )
+ del portEgressList[ i ]
+ else:
+ portIngress = ""
+ portEgressList = None
+ if not macsDict:
+ srcMac = ""
+ else:
+ srcMac = macsDict[ ingressDevice ]
+ if srcMac == None:
+ main.log.debug( "There is no MAC in device - " + ingressDevice )
+ srcMac = ""
+
+ intentsId.append(
+ main.CLIs[ onosNode ].addSinglepointToMultipointIntent(
+ ingressDevice=ingressDevice,
+ egressDeviceList=egressDeviceList,
+ portIngress=portIngress,
+ portEgressList=portEgressList,
+ ethType=ethType,
+ ethSrc=srcMac,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc="",
+ ipDst="",
+ tcpSrc="",
+ tcpDst="" ) )
+
+ # Wait some time for the flow to go through when using multi instance
+ pingResult = pingallHosts( main, hostNames )
+
+ # Check intents state
+ time.sleep( main.checkIntentSleep )
+ intentResult = checkIntentState( main, intentsId )
+
+ # Check intents state again if first check fails...
+ if not intentResult:
+ intentResult = checkIntentState( main, intentsId )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ # Test rerouting if these variables exist
+ if sw1 and sw2 and expectedLink:
+ # link down
+ linkDownResult = link( main, sw1, sw2, "down" )
+ intentResult = intentResult and checkIntentState( main, intentsId )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link down
+ if linkDownResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link down" )
+ else:
+ main.log.error( itemName + ": Failed to bring link down" )
+
+ # link up
+ linkUpResult = link( main, sw1, sw2, "up" )
+ time.sleep( main.rerouteSleep )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, main.numLinks )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link up
+ if linkUpResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link back up" )
+ else:
+ main.log.error( itemName + ": Failed to bring link back up" )
+
+ # Remove all intents
+ removeIntentResult = removeAllIntents( main, intentsId )
+
+ stepResult = pingResult and linkDownResult and linkUpResult \
+ and intentResult and removeIntentResult
+
+ return stepResult
+
+def multiToSingleIntent( main,
+ name,
+ hostNames,
+ onosNode=0,
+ devices="",
+ ports=None,
+ ethType="",
+ macs=None,
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="",
+ sw2="",
+ expectedLink=0 ):
+ """
+ Verify Single to Multi Point intents
+ NOTE:If main.hostsData is not defined, variables data should be passed in the
+ same order index wise. All devices in the list should have the same
+ format, either all the devices have its port or it doesn't.
+ eg. hostName = [ 'h1', 'h2' ,.. ]
+ devices = [ 'of:0000000000000001', 'of:0000000000000002', ...]
+ ports = [ '1', '1', ..]
+ ...
+ Description:
+ Verify add-multi-to-single-intent
+ Steps:
+ - Get device ids | ports
+ - Add multi to single point intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ Required:
+ name - Type of point intent to add eg. IPV4 | VLAN | Dualstack
+ hostNames - List of host names
+ Optional:
+ onosNode - ONOS node to install the intents in main.CLIs[ ]
+ 0 by default so that it will always use the first
+ ONOS node
+ devices - List of device ids in the same order as the hosts
+ in hostNames
+ ports - List of port numbers in the same order as the device in
+ devices
+ ethType - Ethernet type eg. IPV4, IPV6
+ macs - List of hosts mac address in the same order as the hosts in
+ hostNames
+ bandwidth - Bandwidth capacity
+ lambdaAlloc - Allocate lambda, defaults to False
+ ipProto - IP protocol
+ ipAddresses - IP addresses of host in the same order as the hosts in
+ hostNames
+ tcp - TCP ports in the same order as the hosts in hostNames
+ sw1 - First switch to bring down & up for rerouting purpose
+ sw2 - Second switch to bring down & up for rerouting purpose
+ expectedLink - Expected link when the switches are down, it should
+ be two links lower than the links before the two
+ switches are down
+ """
+
+ assert main, "There is no main variable"
+ assert hostNames, "You must specify hosts"
+ assert devices or main.hostsData, "You must specify devices"
+
+ global itemName
+ itemName = name
+ tempHostsData = {}
+ intentsId = []
+ onosNode = int( onosNode )
+
+ macsDict = {}
+ ipDict = {}
+ if hostNames and devices:
+ if len( hostNames ) != len( devices ):
+ main.log.debug( "hosts and devices does not have the same length" )
+ #print "len hostNames = ", len( hostNames )
+ #print "len devices = ", len( devices )
+ return main.FALSE
+ if ports:
+ if len( ports ) != len( devices ):
+ main.log.error( "Ports and devices does " +
+ "not have the same length" )
+ #print "len devices = ", len( devices )
+ #print "len ports = ", len( ports )
+ return main.FALSE
+ else:
+ main.log.info( "Device Ports are not specified" )
+ if macs:
+ for i in range( len( devices ) ):
+ macsDict[ devices[ i ] ] = macs[ i ]
+ elif hostNames and not devices and main.hostsData:
+ devices = []
+ main.log.info( "multiToSingleIntent function is using main.hostsData" )
+ for host in hostNames:
+ devices.append( main.hostsData.get( host ).get( 'location' ) )
+ macsDict[ main.hostsData.get( host ).get( 'location' ) ] = \
+ main.hostsData.get( host ).get( 'mac' )
+ ipDict[ main.hostsData.get( host ).get( 'location' ) ] = \
+ main.hostsData.get( host ).get( 'ipAddresses' )
+ #print main.hostsData
+
+ #print 'host names = ', hostNames
+ #print 'devices = ', devices
+ #print "macsDict = ", macsDict
+
+ pingResult = main.TRUE
+ intentResult = main.TRUE
+ removeIntentResult = main.TRUE
+ flowResult = main.TRUE
+ topoResult = main.TRUE
+ linkDownResult = main.TRUE
+ linkUpResult = main.TRUE
+
+ devicesCopy = copy.copy( devices )
+ if ports:
+ portsCopy = copy.copy( ports )
+ main.log.info( itemName + ": Adding multi point to single point intents" )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+
+ # Adding bidirectional point intents
+ for i in range( len( devices ) ):
+ egressDevice = devicesCopy[ i ]
+ ingressDeviceList = copy.copy( devicesCopy )
+ ingressDeviceList.remove( egressDevice )
+ if ports:
+ portEgress = portsCopy[ i ]
+ portIngressList = copy.copy( portsCopy )
+ del portIngressList[ i ]
+ else:
+ portEgress = ""
+ portIngressList = None
+ if not macsDict:
+ dstMac = ""
+ else:
+ dstMac = macsDict[ egressDevice ]
+ if dstMac == None:
+ main.log.debug( "There is no MAC in device - " + egressDevice )
+ dstMac = ""
+
+ intentsId.append(
+ main.CLIs[ onosNode ].addMultipointToSinglepointIntent(
+ ingressDeviceList=ingressDeviceList,
+ egressDevice=egressDevice,
+ portIngressList=portIngressList,
+ portEgress=portEgress,
+ ethType=ethType,
+ ethDst=dstMac,
+ bandwidth=bandwidth,
+ lambdaAlloc=lambdaAlloc,
+ ipProto=ipProto,
+ ipSrc="",
+ ipDst="",
+ tcpSrc="",
+ tcpDst="" ) )
+
+ pingResult = pingallHosts( main, hostNames )
+
+ # Check intents state
+ time.sleep( main.checkIntentSleep )
+ intentResult = checkIntentState( main, intentsId )
+
+ # Check intents state again if first check fails...
+ if not intentResult:
+ intentResult = checkIntentState( main, intentsId )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+ # Ping hosts again...
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ # Test rerouting if these variables exist
+ if sw1 and sw2 and expectedLink:
+ # link down
+ linkDownResult = link( main, sw1, sw2, "down" )
+ intentResult = intentResult and checkIntentState( main, intentsId )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, expectedLink )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link down
+ if linkDownResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link down" )
+ else:
+ main.log.error( itemName + ": Failed to bring link down" )
+
+ # link up
+ linkUpResult = link( main, sw1, sw2, "up" )
+ time.sleep( main.rerouteSleep )
+
+ # Check flows count in each node
+ checkFlowsCount( main )
+ # Verify flows
+ checkFlowsState( main )
+
+ # Check OnosTopology
+ topoResult = checkTopology( main, main.numLinks )
+
+ # Ping hosts
+ pingResult = pingResult and pingallHosts( main, hostNames )
+
+ intentResult = checkIntentState( main, intentsId )
+
+ # Checks ONOS state in link up
+ if linkUpResult and topoResult and pingResult and intentResult:
+ main.log.info( itemName + ": Successfully brought link back up" )
+ else:
+ main.log.error( itemName + ": Failed to bring link back up" )
+
+ # Remove all intents
+ removeIntentResult = removeAllIntents( main, intentsId )
+
+ stepResult = pingResult and linkDownResult and linkUpResult \
+ and intentResult and removeIntentResult
+
+ return stepResult
+
+def pingallHosts( main, hostList, pingType="ipv4" ):
+ # Ping all host in the hosts list variable
+ print "Pinging : ", hostList
+ pingResult = main.TRUE
+ pingResult = main.Mininet1.pingallHosts( hostList, pingType )
+ return pingResult
+
+def getHostsData( main ):
+ """
+ Use fwd app and pingall to discover all the hosts
+ """
+
+ activateResult = main.TRUE
+ appCheck = main.TRUE
+ getDataResult = main.TRUE
+ main.log.info( "Activating reactive forwarding app " )
+ activateResult = main.CLIs[ 0 ].activateApp( "org.onosproject.fwd" )
+ if not activateResult:
+ main.log.error( "Something went wrong installing fwd app" )
+ time.sleep( main.fwdSleep )
+ pingResult = main.Mininet1.pingall( timeout = 600 )
+ hostsJson = json.loads( main.CLIs[ 0 ].hosts() )
+ hosts = main.Mininet1.getHosts().keys()
+ # TODO: Make better use of new getHosts function
+ for host in hosts:
+ main.hostsData[ host ] = {}
+ main.hostsData[ host ][ 'mac' ] = \
+ main.Mininet1.getMacAddress( host ).upper()
+ for hostj in hostsJson:
+ if main.hostsData[ host ][ 'mac' ] == hostj[ 'mac' ]:
+ main.hostsData[ host ][ 'id' ] = hostj[ 'id' ]
+ main.hostsData[ host ][ 'vlan' ] = hostj[ 'vlan' ]
+ main.hostsData[ host ][ 'location' ] = \
+ hostj[ 'location' ][ 'elementId' ] + '/' + \
+ hostj[ 'location' ][ 'port' ]
+ main.hostsData[ host ][ 'ipAddresses' ] = hostj[ 'ipAddresses' ]
+
+ main.log.info( "Deactivating reactive forwarding app " )
+ deactivateResult = main.CLIs[ 0 ].deactivateApp( "org.onosproject.fwd" )
+ if activateResult and deactivateResult and main.hostsData:
+ main.log.info( "Successfully used fwd app to discover hosts " )
+ getDataResult = main.TRUE
+ else:
+ main.log.info( "Failed to use fwd app to discover hosts " )
+ getDataResult = main.FALSE
+
+ print main.hostsData
+
+ return getDataResult
+
+def checkTopology( main, expectedLink ):
+ statusResult = main.TRUE
+ # Check onos topology
+ main.log.info( itemName + ": Checking ONOS topology " )
+
+ for i in range( main.numCtrls ):
+ topologyResult = main.CLIs[ i ].topology()
+ statusResult = main.ONOSbench.checkStatus( topologyResult,
+ main.numSwitch,
+ expectedLink )\
+ and statusResult
+ if not statusResult:
+ main.log.error( itemName + ": Topology mismatch" )
+ else:
+ main.log.info( itemName + ": Topology match" )
+ return statusResult
+
+def checkIntentState( main, intentsId ):
+ """
+ This function will check intent state to make sure all the intents
+ are in INSTALLED state
+ """
+
+ intentResult = main.TRUE
+ results = []
+
+ main.log.info( itemName + ": Checking intents state" )
+ # First check of intents
+ for i in range( main.numCtrls ):
+ tempResult = main.CLIs[ i ].checkIntentState( intentsId=intentsId )
+ results.append( tempResult )
+
+ expectedState = [ 'INSTALLED', 'INSTALLING' ]
+
+ if all( result == main.TRUE for result in results ):
+ main.log.info( itemName + ": Intents are installed correctly" )
+ else:
+ # Wait for at least 5 second before checking the intents again
+ time.sleep( 5 )
+ results = []
+ # Second check of intents since some of the intents may be in
+ # INSTALLING state, they should be in INSTALLED at this time
+ for i in range( main.numCtrls ):
+ tempResult = main.CLIs[ i ].checkIntentState(
+ intentsId=intentsId )
+ results.append( tempResult )
+ if all( result == main.TRUE for result in results ):
+ main.log.info( itemName + ": Intents are installed correctly" )
+ else:
+ main.log.error( itemName + ": Intents are NOT installed correctly" )
+ intentResult = main.FALSE
+
+ return intentResult
+
+def checkFlowsState( main ):
+
+ main.log.info( itemName + ": Check flows state" )
+ checkFlowsResult = main.CLIs[ 0 ].checkFlowsState()
+ return checkFlowsResult
+
+def link( main, sw1, sw2, option):
+
+ # link down
+ main.log.info( itemName + ": Bring link " + option + "between " +
+ sw1 + " and " + sw2 )
+ linkResult = main.Mininet1.link( end1=sw1, end2=sw2, option=option )
+ return linkResult
+
+def removeAllIntents( main ):
+ """
+ Remove all intents in the intentsId
+ """
+
+ onosSummary = []
+ removeIntentResult = main.TRUE
+ # Remove intents
+ removeIntentResult = main.CLIs[ 0 ].removeAllIntents( )
+
+ if removeIntentResult:
+ main.log.info( itemName + ": There are no more intents remaining, " +
+ "successfully removed all the intents." )
+
+ return removeIntentResult
+
+def checkFlowsCount( main ):
+ """
+ Check flows count in each node
+ """
+
+ flowsCount = []
+ main.log.info( itemName + ": Checking flows count in each ONOS node" )
+ for i in range( main.numCtrls ):
+ flowsCount.append( len( json.loads( main.CLIs[ i ].flows() ) ) )
+
+ if flowsCount:
+ if all( flows==flowsCount[ 0 ] for flows in flowsCount ):
+ main.log.info( itemName + ": There are " + str( flowsCount[ 0 ] ) +
+ " flows in all ONOS node" )
+ else:
+ for i in range( main.numCtrls ):
+ main.log.debug( itemName + ": ONOS node " + str( i + 1 ) +
+ " has " + flowsCount[ i ] + " flows" )
+ else:
+ main.log.error( "Checking flows count failed, check summary command" )
+ return main.FALSE
+
+ return main.TRUE
+
diff --git a/TestON/tests/FUNCintentRest/Dependency/newFuncTopo.py b/TestON/tests/FUNCintentRest/Dependency/newFuncTopo.py
new file mode 100755
index 0000000..5edf7f7
--- /dev/null
+++ b/TestON/tests/FUNCintentRest/Dependency/newFuncTopo.py
@@ -0,0 +1,148 @@
+#!/usr/bin/python
+
+"""
+Custom topology for Mininet
+"""
+from mininet.topo import Topo
+from mininet.net import Mininet
+from mininet.node import Host, RemoteController
+from mininet.node import Node
+from mininet.node import CPULimitedHost
+from mininet.link import TCLink
+from mininet.cli import CLI
+from mininet.log import setLogLevel
+from mininet.util import dumpNodeConnections
+from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
+
+class VLANHost( Host ):
+ def config( self, vlan=100, **params ):
+ r = super( Host, self ).config( **params )
+ intf = self.defaultIntf()
+ self.cmd( 'ifconfig %s inet 0' % intf )
+ self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
+ self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
+ newName = '%s.%d' % ( intf, vlan )
+ intf.name = newName
+ self.nameToIntf[ newName ] = intf
+ return r
+
+class IPv6Host( Host ):
+ def config( self, v6Addr='1000:1/64', **params ):
+ r = super( Host, self ).config( **params )
+ intf = self.defaultIntf()
+ self.cmd( 'ifconfig %s inet 0' % intf )
+ self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
+ return r
+
+class dualStackHost( Host ):
+ def config( self, v6Addr='2000:1/64', **params ):
+ r = super( Host, self ).config( **params )
+ intf = self.defaultIntf()
+ self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
+ return r
+
+class MyTopo( Topo ):
+
+ def __init__( self ):
+ # Initialize topology
+ Topo.__init__( self )
+ # Switch S5 Hosts
+ host1=self.addHost( 'h1', ip='10.1.0.2/24' )
+ host2=self.addHost( 'h2', cls=IPv6Host, v6Addr='1000::2/64' )
+ host3=self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='2000::2/64' )
+ #VLAN hosts
+ host4=self.addHost( 'h4', ip='100.1.0.2/24', cls=VLANHost, vlan=100 )
+ host5=self.addHost( 'h5', ip='200.1.0.2/24', cls=VLANHost, vlan=200 )
+ #VPN-1 and VPN-2 Hosts
+ host6=self.addHost( 'h6', ip='11.1.0.2/24' )
+ host7=self.addHost( 'h7', ip='12.1.0.2/24' )
+ #Multicast Sender
+ host8=self.addHost( 'h8', ip='10.1.0.4/24' )
+
+ # Switch S6 Hosts
+ host9=self.addHost( 'h9', ip='10.1.0.5/24' )
+ host10=self.addHost( 'h10', cls=IPv6Host, v6Addr='1000::3/64' )
+ host11=self.addHost( 'h11', ip='10.1.0.6/24', cls=dualStackHost, v6Addr='2000::3/64' )
+ #VLAN hosts
+ host12=self.addHost( 'h12', ip='100.1.0.3/24', cls=VLANHost, vlan=100 )
+ host13=self.addHost( 'h13', ip='200.1.0.3/24', cls=VLANHost, vlan=200 )
+ #VPN-1 and VPN-2 Hosts
+ host14=self.addHost( 'h14', ip='11.1.0.3/24' )
+ host15=self.addHost( 'h15', ip='12.1.0.3/24' )
+ #Multicast Receiver
+ host16=self.addHost( 'h16', ip='10.1.0.7/24' )
+
+ # Switch S7 Hosts
+ host17=self.addHost( 'h17', ip='10.1.0.8/24' )
+ host18=self.addHost( 'h18', cls=IPv6Host, v6Addr='1000::4/64' )
+ host19=self.addHost( 'h19', ip='10.1.0.9/24', cls=dualStackHost, v6Addr='2000::4/64' )
+ #VLAN hosts
+ host20=self.addHost( 'h20', ip='100.1.0.4/24', cls=VLANHost, vlan=100 )
+ host21=self.addHost( 'h21', ip='200.1.0.4/24', cls=VLANHost, vlan=200 )
+ #VPN-1 and VPN-2 Hosts
+ host22=self.addHost( 'h22', ip='11.1.0.4/24' )
+ host23=self.addHost( 'h23', ip='12.1.0.4/24' )
+ #Multicast Receiver
+ host24=self.addHost( 'h24', ip='10.1.0.10/24' )
+
+ s1 = self.addSwitch( 's1' )
+ s2 = self.addSwitch( 's2' )
+ s3 = self.addSwitch( 's3' )
+ s4 = self.addSwitch( 's4' )
+ s5 = self.addSwitch( 's5' )
+ s6 = self.addSwitch( 's6' )
+ s7 = self.addSwitch( 's7' )
+
+ self.addLink(s5,host1)
+ self.addLink(s5,host2)
+ self.addLink(s5,host3)
+ self.addLink(s5,host4)
+ self.addLink(s5,host5)
+ self.addLink(s5,host6)
+ self.addLink(s5,host7)
+ self.addLink(s5,host8)
+
+ self.addLink(s6,host9)
+ self.addLink(s6,host10)
+ self.addLink(s6,host11)
+ self.addLink(s6,host12)
+ self.addLink(s6,host13)
+ self.addLink(s6,host14)
+ self.addLink(s6,host15)
+ self.addLink(s6,host16)
+
+ self.addLink(s7,host17)
+ self.addLink(s7,host18)
+ self.addLink(s7,host19)
+ self.addLink(s7,host20)
+ self.addLink(s7,host21)
+ self.addLink(s7,host22)
+ self.addLink(s7,host23)
+ self.addLink(s7,host24)
+
+ self.addLink(s1,s2)
+ self.addLink(s1,s3)
+ self.addLink(s1,s4)
+ self.addLink(s1,s5)
+ self.addLink(s2,s3)
+ self.addLink(s2,s5)
+ self.addLink(s2,s6)
+ self.addLink(s3,s4)
+ self.addLink(s3,s6)
+ self.addLink(s4,s7)
+ topos = { 'mytopo': ( lambda: MyTopo() ) }
+
+# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
+
+def setupNetwork():
+ "Create network"
+ topo = MyTopo()
+ network = Mininet(topo=topo, autoSetMacs=True, controller=None)
+ network.start()
+ CLI( network )
+ network.stop()
+
+if __name__ == '__main__':
+ setLogLevel('info')
+ #setLogLevel('debug')
+ setupNetwork()
diff --git a/TestON/tests/FUNCintentRest/Dependency/startUp.py b/TestON/tests/FUNCintentRest/Dependency/startUp.py
new file mode 100644
index 0000000..bf2a2b6
--- /dev/null
+++ b/TestON/tests/FUNCintentRest/Dependency/startUp.py
@@ -0,0 +1,38 @@
+"""
+ 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
+ checkOutResult = main.ONOSbench.gitCheckout( gitBranch )
+ # Does the git pull on the branch that was checked out
+ if not checkOutResult:
+ main.log.warn( "Failed to checked out " + gitBranch +
+ " branch")
+ else:
+ main.log.info( "Successfully checked out " + gitBranch +
+ " branch")
+ gitPullResult = main.ONOSbench.gitPull()
+ if gitPullResult == main.ERROR:
+ main.log.error( "Error pulling git branch" )
+ else:
+ main.log.info( "Successfully pulled " + gitBranch + " branch" )
+
+ # Maven clean install
+ buildResult = main.ONOSbench.cleanInstall()
+
+ return buildResult
+
+
+
+
diff --git a/TestON/tests/FUNCintentRest/Dependency/topo.py b/TestON/tests/FUNCintentRest/Dependency/topo.py
new file mode 100644
index 0000000..b44e3fc
--- /dev/null
+++ b/TestON/tests/FUNCintentRest/Dependency/topo.py
@@ -0,0 +1,100 @@
+"""
+ 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
+ """
+ devices = []
+ threads = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].devices,
+ name="devices-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ devices.append( t.result )
+ return devices
+
+def getAllHosts( main ):
+ """
+ Return a list containing the hosts output from each ONOS node
+ """
+ hosts = []
+ ipResult = main.TRUE
+ threads = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].hosts,
+ name="hosts-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ hosts.append( t.result )
+ return hosts
+
+def getAllPorts( main ):
+ """
+ Return a list containing the ports output from each ONOS node
+ """
+ ports = []
+ threads = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].ports,
+ name="ports-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ ports.append( t.result )
+ return ports
+
+def getAllLinks( main ):
+ """
+ Return a list containing the links output from each ONOS node
+ """
+ links = []
+ threads = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].links,
+ name="links-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ links.append( t.result )
+ return links
+
+def getAllClusters( main ):
+ """
+ Return a list containing the clusters output from each ONOS node
+ """
+ clusters = []
+ threads = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].clusters,
+ name="clusters-" + str( i ),
+ args=[ ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ clusters.append( t.result )
+ return clusters
+
+
diff --git a/TestON/tests/FUNCintentRest/FUNCintentRest.params b/TestON/tests/FUNCintentRest/FUNCintentRest.params
new file mode 100644
index 0000000..edb8c85
--- /dev/null
+++ b/TestON/tests/FUNCintentRest/FUNCintentRest.params
@@ -0,0 +1,58 @@
+<PARAMS>
+ # CASE - Description
+ # 1 - Variable initialization and optional pull and build ONOS package
+ # 2 - Install ONOS
+ # 9 - Report logs
+ # 11 - Start Mininet
+ # 12 - Assign switch to controller
+ # 13 - Create a data of hosts information
+ # 14 - Stop Mininet
+ # 1000 - Test host intents
+ # 2000 - Test point intents
+ # 3000 - Test single to multi point intents
+ # 4000 - Test multi to single point intents
+
+ <testcases>1,2,10,12,13,1000,2000</testcases>
+
+ <SCALE>
+ <size>1,3</size>
+ </SCALE>
+
+ <DEPENDENCY>
+ <path>/tests/FUNCintentRest/Dependency/</path>
+ <wrapper1>startUp</wrapper1>
+ <wrapper2>FuncIntentFunction</wrapper2>
+ <wrapper3>topo</wrapper3>
+ <topology>newFuncTopo.py</topology>
+ </DEPENDENCY>
+
+ <ENV>
+ <cellApps>drivers,openflow,proxyarp,mobility</cellApps>
+ </ENV>
+ <GIT>
+ <pull>False</pull>
+ <branch>master</branch>
+ </GIT>
+
+ <SLEEP>
+ <startup>15</startup>
+ <reroute>5</reroute>
+ <checkintent>5</checkintent>
+ <fwd>5</fwd>
+ <hostintent>3</hostintent>
+ </SLEEP>
+
+ <MININET>
+ <switch>7</switch>
+ <links>20</links>
+ </MININET>
+
+ # Intent tests params
+ <SDNIP>
+ <tcpProto>6</tcpProto>
+ <icmpProto>1</icmpProto>
+ <srcPort>5001</srcPort>
+ <dstPort>5001</dstPort>
+ </SDNIP>
+
+</PARAMS>
diff --git a/TestON/tests/FUNCintentRest/FUNCintentRest.py b/TestON/tests/FUNCintentRest/FUNCintentRest.py
new file mode 100644
index 0000000..ef204e9
--- /dev/null
+++ b/TestON/tests/FUNCintentRest/FUNCintentRest.py
@@ -0,0 +1,1196 @@
+
+# Testing the basic intent functionality of ONOS
+
+import time
+import json
+
+class FUNCintentRest:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ import time
+ import os
+ import imp
+
+ """
+ - Construct tests variables
+ - GIT ( optional )
+ - Checkout ONOS master branch
+ - Pull latest ONOS code
+ - Building ONOS ( optional )
+ - 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 " +\
+ "from params file, and pull and build the " +\
+ " latest ONOS package"
+ stepResult = main.FALSE
+
+ # Test variables
+ try:
+ main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
+ main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+ gitBranch = main.params[ 'GIT' ][ 'branch' ]
+ main.dependencyPath = main.testOnDirectory + \
+ main.params[ 'DEPENDENCY' ][ 'path' ]
+ main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
+ main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
+ if main.ONOSbench.maxNodes:
+ main.maxNodes = int( main.ONOSbench.maxNodes )
+ else:
+ main.maxNodes = 0
+ wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
+ wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
+ wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
+ main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+ main.checkIntentSleep = int( main.params[ 'SLEEP' ]\
+ [ 'checkintent' ] )
+ main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
+ main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
+ main.hostIntentSleep = int( main.params[ 'SLEEP' ][ 'hostintent' ] )
+ gitPull = main.params[ 'GIT' ][ 'pull' ]
+ main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
+ main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
+ main.cellData = {} # for creating cell file
+ main.hostsData = {}
+ main.CLIs = []
+ main.ONOSip = []
+
+ main.ONOSip = main.ONOSbench.getOnosIps()
+
+ # Assigning ONOS cli handles to a list
+ for i in range( 1, main.maxNodes + 1 ):
+ main.CLIs.append( getattr( main, 'ONOSrest' + str( i ) ) )
+
+ # -- INIT SECTION, ONLY RUNS ONCE -- #
+ main.startUp = imp.load_source( wrapperFile1,
+ main.dependencyPath +
+ wrapperFile1 +
+ ".py" )
+
+ main.intentFunction = imp.load_source( wrapperFile2,
+ main.dependencyPath +
+ wrapperFile2 +
+ ".py" )
+
+ main.topo = imp.load_source( wrapperFile3,
+ main.dependencyPath +
+ wrapperFile3 +
+ ".py" )
+
+ copyResult = main.ONOSbench.copyMininetFile( main.topology,
+ main.dependencyPath,
+ main.Mininet1.user_name,
+ main.Mininet1.ip_address )
+ if main.CLIs:
+ stepResult = main.TRUE
+ else:
+ main.log.error( "Did not properly created list of ONOS CLI handle" )
+ stepResult = main.FALSE
+ except Exception as e:
+ main.log.exception(e)
+ main.cleanup()
+ main.exit()
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully construct " +
+ "test variables ",
+ onfail="Failed to construct test variables" )
+
+ if gitPull == 'True':
+ main.step( "Building ONOS in " + gitBranch + " branch" )
+ onosBuildResult = main.startUp.onosBuild( main, gitBranch )
+ stepResult = onosBuildResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully compiled " +
+ "latest ONOS",
+ onfail="Failed to compile " +
+ "latest ONOS" )
+ else:
+ main.log.warn( "Did not pull new code so skipping mvn " +
+ "clean install" )
+ main.ONOSbench.getVersion( report=True )
+
+ def CASE2( self, main ):
+ """
+ - Set up cell
+ - Create cell file
+ - Set cell file
+ - Verify cell file
+ - Kill ONOS process
+ - Uninstall ONOS cluster
+ - Verify ONOS start up
+ - Install ONOS cluster
+ - Connect to cli
+ """
+
+ # main.scale[ 0 ] determines the current number of ONOS controller
+ main.numCtrls = int( main.scale[ 0 ] )
+
+ main.case( "Starting up " + str( main.numCtrls ) +
+ " node(s) ONOS cluster" )
+ 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 enviornment setup" )
+
+ for i in range( main.maxNodes ):
+ main.ONOSbench.onosDie( main.ONOSip[ i ] )
+
+ print "NODE COUNT = ", main.numCtrls
+
+ tempOnosIp = []
+ for i in range( main.numCtrls ):
+ tempOnosIp.append( main.ONOSip[i] )
+
+ main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
+ "temp", main.Mininet1.ip_address,
+ main.apps, tempOnosIp )
+
+ main.step( "Apply cell to environment" )
+ cellResult = main.ONOSbench.setCell( "temp" )
+ verifyResult = main.ONOSbench.verifyCell()
+ stepResult = cellResult and verifyResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully applied cell to " + \
+ "environment",
+ onfail="Failed to apply cell to environment " )
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+ stepResult = packageResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully created ONOS package",
+ onfail="Failed to create ONOS package" )
+
+ time.sleep( main.startUpSleep )
+ main.step( "Uninstalling ONOS package" )
+ onosUninstallResult = main.TRUE
+ for i in range( main.numCtrls ):
+ onosUninstallResult = onosUninstallResult and \
+ main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
+ stepResult = onosUninstallResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully uninstalled ONOS package",
+ onfail="Failed to uninstall ONOS package" )
+
+ time.sleep( main.startUpSleep )
+ main.step( "Installing ONOS package" )
+ onosInstallResult = main.TRUE
+ for i in range( main.numCtrls ):
+ onosInstallResult = onosInstallResult and \
+ main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
+ stepResult = onosInstallResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully installed ONOS package",
+ onfail="Failed to install ONOS package" )
+
+ time.sleep( main.startUpSleep )
+ main.step( "Starting ONOS service" )
+ stopResult = main.TRUE
+ startResult = main.TRUE
+ onosIsUp = main.TRUE
+
+ for i in range( main.numCtrls ):
+ onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+ if onosIsUp == main.TRUE:
+ main.log.report( "ONOS instance is up and ready" )
+ else:
+ main.log.report( "ONOS instance may not be up, stop and " +
+ "start ONOS again " )
+ for i in range( main.numCtrls ):
+ stopResult = stopResult and \
+ main.ONOSbench.onosStop( main.ONOSip[ i ] )
+ for i in range( main.numCtrls ):
+ startResult = startResult and \
+ main.ONOSbench.onosStart( main.ONOSip[ i ] )
+ stepResult = onosIsUp and stopResult and startResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="ONOS service is ready",
+ onfail="ONOS service did not start properly" )
+
+ # Remove the first element in main.scale list
+ main.scale.remove( main.scale[ 0 ] )
+
+ def CASE8( self, main ):
+ """
+ Compare Topo
+ """
+ import json
+
+ main.case( "Compare ONOS Topology view to Mininet topology" )
+ main.caseExplanation = "Compare topology elements between Mininet" +\
+ " and ONOS"
+
+ main.step( "Gathering topology information" )
+ # TODO: add a paramaterized sleep here
+ devicesResults = main.TRUE
+ linksResults = main.TRUE
+ hostsResults = main.TRUE
+ devices = main.topo.getAllDevices( main )
+ hosts = main.topo.getAllHosts( main )
+ ports = main.topo.getAllPorts( main )
+ links = main.topo.getAllLinks( main )
+ clusters = main.topo.getAllClusters( main )
+
+ mnSwitches = main.Mininet1.getSwitches()
+ mnLinks = main.Mininet1.getLinks()
+ mnHosts = main.Mininet1.getHosts()
+
+ main.step( "Conmparing MN topology to ONOS topology" )
+ for controller in range( main.numCtrls ):
+ controllerStr = str( controller + 1 )
+ if devices[ controller ] and ports[ controller ] and\
+ "Error" not in devices[ controller ] and\
+ "Error" not in ports[ controller ]:
+
+ currentDevicesResult = main.Mininet1.compareSwitches(
+ mnSwitches,
+ json.loads( devices[ controller ] ),
+ json.loads( ports[ controller ] ) )
+ else:
+ currentDevicesResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentDevicesResult,
+ onpass="ONOS" + controllerStr +
+ " Switches view is correct",
+ onfail="ONOS" + controllerStr +
+ " Switches view is incorrect" )
+
+ if links[ controller ] and "Error" not in links[ controller ]:
+ currentLinksResult = main.Mininet1.compareLinks(
+ mnSwitches, mnLinks,
+ json.loads( links[ controller ] ) )
+ else:
+ currentLinksResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentLinksResult,
+ onpass="ONOS" + controllerStr +
+ " links view is correct",
+ onfail="ONOS" + controllerStr +
+ " links view is incorrect" )
+
+ if hosts[ controller ] or "Error" not in hosts[ controller ]:
+ currentHostsResult = main.Mininet1.compareHosts(
+ mnHosts,
+ json.loads( hosts[ controller ] ) )
+ else:
+ currentHostsResult = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=currentHostsResult,
+ onpass="ONOS" + controllerStr +
+ " hosts exist in Mininet",
+ onfail="ONOS" + controllerStr +
+ " hosts don't match Mininet" )
+
+ def CASE9( self, main ):
+ '''
+ Report errors/warnings/exceptions
+ '''
+ main.log.info( "Error report: \n" )
+ main.ONOSbench.logReport( globalONOSip[0],
+ [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
+ "s" )
+ #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
+
+ def CASE10( self, main ):
+ """
+ Start Mininet topology with OF 1.0 switches
+ """
+ main.OFProtocol = "1.0"
+ main.log.report( "Start Mininet topology with OF 1.0 switches" )
+ main.case( "Start Mininet topology with OF 1.0 switches" )
+ main.caseExplanation = "Start mininet topology with OF 1.0 " +\
+ "switches to test intents, exits out if " +\
+ "topology did not start correctly"
+
+ main.step( "Starting Mininet topology with OF 1.0 switches" )
+ args = "--switch ovs,protocols=OpenFlow10"
+ topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
+ main.topology,
+ args=args )
+ stepResult = topoResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully loaded topology",
+ onfail="Failed to load topology" )
+ # Exit if topology did not load properly
+ if not topoResult:
+ main.cleanup()
+ main.exit()
+
+ def CASE11( self, main ):
+ """
+ Start Mininet topology with OF 1.3 switches
+ """
+ main.OFProtocol = "1.3"
+ main.log.report( "Start Mininet topology with OF 1.3 switches" )
+ main.case( "Start Mininet topology with OF 1.3 switches" )
+ main.caseExplanation = "Start mininet topology with OF 1.3 " +\
+ "switches to test intents, exits out if " +\
+ "topology did not start correctly"
+
+ main.step( "Starting Mininet topology with OF 1.3 switches" )
+ args = "--switch ovs,protocols=OpenFlow13"
+ topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
+ main.topology,
+ args=args )
+ stepResult = topoResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully loaded topology",
+ onfail="Failed to load topology" )
+ # Exit if topology did not load properly
+ if not topoResult:
+ main.cleanup()
+ main.exit()
+
+ def CASE12( self, main ):
+ """
+ Assign mastership to controllers
+ """
+ import re
+
+ main.case( "Assign switches to controllers" )
+ main.step( "Assigning switches to controllers" )
+ main.caseExplanation = "Assign OF " + main.OFProtocol +\
+ " switches to ONOS nodes"
+
+ assignResult = main.TRUE
+ switchList = []
+
+ # Creates a list switch name, use getSwitch() function later...
+ for i in range( 1, ( main.numSwitch + 1 ) ):
+ switchList.append( 's' + str( i ) )
+
+ tempONOSip = []
+ for i in range( main.numCtrls ):
+ tempONOSip.append( main.ONOSip[ i ] )
+
+ assignResult = main.Mininet1.assignSwController( sw=switchList,
+ ip=tempONOSip,
+ port='6633' )
+ if not assignResult:
+ main.cleanup()
+ main.exit()
+
+ for i in range( 1, ( main.numSwitch + 1 ) ):
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ print( "Response is " + str( response ) )
+ if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
+ assignResult = assignResult and main.TRUE
+ else:
+ assignResult = main.FALSE
+ stepResult = assignResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully assigned switches" +
+ "to controller",
+ onfail="Failed to assign switches to " +
+ "controller" )
+ def CASE13( self, main ):
+ """
+ Discover all hosts and store its data to a dictionary
+ """
+ main.case( "Discover all hosts" )
+
+ stepResult = main.TRUE
+ main.step( "Discover all hosts using pingall " )
+ stepResult = main.intentFunction.getHostsData( main )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully discovered hosts",
+ onfail="Failed to discover hosts" )
+
+ def CASE14( self, main ):
+ """
+ Stop mininet
+ """
+ main.log.report( "Stop Mininet topology" )
+ main.case( "Stop Mininet topology" )
+ main.caseExplanation = "Stopping the current mininet topology " +\
+ "to start up fresh"
+
+ main.step( "Stopping Mininet Topology" )
+ topoResult = main.Mininet1.stopNet( )
+ stepResult = topoResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully stop mininet",
+ onfail="Failed to stop mininet" )
+ # Exit if topology did not load properly
+ if not topoResult:
+ main.cleanup()
+ main.exit()
+
+ def CASE1000( self, main ):
+ """
+ Add host intents between 2 host:
+ - Discover hosts
+ - Add host intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ """
+ import time
+ import json
+ import re
+
+ # Assert variables - These variable's name|format must be followed
+ # if you want to use the wrapper function
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+
+ main.case( "Host Intents Test - " + str( main.numCtrls ) +
+ " NODE(S) - OF " + main.OFProtocol )
+ main.caseExplanation = "This test case tests Host intents using " +\
+ str( main.numCtrls ) + " node(s) cluster;\n" +\
+ "Different type of hosts will be tested in " +\
+ "each step such as IPV4, Dual stack, VLAN " +\
+ "etc;\nThe test will use OF " + main.OFProtocol\
+ + " OVS running in Mininet"
+
+ main.step( "IPV4: Add host intents between h1 and h9" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.hostIntent( main,
+ onosNode='0',
+ name='IPV4',
+ host1='h1',
+ host2='h9',
+ host1Id='00:00:00:00:00:01/-1',
+ host2Id='00:00:00:00:00:09/-1',
+ sw1='s5',
+ sw2='s2',
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4: Host intent test successful " +
+ "between two IPV4 hosts",
+ onfail="IPV4: Host intent test failed " +
+ "between two IPV4 hosts")
+
+ main.step( "DUALSTACK1: Add host intents between h3 and h11" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.hostIntent( main,
+ name='DUALSTACK',
+ host1='h3',
+ host2='h11',
+ host1Id='00:00:00:00:00:03/-1',
+ host2Id='00:00:00:00:00:0B/-1',
+ sw1='s5',
+ sw2='s2',
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="DUALSTACK: Host intent test " +
+ "successful between two " +
+ "dual stack host using IPV4",
+ onfail="DUALSTACK: Host intent test " +
+ "failed between two" +
+ "dual stack host using IPV4" )
+
+
+ main.step( "DUALSTACK2: Add host intents between h1 and h11" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.hostIntent( main,
+ name='DUALSTACK2',
+ host1='h1',
+ host2='h11',
+ sw1='s5',
+ sw2='s2',
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="DUALSTACK2: Host intent test " +
+ "successful between two " +
+ "dual stack host using IPV4",
+ onfail="DUALSTACK2: Host intent test " +
+ "failed between two" +
+ "dual stack host using IPV4" )
+
+ main.step( "1HOP: Add host intents between h1 and h3" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.hostIntent( main,
+ name='1HOP',
+ host1='h1',
+ host2='h3' )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="1HOP: Host intent test " +
+ "successful between two " +
+ "host using IPV4 in the same switch",
+ onfail="1HOP: Host intent test " +
+ "failed between two" +
+ "host using IPV4 in the same switch" )
+
+ main.step( "VLAN1: Add vlan host intents between h4 and h12" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.hostIntent( main,
+ name='VLAN1',
+ host1='h4',
+ host2='h12',
+ host1Id='00:00:00:00:00:04/100',
+ host2Id='00:00:00:00:00:0C/100',
+ sw1='s5',
+ sw2='s2',
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="VLAN1: Host intent test " +
+ "successful between two " +
+ "host using IPV4 in the same VLAN",
+ onfail="VLAN1: Host intent test " +
+ "failed between two" +
+ "host using IPV4 in the same VLAN" )
+
+ main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.hostIntent( main,
+ name='VLAN2',
+ host1='h13',
+ host2='h20' )
+
+ utilities.assert_equals( expect=main.FALSE,
+ actual=stepResult,
+ onpass="VLAN2: Host intent negative test " +
+ "successful between two " +
+ "host using IPV4 in different VLAN",
+ onfail="VLAN2: Host intent negative test " +
+ "failed between two" +
+ "host using IPV4 in different VLAN" )
+
+
+ def CASE2000( self, main ):
+ """
+ Add point intents between 2 hosts:
+ - Get device ids | ports
+ - Add point intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ """
+ import time
+ import json
+ import re
+
+ # Assert variables - These variable's name|format must be followed
+ # if you want to use the wrapper function
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+
+ main.case( "Point Intents Test - " + str( main.numCtrls ) +
+ " NODE(S) - OF " + main.OFProtocol )
+ main.caseExplanation = "This test case will test point to point" +\
+ " intents using " + str( main.numCtrls ) +\
+ " node(s) cluster;\n" +\
+ "Different type of hosts will be tested in " +\
+ "each step such as IPV4, Dual stack, VLAN etc" +\
+ ";\nThe test will use OF " + main.OFProtocol +\
+ " OVS running in Mininet"
+
+ # No option point intents
+ main.step( "NOOPTION: Add point intents between h1 and h9" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.pointIntent(
+ main,
+ name="NOOPTION",
+ host1="h1",
+ host2="h9",
+ deviceId1="of:0000000000000005/1",
+ deviceId2="of:0000000000000006/1",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="NOOPTION: Point intent test " +
+ "successful using no match action",
+ onfail="NOOPTION: Point intent test " +
+ "failed using no match action" )
+
+ stepResult = main.TRUE
+ main.step( "IPV4: Add point intents between h1 and h9" )
+ stepResult = main.intentFunction.pointIntent(
+ main,
+ name="IPV4",
+ host1="h1",
+ host2="h9",
+ deviceId1="of:0000000000000005/1",
+ deviceId2="of:0000000000000006/1",
+ port1="",
+ port2="",
+ ethType="IPV4",
+ mac1="00:00:00:00:00:01",
+ mac2="00:00:00:00:00:09",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ip1="",
+ ip2="",
+ tcp1="",
+ tcp2="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4: Point intent test " +
+ "successful using IPV4 type with " +
+ "MAC addresses",
+ onfail="IPV4: Point intent test " +
+ "failed using IPV4 type with " +
+ "MAC addresses" )
+ main.step( "IPV4_2: Add point intents between h1 and h9" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.pointIntent(
+ main,
+ name="IPV4_2",
+ host1="h1",
+ host2="h9",
+ deviceId1="of:0000000000000005/1",
+ deviceId2="of:0000000000000006/1",
+ ipProto="",
+ ip1="",
+ ip2="",
+ tcp1="",
+ tcp2="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4_2: Point intent test " +
+ "successful using IPV4 type with " +
+ "no MAC addresses",
+ onfail="IPV4_2: Point intent test " +
+ "failed using IPV4 type with " +
+ "no MAC addresses" )
+
+ main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
+ stepResult = main.TRUE
+ mac1 = main.hostsData[ 'h1' ][ 'mac' ]
+ mac2 = main.hostsData[ 'h9' ][ 'mac' ]
+ try:
+ ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
+ ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
+ except KeyError:
+ main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
+ "main.hostsData" )
+ ip1 = main.Mininet1.getIPAddress( 'h1')
+ ip2 = main.Mininet1.getIPAddress( 'h9')
+
+ ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
+ # Uneccessary, not including this in the selectors
+ tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
+ tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
+
+ stepResult = main.intentFunction.pointIntent(
+ main,
+ name="SDNIP-TCP",
+ host1="h1",
+ host2="h9",
+ deviceId1="of:0000000000000005/1",
+ deviceId2="of:0000000000000006/1",
+ mac1=mac1,
+ mac2=mac2,
+ ethType="IPV4",
+ ipProto=ipProto,
+ ip1=ip1,
+ ip2=ip2 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="SDNIP-TCP: Point intent test " +
+ "successful using IPV4 type with " +
+ "IP protocol TCP enabled",
+ onfail="SDNIP-TCP: Point intent test " +
+ "failed using IPV4 type with " +
+ "IP protocol TCP enabled" )
+
+ main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
+ stepResult = main.TRUE
+ mac1 = main.hostsData[ 'h1' ][ 'mac' ]
+ mac2 = main.hostsData[ 'h9' ][ 'mac' ]
+ ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
+ ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
+ ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
+ tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
+ tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
+
+ stepResult = main.intentFunction.pointIntent(
+ main,
+ name="SDNIP-ICMP",
+ host1="h1",
+ host2="h9",
+ deviceId1="of:0000000000000005/1",
+ deviceId2="of:0000000000000006/1",
+ mac1=mac1,
+ mac2=mac2,
+ ethType="IPV4",
+ ipProto=ipProto )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="SDNIP-ICMP: Point intent test " +
+ "successful using IPV4 type with " +
+ "IP protocol ICMP enabled",
+ onfail="SDNIP-ICMP: Point intent test " +
+ "failed using IPV4 type with " +
+ "IP protocol ICMP enabled" )
+
+ main.step( "DUALSTACK1: Add point intents between h1 and h9" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.pointIntent(
+ main,
+ name="DUALSTACK1",
+ host1="h3",
+ host2="h11",
+ deviceId1="of:0000000000000005",
+ deviceId2="of:0000000000000006",
+ port1="3",
+ port2="3",
+ ethType="IPV4",
+ mac1="00:00:00:00:00:03",
+ mac2="00:00:00:00:00:0B",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ip1="",
+ ip2="",
+ tcp1="",
+ tcp2="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="DUALSTACK1: Point intent test " +
+ "successful using IPV4 type with " +
+ "MAC addresses",
+ onfail="DUALSTACK1: Point intent test " +
+ "failed using IPV4 type with " +
+ "MAC addresses" )
+
+ main.step( "VLAN: Add point intents between h5 and h21" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.pointIntent(
+ main,
+ name="VLAN",
+ host1="h5",
+ host2="h21",
+ deviceId1="of:0000000000000005/5",
+ deviceId2="of:0000000000000007/5",
+ port1="",
+ port2="",
+ ethType="IPV4",
+ mac1="00:00:00:00:00:05",
+ mac2="00:00:00:00:00:15",
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ip1="",
+ ip2="",
+ tcp1="",
+ tcp2="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="VLAN1: Point intent test " +
+ "successful using IPV4 type with " +
+ "MAC addresses",
+ onfail="VLAN1: Point intent test " +
+ "failed using IPV4 type with " +
+ "MAC addresses" )
+
+ main.step( "1HOP: Add point intents between h1 and h3" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.hostIntent( main,
+ name='1HOP',
+ host1='h1',
+ host2='h3' )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="1HOP: Point intent test " +
+ "successful using IPV4 type with " +
+ "no MAC addresses",
+ onfail="1HOP: Point intent test " +
+ "failed using IPV4 type with " +
+ "no MAC addresses" )
+
+ def CASE3000( self, main ):
+ """
+ Add single point to multi point intents
+ - Get device ids
+ - Add single point to multi point intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ """
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+
+ main.case( "Single To Multi Point Intents Test - " +
+ str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
+ main.caseExplanation = "This test case will test single point to" +\
+ " multi point intents using " +\
+ str( main.numCtrls ) + " node(s) cluster;\n" +\
+ "Different type of hosts will be tested in " +\
+ "each step such as IPV4, Dual stack, VLAN etc" +\
+ ";\nThe test will use OF " + main.OFProtocol +\
+ " OVS running in Mininet"
+
+ main.step( "NOOPTION: Add single point to multi point intents" )
+ stepResult = main.TRUE
+ hostNames = [ 'h8', 'h16', 'h24' ]
+ devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
+ 'of:0000000000000007/8' ]
+ macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
+ stepResult = main.intentFunction.singleToMultiIntent(
+ main,
+ name="NOOPTION",
+ hostNames=hostNames,
+ devices=devices,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="NOOPTION: Successfully added single "
+ + " point to multi point intents" +
+ " with no match action",
+ onfail="NOOPTION: Failed to add single point"
+ + " point to multi point intents" +
+ " with no match action" )
+
+ main.step( "IPV4: Add single point to multi point intents" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.singleToMultiIntent(
+ main,
+ name="IPV4",
+ hostNames=hostNames,
+ devices=devices,
+ ports=None,
+ ethType="IPV4",
+ macs=macs,
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4: Successfully added single "
+ + " point to multi point intents" +
+ " with IPV4 type and MAC addresses",
+ onfail="IPV4: Failed to add single point"
+ + " point to multi point intents" +
+ " with IPV4 type and MAC addresses" )
+
+ main.step( "IPV4_2: Add single point to multi point intents" )
+ stepResult = main.TRUE
+ hostNames = [ 'h8', 'h16', 'h24' ]
+ stepResult = main.intentFunction.singleToMultiIntent(
+ main,
+ name="IPV4",
+ hostNames=hostNames,
+ ethType="IPV4",
+ lambdaAlloc=False )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4_2: Successfully added single "
+ + " point to multi point intents" +
+ " with IPV4 type and no MAC addresses",
+ onfail="IPV4_2: Failed to add single point"
+ + " point to multi point intents" +
+ " with IPV4 type and no MAC addresses" )
+
+ main.step( "VLAN: Add single point to multi point intents" )
+ stepResult = main.TRUE
+ hostNames = [ 'h4', 'h12', 'h20' ]
+ devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
+ 'of:0000000000000007/4' ]
+ macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
+ stepResult = main.intentFunction.singleToMultiIntent(
+ main,
+ name="VLAN",
+ hostNames=hostNames,
+ devices=devices,
+ ports=None,
+ ethType="IPV4",
+ macs=macs,
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="VLAN: Successfully added single "
+ + " point to multi point intents" +
+ " with IPV4 type and MAC addresses" +
+ " in the same VLAN",
+ onfail="VLAN: Failed to add single point"
+ + " point to multi point intents" +
+ " with IPV4 type and MAC addresses" +
+ " in the same VLAN")
+
+ def CASE4000( self, main ):
+ """
+ Add multi point to single point intents
+ - Get device ids
+ - Add multi point to single point intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ """
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+
+ main.case( "Multi To Single Point Intents Test - " +
+ str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
+ main.caseExplanation = "This test case will test single point to" +\
+ " multi point intents using " +\
+ str( main.numCtrls ) + " node(s) cluster;\n" +\
+ "Different type of hosts will be tested in " +\
+ "each step such as IPV4, Dual stack, VLAN etc" +\
+ ";\nThe test will use OF " + main.OFProtocol +\
+ " OVS running in Mininet"
+
+ main.step( "NOOPTION: Add multi point to single point intents" )
+ stepResult = main.TRUE
+ hostNames = [ 'h8', 'h16', 'h24' ]
+ devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
+ 'of:0000000000000007/8' ]
+ macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
+ stepResult = main.intentFunction.multiToSingleIntent(
+ main,
+ name="NOOPTION",
+ hostNames=hostNames,
+ devices=devices,
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="NOOPTION: Successfully added multi "
+ + " point to single point intents" +
+ " with no match action",
+ onfail="NOOPTION: Failed to add multi point" +
+ " to single point intents" +
+ " with no match action" )
+
+ main.step( "IPV4: Add multi point to single point intents" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.multiToSingleIntent(
+ main,
+ name="IPV4",
+ hostNames=hostNames,
+ devices=devices,
+ ports=None,
+ ethType="IPV4",
+ macs=macs,
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4: Successfully added multi point"
+ + " to single point intents" +
+ " with IPV4 type and MAC addresses",
+ onfail="IPV4: Failed to add multi point" +
+ " to single point intents" +
+ " with IPV4 type and MAC addresses" )
+
+ main.step( "IPV4_2: Add multi point to single point intents" )
+ stepResult = main.TRUE
+ hostNames = [ 'h8', 'h16', 'h24' ]
+ stepResult = main.intentFunction.multiToSingleIntent(
+ main,
+ name="IPV4",
+ hostNames=hostNames,
+ ethType="IPV4",
+ lambdaAlloc=False )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4_2: Successfully added multi point"
+ + " to single point intents" +
+ " with IPV4 type and no MAC addresses",
+ onfail="IPV4_2: Failed to add multi point" +
+ " to single point intents" +
+ " with IPV4 type and no MAC addresses" )
+
+ main.step( "VLAN: Add multi point to single point intents" )
+ stepResult = main.TRUE
+ hostNames = [ 'h5', 'h13', 'h21' ]
+ devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
+ 'of:0000000000000007/5' ]
+ macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
+ stepResult = main.intentFunction.multiToSingleIntent(
+ main,
+ name="VLAN",
+ hostNames=hostNames,
+ devices=devices,
+ ports=None,
+ ethType="IPV4",
+ macs=macs,
+ bandwidth="",
+ lambdaAlloc=False,
+ ipProto="",
+ ipAddresses="",
+ tcp="",
+ sw1="s5",
+ sw2="s2",
+ expectedLink=18 )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="VLAN: Successfully added multi point"
+ + " to single point intents" +
+ " with IPV4 type and MAC addresses" +
+ " in the same VLAN",
+ onfail="VLAN: Failed to add multi point" +
+ " to single point intents" )
+
+ def CASE5000( self, main ):
+ """
+ Will add description in next patch set
+ """
+ assert main, "There is no main"
+ assert main.CLIs, "There is no main.CLIs"
+ assert main.Mininet1, "Mininet handle should be named Mininet1"
+ assert main.numSwitch, "Placed the total number of switch topology in \
+ main.numSwitch"
+ main.case( "Test host mobility with host intents " )
+ main.step( " Testing host mobility by moving h1 from s5 to s6" )
+ h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
+
+ main.log.info( "Moving h1 from s5 to s6")
+
+ main.Mininet1.moveHost( "h1","s5","s6" )
+
+ main.intentFunction.getHostsData( main )
+ h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
+
+ utilities.assert_equals( expect="of:0000000000000006",
+ actual=h1PostMove,
+ onpass="Mobility: Successfully moved h1 to s6",
+ onfail="Mobility: Failed to moved h1 to s6" +
+ " to single point intents" +
+ " with IPV4 type and MAC addresses" +
+ " in the same VLAN" )
+
+ main.step( "IPV4: Add host intents between h1 and h9" )
+ stepResult = main.TRUE
+ stepResult = main.intentFunction.hostIntent( main,
+ onosNode='0',
+ name='IPV4',
+ host1='h1',
+ host2='h9',
+ host1Id='00:00:00:00:00:01/-1',
+ host2Id='00:00:00:00:00:09/-1' )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="IPV4: Host intent test successful " +
+ "between two IPV4 hosts",
+ onfail="IPV4: Host intent test failed " +
+ "between two IPV4 hosts")
diff --git a/TestON/tests/FUNCintentRest/FUNCintentRest.topo b/TestON/tests/FUNCintentRest/FUNCintentRest.topo
new file mode 100755
index 0000000..647bdc6
--- /dev/null
+++ b/TestON/tests/FUNCintentRest/FUNCintentRest.topo
@@ -0,0 +1,57 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>localhost</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOSbench>
+
+ <ONOSrest1>
+ <host>OC1</host>
+ <port>8181</port>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosRestDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOSrest1>
+
+ <ONOSrest2>
+ <host>OC2</host>
+ <port>8181</port>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosRestDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOSrest2>
+
+ <ONOSrest3>
+ <host>OC3</host>
+ <port>8181</port>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosRestDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOSrest3>
+
+ <Mininet1>
+ <host>localhost</host>
+ <user>admin</user>
+ <password></password>
+ <type>MininetCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </Mininet1>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/FUNCintentRest/README b/TestON/tests/FUNCintentRest/README
new file mode 100644
index 0000000..ce4e99f
--- /dev/null
+++ b/TestON/tests/FUNCintentRest/README
@@ -0,0 +1,39 @@
+Summary:
+ This test suite consist of basic intent functionality testing.
+ The following is an overview of how host intents is being tested.
+ Steps:
+ - Discover hosts
+ - Add host intents
+ - Check intents
+ - Verify flows
+ - Ping hosts
+ - Reroute
+ - Link down
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Link up
+ - Verify flows
+ - Check topology
+ - Ping hosts
+ - Remove intents
+ This test suite includes testing of different types of intents such as
+ host, point, single-to-multi and multi-to-single ( More intent types to
+ add later ). The same steps above is being performed to other type of
+ intents.
+
+Required:
+ This test requires Mininet topology file newFuncIntent.py that is in the
+ Dependency folder. You should run the topology file to check for any
+ missing packages. The mininet topology file has different type of hosts
+ including VLAN hosts. Therefore you need to install VLAN module to build
+ the topology correctly.
+
+VLAN configuration:
+ Execute command:
+ $ sudo apt-get install vlan
+ Configuration:
+ $ sudo modprobe 8021q
+ NOTE:To make this configuration permanent
+ $ sudo su -c 'echo "8021q" >> /etc/modules'
+
diff --git a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.params b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.params
new file mode 100644
index 0000000..3ca917f
--- /dev/null
+++ b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.params
@@ -0,0 +1,45 @@
+<PARAMS>
+ # CASE - Description
+ # 1 - Variable initialization and optional pull and build ONOS package
+ # 2 - Create Network northbound test
+ # 3 - Update Network northbound test
+ # 4 - Delete Network northbound test
+ # 5 - Create Subnet northbound test
+ # 6 - Update Subnet northbound test
+ # 7 - Delete Subnet northbound test
+ # 8 - Create Virtualport northbound test
+ # 9 - Update Virtualport northbound test
+ #10 - Delete Virtualport northbound test
+
+ <testcases>1,2,3,4</testcases>
+
+ <SLEEP>
+ <startup>15</startup>
+ </SLEEP>
+
+ <ENV>
+ <cellName>singlenode</cellName>
+ <cellApps>drivers,openflow,proxyarp,mobility</cellApps>
+ </ENV>
+
+ <CTRL>
+ <ip1>OC1</ip1>
+ <port1>6633</port1>
+ </CTRL>
+
+ <HTTP>
+ <port>8181</port>
+ <path>/onos/vtn/</path>
+ </HTTP>
+
+ <GIT>
+ <pull>False</pull>
+ <branch>master</branch>
+ </GIT>
+
+ <MININET>
+ <switch>7</switch>
+ <links>20</links>
+ </MININET>
+
+</PARAMS>
diff --git a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
new file mode 100644
index 0000000..e3c3cc4
--- /dev/null
+++ b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
@@ -0,0 +1,402 @@
+"""
+Description: This test is to determine if North bound
+ can handle the request
+
+List of test cases:
+CASE1 - Variable initialization and optional pull and build ONOS package
+CASE2 - Create Network northbound test
+CASE3 - Update Network northbound test
+CASE4 - Delete Network northbound test
+CASE5 - Create Subnet northbound test
+CASE6 - Update Subnet northbound test
+CASE7 - Delete Subnet northbound test
+CASE8 - Create Virtualport northbound test
+CASE9 - Update Virtualport northbound test
+CASE10 - Delete Virtualport northbound test
+
+lanqinglong@huawei.com
+"""
+import os
+
+class FUNCvirNetNB:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ """
+ CASE1 is to compile ONOS and push it to the test machines
+
+ Startup sequence:
+ cell<name>
+ onos-verify-cell
+ NOTE:temporary - onos-remove-raft-logs
+ onos-uninstall
+ git pull
+ mvn clean install
+ onos-package
+ onos-install -f
+ onos-wait-for-start
+ start cli sessions
+ start vtnrsc
+ """
+
+ import time
+ import os
+ main.log.info( "ONOS Single node Start "+
+ "VirtualNet Northbound test - initialization" )
+ main.case( "Setting up test environment" )
+ main.caseExplanation = "Setup the test environment including "+\
+ "installing ONOS,start ONOS."
+
+ # load some variables from the params file
+ PULLCODE = False
+ if main.params['GIT']['pull'] =='True':
+ PULLCODE = True
+ gitBranch = main.params['GIT']['branch']
+ cellName = main.params['ENV']['cellName']
+ ipList = os.getenv( main.params['CTRL']['ip1'] )
+
+ main.step("Create cell file")
+ cellAppString = main.params['ENV']['cellApps']
+ main.ONOSbench.createCellFile(main.ONOSbench.ip_address,cellName,
+ main.Mininet1.ip_address,
+ cellAppString,ipList )
+
+ main.step( "Applying cell variable to environment" )
+ cellResult = main.ONOSbench.setCell(cellName)
+ verifyResult = main.ONOSbench.verifyCell()
+
+ #FIXME:this is short term fix
+ main.log.info( "Removing raft logs" )
+ main.ONOSbench.onosRemoveRaftlogs()
+
+ main.CLIs = []
+ main.nodes = []
+ main.numCtrls=1
+ main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+
+ for i in range ( 1, main.numCtrls +1):
+ try:
+ main.CLIs.append( getattr( main, 'ONOScli' + str(i) ) )
+ main.nodes.append( getattr( main, 'ONOS' + str(i) ) )
+ ipList.append( main.nodes[ -1 ].ip_address )
+ except AttributeError:
+ break
+
+ main.log.info( "Uninstalling ONOS" )
+ for node in main.nodes:
+ main.ONOSbench.onosUninstall( node.ip_address )
+
+ #Make sure ONOS is DEAD
+ main.log.info( "Killing any ONOS processes" )
+ killResults = main.TRUE
+ for node in main.nodes:
+ killed = main.ONOSbench.onosKill( node.ip_address )
+ killResults = killResults and killed
+
+ cleanInstallResult = main.TRUE
+ gitPullResult = main.TRUE
+ main.step( "Git checkout and pull " + gitBranch )
+ if PULLCODE:
+ main.ONOSbench.gitCheckout ( gitBranch )
+ gitPullResult = main.ONOSbench.gitPull()
+ # values of 1 or 3 are good
+ utilities.assert_lesser ( expect=0, actual=gitPullResult,
+ onpass="Git pull successful",
+ onfail ="Git pull failed" )
+ main.ONOSbench.getVersion( report =True )
+ main.step( "Using mvn clean install" )
+ cleanInstallResult= main.TRUE
+ if PULLCODE and gitPullResult == main.TRUE:
+ cleanInstallResult = main.ONOSbench.cleanInstall()
+ else:
+ main.log.warn("Did not pull new code so skipping mvn "+
+ "clean install")
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=cleanInstallResult,
+ onpass="MCI successful",
+ onfail="MCI failed" )
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+ utilities.assert_equals( expect=main.TRUE,
+ actual=packageResult,
+ onpass="Successfully created ONOS package",
+ onfail="Failed to create ONOS package " )
+ time.sleep( main.startUpSleep )
+
+ main.step( "Installing ONOS package" )
+ onosInstallResult = main.ONOSbench.onosInstall(
+ options="-f",node=main.nodes[0].ip_address )
+ utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
+ onpass="ONOS install successful",
+ onfail="ONOS install failed" )
+ time.sleep( main.startUpSleep )
+
+ main.step( "Checking if ONOS is up yet" )
+
+ for i in range( 2 ):
+ onos1Isup = main.ONOSbench.isup( main.nodes[0].ip_address )
+ if onos1Isup:
+ break
+ utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
+ onpass="ONOS startup successful",
+ onfail="ONOS startup failed" )
+ time.sleep( main.startUpSleep )
+
+ main.log.step( "Starting ONOS CLI sessions" )
+
+ print main.nodes[0].ip_address
+ cliResults = main.ONOScli1.startOnosCli(main.nodes[0].ip_address)
+ utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+ onpass="ONOS cli startup successful",
+ onfail="ONOS cli startup failed" )
+ time.sleep( main.startUpSleep )
+
+ main.step( "App Ids check" )
+ appCheck = main.ONOScli1.appToIDCheck()
+ if appCheck != main.TRUE:
+ main.log.warn( main.CLIs[0].apps() )
+ main.log.warn( main.CLIs[0].appIDs() )
+ utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+ onpass="App Ids seem to be correct",
+ onfail="Something is wrong with app Ids" )
+
+ if cliResults == main.FALSE:
+ main.log.error( "Failed to start ONOS, stopping test" )
+ main.cleanup()
+ main.exit()
+
+ main.step( "Install onos-app-vtnrsc app" )
+ installResults = main.ONOScli1.featureInstall( "onos-app-vtnrsc" )
+ utilities.assert_equals( expect=main.TRUE, actual=installResults,
+ onpass="Install onos-app-vtnrsc successful",
+ onfail="Install onos-app-vtnrsc app failed" )
+
+ time.sleep( main.startUpSleep )
+
+ main.step( "Install onos-app-vtnweb app" )
+ installResults = main.ONOScli1.featureInstall( "onos-app-vtnweb" )
+ utilities.assert_equals( expect=main.TRUE, actual=installResults,
+ onpass="Install onos-app-vtnweb successful",
+ onfail="Install onos-app-vtnweb app failed" )
+
+ time.sleep( main.startUpSleep )
+
+ def CASE2 ( self,main ):
+
+ """
+ Test Post Network
+ """
+ import os,sys
+ sys.path.append("..")
+ try:
+ from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
+ except ImportError:
+ main.log.exception( "Something wrong with import file or code error." )
+ main.log.info( "Import Error,please check!" )
+
+ main.log.info( "ONOS Network Post test Start" )
+ main.case( "Virtual Network NBI Test - Network" )
+ main.caseExplanation = "Test Network Post NBI " +\
+ "Verify Post Data same with Stored Data"
+
+ ctrlip = os.getenv( main.params['CTRL']['ip1'] )
+ port = main.params['HTTP']['port']
+ path = main.params['HTTP']['path']
+
+ main.step( "Generate Post Data" )
+ network = NetworkData()
+ network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
+ network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
+ postdata = network.DictoJson()
+
+ main.step( "Post Data via HTTP" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path+'networks/',
+ 'POST', None, postdata)
+
+ utilities.assert_equals(
+ expect='200',
+ actual=Poststatus,
+ onpass="Post Success",
+ onfail="Post Failed " + str( Poststatus ) + str( result ) )
+
+ main.step( "Get Data via HTTP" )
+ Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
+ 'GET', None, None)
+ utilities.assert_equals(
+ expect='200',
+ actual=Getstatus,
+ onpass="Get Success",
+ onfail="Get Failed " + str( Getstatus ) + str( result ) )
+
+ main.log.info("Post Network Data is :%s\nGet Network Data is:%s"%(postdata,result))
+
+ main.step( "Compare Send Id and Get Id" )
+ IDcmpresult = network.JsonCompare( postdata, result, 'network', 'id' )
+ TanantIDcmpresult = network.JsonCompare( postdata, result, 'network', 'tenant_id' )
+ Cmpresult = IDcmpresult and TanantIDcmpresult
+
+ utilities.assert_equals(
+ expect=True,
+ actual=Cmpresult,
+ onpass="Compare Success",
+ onfail="Compare Failed:ID compare: " + str( IDcmpresult ) + \
+ ",Tenant id compare :" + str( TanantIDcmpresult ) )
+
+ deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
+ 'DELETE', None, None )
+ utilities.assert_equals(
+ expect='200',
+ actual=deletestatus,
+ onpass="Delete Network Success",
+ onfail="Delete Network Failed")
+
+ if Cmpresult !=True:
+ main.log.error( "Post Network compare failed" )
+
+ def CASE3( self,main ):
+
+ """
+ Test Update Network
+ """
+ import os,sys
+ sys.path.append("..")
+ try:
+ from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
+ except ImportError:
+ main.log.exception( "Something wrong with import file or code error." )
+ main.log.info( "Import Error,please check!" )
+
+ main.log.info( "ONOS Network Update test Start" )
+ main.case( "Virtual Network NBI Test - Network" )
+ main.caseExplanation = "Test Network Update NBI " +\
+ "Verify Update Data same with Stored Data"
+
+ ctrlip = os.getenv( main.params['CTRL']['ip1'] )
+ port = main.params['HTTP']['port']
+ path = main.params['HTTP']['path']
+
+ main.step( "Generate Post Data" )
+ network = NetworkData()
+ network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
+ network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
+ network.shared = 'false'
+ postdata = network.DictoJson()
+
+ network.shared = 'true'
+ postdatanew = network.DictoJson()
+
+ main.step( "Post Data via HTTP" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path+'networks',
+ 'POST', None, postdata )
+ utilities.assert_equals(
+ expect='200',
+ actual=Poststatus,
+ onpass="Post Success",
+ onfail="Post Failed " + str( Poststatus ) + str( result ) )
+
+ main.step( "Update Data via HTTP" )
+ Updatestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
+ 'PUT', None, postdatanew)
+ utilities.assert_equals(
+ expect='200',
+ actual=Updatestatus,
+ onpass="Update Success",
+ onfail="Update Failed " + str( Updatestatus ) + str( result ) )
+
+ main.step( "Get Data via HTTP" )
+ Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
+ 'GET', None, None )
+ utilities.assert_equals(
+ expect='200',
+ actual=Getstatus,
+ onpass="Get Success",
+ onfail="Get Failed " + str( Getstatus ) + str( result ) )
+
+ main.step( "Compare Update data." )
+ IDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'id' )
+ TanantIDcmpresult = network.JsonCompare( postdatanew, result, 'network', 'tenant_id' )
+ Shareresult = network.JsonCompare( postdatanew, result, 'network', 'shared' )
+
+ Cmpresult = IDcmpresult and TanantIDcmpresult and Shareresult
+ utilities.assert_equals(
+ expect=True,
+ actual=Cmpresult,
+ onpass="Compare Success",
+ onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
+ ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
+ ",Name compare:" + str( Shareresult ) )
+
+ deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
+ 'DELETE', None, None )
+
+ utilities.assert_equals(
+ expect='200',
+ actual=deletestatus,
+ onpass="Delete Network Success",
+ onfail="Delete Network Failed" )
+
+ if Cmpresult!=True:
+ main.log.error( "Update Network compare failed" )
+
+ def CASE4( self,main ):
+
+ """
+ Test Delete Network
+ """
+ import os,sys
+ sys.path.append("..")
+ try:
+ from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
+ except ImportError:
+ main.log.exception( "Something wrong with import file or code error." )
+ main.log.info( "Import Error,please check!" )
+
+ main.log.info( "ONOS Network Delete test Start" )
+ main.case( "Virtual Network NBI Test - Network" )
+ main.caseExplanation = "Test Network Delete NBI " +\
+ "Verify Stored Data is NULL after Delete"
+
+ ctrlip = os.getenv( main.params['CTRL']['ip1'] )
+ port = main.params['HTTP']['port']
+ path = main.params['HTTP']['path']
+
+ main.step( "Generate Post Data" )
+ network = NetworkData()
+ network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
+ network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
+ postdata = network.DictoJson()
+
+ main.step( "Post Data via HTTP" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, port , '' , path + 'networks/',
+ 'POST', None , postdata )
+
+ utilities.assert_equals(
+ expect='200',
+ actual=Poststatus,
+ onpass="Post Success",
+ onfail="Post Failed " + str( Poststatus ) + str( result ) )
+
+ main.step( "Delete Data via HTTP" )
+ Deletestatus, result = main.ONOSrest.send( ctrlip,port,network.id,path+'networks/',
+ 'DELETE', None, None )
+ utilities.assert_equals(
+ expect='200',
+ actual=Deletestatus,
+ onpass="Delete Success",
+ onfail="Delete Failed " + str( Getstatus ) + str( result ) )
+
+ main.step( "Get Data is NULL" )
+ Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
+ 'GET', None, None )
+ utilities.assert_equals(
+ expect='The tenantNetwork does not exists',
+ actual=result,
+ onpass="Get Success",
+ onfail="Get Failed " + str( Getstatus ) + str( result ) )
+
+ if result != 'The tenantNetwork does not exists':
+ main.log.error( "Delete Network failed" )
diff --git a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.topo b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.topo
new file mode 100644
index 0000000..fbe743b
--- /dev/null
+++ b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.topo
@@ -0,0 +1,53 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>localhost</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>localhost</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli1>
+
+ <ONOS1>
+ <host>OC1</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOSrest>
+ <host>OC1</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosRestDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSrest>
+
+ <Mininet1>
+ <host>OCN</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS>
+ <controller> none </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/FUNCvirNetNB/__init__.py b/TestON/tests/FUNCvirNetNB/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/FUNCvirNetNB/__init__.py
diff --git a/TestON/tests/FUNCvirNetNB/dependencies/Nbdata.py b/TestON/tests/FUNCvirNetNB/dependencies/Nbdata.py
new file mode 100644
index 0000000..c002c4a
--- /dev/null
+++ b/TestON/tests/FUNCvirNetNB/dependencies/Nbdata.py
@@ -0,0 +1,221 @@
+"""
+This file provide the data
+lanqinglong@huawei.com
+"""
+import json
+
+class NetworkData:
+
+ def __init__(self):
+ self.id = ''
+ self.state = 'ACTIVE'
+ self.name = 'onosfw-1'
+ self.physicalNetwork = 'none'
+ self.admin_state_up = 'true'
+ self.tenant_id = ''
+ self.routerExternal = 'false'
+ self.type ='LOCAL'
+ self.segmentationID = '6'
+ self.shared = 'false'
+
+ def DictoJson(self):
+
+ if self.id =='' or self.tenant_id == '':
+ print 'Id and tenant id is necessary!'
+
+ Dicdata = {}
+ if self.id !='':
+ Dicdata['id'] = self.id
+ if self.state != '':
+ Dicdata['status'] = self.state
+ if self.name !='':
+ Dicdata['name'] = self.name
+ if self.physicalNetwork !='':
+ Dicdata['provider:physical_network'] = self.physicalNetwork
+ if self.admin_state_up !='':
+ Dicdata['admin_state_up'] = self.admin_state_up
+ if self.tenant_id !='':
+ Dicdata['tenant_id'] = self.tenant_id
+ if self.routerExternal !='':
+ Dicdata['router:external'] = self.routerExternal
+ if self.type !='':
+ Dicdata['provider:network_type'] = self.type
+ if self.segmentationID !='':
+ Dicdata['provider:segmentation_id'] = self.segmentationID
+ if self.shared !='':
+ Dicdata['shared'] = self.shared
+
+ Dicdata = {'network': Dicdata}
+
+ return json.dumps(Dicdata,indent=4)
+
+ def Ordered(self,obj):
+
+ if isinstance(obj, dict):
+ return sorted((k,self.Ordered(v)) for k, v in obj.items())
+ if isinstance(obj, list):
+ return sorted(self.Ordered(x) for x in obj )
+ else:
+ return obj
+
+ def JsonCompare(self,SourceData,DestiData,FirstPara,SecondPara):
+
+ try:
+ SourceCompareDataDic = json.loads(SourceData)
+ DestiCompareDataDic = json.loads(DestiData)
+ except ValueError:
+ print "SourceData or DestData is not JSON Type!"
+ return False
+
+ Socom = SourceCompareDataDic[FirstPara][SecondPara]
+ Decom = DestiCompareDataDic[FirstPara][SecondPara]
+ if Socom == Decom:
+ return True
+ else:
+ print "Source Compare data:"+FirstPara+"."+SecondPara+"="+Socom
+ print "Dest Compare data: "+FirstPara+"."+SecondPara+"="+str(Decom)
+ return False
+
+class SubnetData(NetworkData):
+
+ def __init__(self):
+ self.id = ''
+ self.tenant_id = ''
+ self.network_id = ''
+ self.nexthop = '192.168.1.1'
+ self.destination = '192.168.1.1/24'
+ self.start = '192.168.2.2'
+ self.end = '192.168.2.254'
+ self.ipv6_address_mode = 'DHCPV6_STATELESS'
+ self.ipv6_ra_mode = 'DHCPV6_STATELESS'
+ self.cidr = '192.168.1.1/24'
+ self.enable_dhcp = 'true'
+ self.dns_nameservers = 'aaa'
+ self.gateway_ip = '192.168.2.1'
+ self.ip_version = 'INET'
+ self.shared = 'false'
+ self.name = 'demo-subnet'
+
+ def DictoJson(self):
+ if self.id =='' or self.tenant_id == '':
+ print 'Id and tenant id is necessary!'
+
+ Dicdata = {}
+ host_routesdata = []
+ host_routesdata.append({'nexthop': self.nexthop,'destination': self.destination})
+ allocation_pools = []
+ allocation_pools.append({'start': self.start,'end':self.end})
+
+ if self.id != '':
+ Dicdata['id'] = self.id
+ if self.network_id != '':
+ Dicdata['network_id'] = self.network_id
+ if self.name != '':
+ Dicdata['name'] = self.name
+ if self.nexthop != '':
+ Dicdata['host_routes'] = host_routesdata
+ if self.tenant_id != '':
+ Dicdata['tenant_id'] = self.tenant_id
+ if self.start != '':
+ Dicdata['allocation_pools'] = allocation_pools
+ if self.shared != '':
+ Dicdata['shared'] = self.shared
+ if self.ipv6_address_mode != '':
+ Dicdata['ipv6_address_mode'] = self.ipv6_address_mode
+ if self.ipv6_ra_mode != '':
+ Dicdata['ipv6_ra_mode'] = self.ipv6_ra_mode
+ if self.cidr != '':
+ Dicdata['cidr'] = self.cidr
+ if self.enable_dhcp != '':
+ Dicdata['enable_dhcp'] = self.enable_dhcp
+ if self.dns_nameservers != '':
+ Dicdata['dns_nameservers'] = self.dns_nameservers
+ if self.gateway_ip != '':
+ Dicdata['gateway_ip'] = self.gateway_ip
+ if self.ip_version != '':
+ Dicdata['ip_version'] = self.ip_version
+
+ Dicdata = {'subnet': Dicdata}
+
+ return json.dumps(Dicdata,indent=4)
+
+ def Ordered(self,obj):
+ super(NetworkData,self).Ordered(obj)
+
+ def JsonCompare(self,SourceData,DestiData,FirstPara,SecondPara):
+ super(NetworkData,self).JsonCompare(SourceData,DestiData,FirstPara,SecondPara)
+
+class VirtualPortData(NetworkData):
+
+ def __init__(self):
+ self.id = ''
+ self.state = 'ACTIVE'
+ self.bindingHostId = 'fa:16:3e:76:8e:88'
+ self.allowedAddressPairs = [{'macAddress':'fa:16:3e:76:8e:88','ipAddress':'192.168.1.1'}]
+ self.deviceOwner = 'none'
+ self.fixedIp = []
+ self.securityGroups = [{'securityGroup':'asd'}]
+ self.adminStateUp = 'true'
+ self.networkId = ''
+ self.tenantId = ''
+ self.subnetId = ''
+ self.bindingvifDetails = 'port_filter'
+ self.bindingvnicType = 'normal'
+ self.bindingvifType = 'ovs'
+ self.macAddress = 'fa:16:3e:76:8e:88'
+ self.deviceId = 'a08aa'
+ self.name = 'u'
+
+ def DictoJson(self):
+ if self.id == '' or self.tenant_id == ' ' or self.networkId == '':
+ print 'Id/tenant id/networkid/subnetId is necessary!'
+
+ Dicdata = {}
+ fixedIp =[]
+ fixedIp.append({'subnetId':self.subnetId,'ipAddress':'192.168.1.4'})
+ allocation_pools = []
+
+ if self.id != '':
+ Dicdata['id'] = self.id
+ if self.state != '':
+ Dicdata['state'] = self.state
+ if self.bindingHostId != '':
+ Dicdata['bindingHostId'] = self.bindingHostId
+ if self.allowedAddressPairs != '':
+ Dicdata['allowedAddressPairs'] = self.allowedAddressPairs
+ if self.deviceOwner != '':
+ Dicdata['deviceOwner'] = self.deviceOwner
+ if self.fixedIp != []:
+ Dicdata['fixedIp'] = fixedIp
+ if self.securityGroups != '':
+ Dicdata['securityGroups'] = self.securityGroups
+ if self.adminStateUp != '':
+ Dicdata['adminStateUp'] = self.adminStateUp
+ if self.networkId != '':
+ Dicdata['networkId'] = self.networkId
+ if self.tenantId != '':
+ Dicdata['tenantId'] = self.tenantId
+ if self.subnetId != '':
+ Dicdata['subnetId'] = self.subnetId
+ if self.bindingvifDetails != '':
+ Dicdata['bindingvifDetails'] = self.bindingvifDetails
+ if self.bindingvnicType != '':
+ Dicdata['bindingvnicType'] = self.bindingvnicType
+ if self.bindingvifType != '':
+ Dicdata['bindingvifType'] = self.bindingvifType
+ if self.macAddress != '':
+ Dicdata['macAddress'] = self.macAddress
+ if self.deviceId != '':
+ Dicdata['deviceId'] = self.deviceId
+ if self.name != '':
+ Dicdata['name'] = self.name
+
+ Dicdata = {'virtualport': Dicdata}
+
+ return json.dumps(Dicdata,indent=4)
+
+ def Ordered(self,obj):
+ super(NetworkData,self).Ordered(obj)
+
+ def JsonCompare(self,SourceData,DestiData,FirstPara,SecondPara):
+ super(NetworkData,self).JsonCompare(SourceData,DestiData,FirstPara,SecondPara)
\ No newline at end of file
diff --git a/TestON/tests/FUNCvirNetNB/dependencies/__init__.py b/TestON/tests/FUNCvirNetNB/dependencies/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/FUNCvirNetNB/dependencies/__init__.py