return True
-
-
+def num_of_nodes(depth, fanout):
+ '''returns num of switches of a mininet with tree topology
+ with particular depth and fanout parameters
+ '''
+ result = 0
+ for i in xrange(depth):
+ result += fanout**i
+ return result
-if __name__ == '__main__':
+def num_of_links_for_node(nodeid, leaflist, fanout):
+ '''
+ If the given node is a leaf node, there will be an only one link for it
+ and nodeid will be represented 2 times in topology
+ If the given node is not a leaf node, then there will be fanout+1 links
+ for it and nodeid will be represented (fanout+1)*2 times in topology
+ p.s. root node is excluded.
+ '''
+ if nodeid in leaflist:
+ return 1
+ return (fanout+1)
- pass
+if __name__ == '__main__':
+ print num_of_nodes(3,4)
+ pass
"""
import string
import robot
+import re
from robot.libraries.BuiltIn import BuiltIn
+import Common
class Topologynew(object):
'''
Topology class provide topology database and provide many method to get property of topology.
+
+ node_boilerplate = {u'type': u'MD_SAL', u'id': u'openflow:%d'}
'''
topo_nodes_db=[[],
[{u'type': u'MD_SAL', u'id': u'openflow:1'}],
[{u'type': u'MD_SAL', u'id': u'openflow:1'},{u'type': u'MD_SAL', u'id': u'openflow:2'},{u'type': u'MD_SAL', u'id': u'openflow:3'}]]
+
def __init__(self):
self.builtin = BuiltIn()
return self.topo_nodes_db[topo_level]
else:
return None
+
+ def get_nodes_from_tree_topo(self, topo, exceptroot="0"):
+ '''
+ This function generates a dictionary that contains type and id of each node.
+ It follows tree level topology.
+ @parameter topo: either an interer (in this case, depth is set and fanout will be 2)
+ or a string in format of "(a,b)" (a and b are integers and they
+ stands for depth and fanout respectively)
+ @return array of dicitonary objects that contains info about each node
+ '''
+ depth=0
+ fanout=2
+ if isinstance(topo, str) or isinstance(topo, unicode):
+ t = tuple(int(v) for v in re.findall("[0-9]+", topo))
+ if len(t) == 1:
+ depth = t[0]
+ elif len(t) == 2:
+ depth = t[0]
+ fanout = t[1]
+ else:
+ return None #topology consists of two parameters: depth and fanout
+ elif isinstance(topo, int):
+ depth = topo
+ else:
+ return None #topo parameter is not given in a desired way
+
+ num_nodes = Common.num_of_nodes(depth, fanout)
+ nodelist = []
+ for i in xrange(1, num_nodes+1):
+ temp = { "id": "00:00:00:00:00:00:00:%s" % format(i, '02x'), "type": "OF" }
+ nodelist.append(temp)
+ if int(exceptroot):
+ del nodelist[0]
+ return nodelist
+
+ def get_ids_of_leaf_nodes(self, fanout, depth):
+ '''
+ For a tree structure, it numerates leaf nodes
+ by following depth-first strategy
+ @parameter fanout: fanout of tree
+ @parameter depth: total depth of a tree
+ @return leafnodes: list of ids of leaf nodes
+ '''
+ leafnodes = []
+ self._enumerate_nodes(0, 1, 1, fanout, depth-1, leafnodes)
+ return leafnodes
+
+ def _enumerate_nodes(self, currentdepth, nodeid, currentbranch, fanout, depth, leafnodes):
+ if currentdepth==depth:
+ leafnodes.append("00:00:00:00:00:00:00:%s" % format(nodeid, '02x'))
+ return 1
+ nodes = 1
+ for i in xrange(1, fanout+1):
+ nodes += self._enumerate_nodes(currentdepth+1, nodeid+nodes, i, fanout, depth, leafnodes)
+ return nodes
if __name__ == '__main__':
topologynew = Topologynew()
- print topologynew.get_nodes_from_topology(2)
- print topologynew.get_nodes_from_topology('2')
+ #print topologynew.get_nodes_from_tree_topo(2)
+ #print topologynew.get_nodes_from_tree_topo('2')
+ print topologynew.get_nodes_from_tree_topo('(2,3)')
+ #print topologynew.get_ids_of_leaf_nodes(2,2 )#, depth)
--- /dev/null
+*** Settings ***
+Documentation Test suite for RESTCONF inventory
+Suite Setup Create Session session http://${CONTROLLER}:8080 auth=${AUTH} headers=${HEADERS_XML}
+Suite Teardown Delete All Sessions
+Library Collections
+Library ../../../libraries/RequestsLibrary.py
+Library ../../../libraries/Common.py
+Variables ../../../variables/Variables.py
+
+*** Variables ***
+${REST_CONTEXT} /restconf/operational/opendaylight-inventory:nodes
+
+
+*** Test Cases ***
+Get list of nodes
+ [Documentation] Get the inventory
+ ${resp} Get session ${REST_CONTEXT}
+ Should Be Equal As Strings ${resp.status_code} 200
+ ${TOPO_TREE_DEPTH} Convert To Integer ${TOPO_TREE_DEPTH}
+ ${TOPO_TREE_FANOUT} Convert To Integer ${TOPO_TREE_FANOUT}
+ ${numnodes} Num Of Nodes ${TOPO_TREE_DEPTH} ${TOPO_TREE_FANOUT}
+ :FOR ${IND} IN RANGE 1 ${numnodes+1}
+ \ Should Contain ${resp.content} openflow:${IND}
+
+Get nodeconnector for the root node
+ [Documentation] Get the inventory for the root node
+ ${TOPO_TREE_FANOUT} Convert To Integer ${TOPO_TREE_FANOUT}
+ ${resp} Get session ${REST_CONTEXT}/node/openflow:1
+ Should Be Equal As Strings ${resp.status_code} 200
+ Check conn loop ${TOPO_TREE_FANOUT} 1 ${resp.content}
+
+Get nodeconnector for a node
+ [Documentation] Get the inventory for a node
+ ${TOPO_TREE_DEPTH} Convert To Integer ${TOPO_TREE_DEPTH}
+ ${TOPO_TREE_FANOUT} Convert To Integer ${TOPO_TREE_FANOUT}
+ ${numnodes} Num Of Nodes ${TOPO_TREE_DEPTH} ${TOPO_TREE_FANOUT}
+ :FOR ${IND} IN RANGE 2 ${numnodes+1}
+ \ ${resp} Get session ${REST_CONTEXT}/node/openflow:${IND}
+ \ Should Be Equal As Strings ${resp.status_code} 200
+ \ Check conn loop ${TOPO_TREE_FANOUT+1} ${IND} ${resp.content}
+
+Get Stats for a node
+ [Documentation] Get the stats for a node
+ ${TOPO_TREE_DEPTH} Convert To Integer ${TOPO_TREE_DEPTH}
+ ${TOPO_TREE_FANOUT} Convert To Integer ${TOPO_TREE_FANOUT}
+ ${numnodes} Num Of Nodes ${TOPO_TREE_DEPTH} ${TOPO_TREE_FANOUT}
+ :FOR ${IND} IN RANGE 1 ${numnodes+1}
+ \ ${resp} Get session ${REST_CONTEXT}/node/openflow:${IND}
+ \ Should Be Equal As Strings ${resp.status_code} 200
+ \ Should Contain ${resp.content} opendaylight-port-statistics
+ \ Should Contain ${resp.content} opendaylight-flow-table-statistics
+
+*** Keywords ***
+Check conn loop
+ [Arguments] ${arg} ${outerind} ${content}
+ :FOR ${var} IN RANGE 1 ${arg+1}
+ \ Should Contain ${content} openflow:${outerind}:${var}
--- /dev/null
+*** Settings ***
+Documentation Test suite for Switch Manager
+Suite Setup Create Session ${ODL_CONTROLLER_SESSION} http://${CONTROLLER}:8080 auth=${AUTH} headers=${HEADERS}
+Suite Teardown Delete All Sessions
+Library Collections
+Library RequestsLibrary
+Library ../../../libraries/Common.py
+Library ../../../libraries/SwitchManager.py
+Variables ../../../variables/Variables.py
+Library ../../../libraries/Topologynew.py
+
+*** Variables ***
+${REST_CONTEXT} /controller/nb/v2/switchmanager
+
+*** Test Cases ***
+
+List all nodes
+ [Documentation] List all nodes and their properties in the network.
+ [Tags] list_info
+ Log ${TOPO_TREE_LEVEL}
+ ${topo_nodes} Get Nodes From Tree Topo (${TOPO_TREE_DEPTH},${TOPO_TREE_FANOUT})
+ ${resp} Get ${ODL_CONTROLLER_SESSION} ${REST_CONTEXT}/default/nodes
+ Should Be Equal As Strings ${resp.status_code} 200 Response status code error
+ ${jsondata}= To JSON ${resp.content}
+ ${nodes} Extract All Nodes ${jsondata}
+ List Should Contain Sublist ${nodes} ${topo_nodes}
+
+Check root node connectors
+ [Documentation] List node connectors and verify all connectors are there
+ [Tags] list_info
+ ${resp} Get ${ODL_CONTROLLER_SESSION} ${REST_CONTEXT}/default/node/OF/00:00:00:00:00:00:00:01
+ Should Be Equal As Strings ${resp.status_code} 200 Response status code error
+ ${TOPO_TREE_FANOUT} Convert To Integer ${TOPO_TREE_FANOUT}
+ Check conn loop ${TOPO_TREE_FANOUT} 1 ${resp.content}
+
+Check node i connectors
+ [Documentation] List node connectors and verify all connectors are there
+ [Tags] list_info
+ ${topo_nodes} Get Nodes From Tree Topo (${TOPO_TREE_DEPTH},${TOPO_TREE_FANOUT}) 1
+ :FOR ${ITEM} IN @{topo_nodes}
+ \ ${IND} Get From Dictionary ${ITEM} id
+ \ ${resp} Get ${ODL_CONTROLLER_SESSION} ${REST_CONTEXT}/default/node/OF/${IND}
+ \ Should Be Equal As Strings ${resp.status_code} 200
+ \ Check conn loop ${TOPO_TREE_FANOUT+1} ${IND} ${resp.content}
+
+*** Keywords ***
+Check conn loop
+ [Arguments] ${arg} ${outerind} ${content}
+ :FOR ${var} IN RANGE 0 ${arg+1}
+ \ Should Contain ${content} "id":"${var}"
+
--- /dev/null
+*** Settings ***
+Documentation Test suite for Statistics Manager
+Suite Setup Create Session session http://${CONTROLLER}:8080 auth=${AUTH} headers=${HEADERS}
+Suite Teardown Delete All Sessions
+Library Collections
+Library ../../../libraries/RequestsLibrary.py
+Library ../../../libraries/Common.py
+Library ../../../libraries/Topologynew.py
+Variables ../../../variables/Variables.py
+
+*** Variables ***
+${nodeprefix} openflow:
+${key} portStatistics
+${REST_CONTEXT} /controller/nb/v2/statistics
+
+*** Test Cases ***
+get port stats
+ [Documentation] Show port stats and validate result
+ [Tags] get
+ ${resp} Get session ${REST_CONTEXT}/${CONTAINER}/port
+ Should Be Equal As Strings ${resp.status_code} 200
+ ${topo_nodes} Get Nodes From Tree Topo (${TOPO_TREE_DEPTH},${TOPO_TREE_FANOUT}) 1
+ Should Contain X Times ${resp.content} "00:00:00:00:00:00:00:01" ${TOPO_TREE_FANOUT+2}
+ :FOR ${ITEM} IN @{topo_nodes}
+ \ ${IND} Get From Dictionary ${ITEM} id
+ \ Should Contain X Times ${resp.content} "${IND}" ${TOPO_TREE_FANOUT+3}
+
+get flow stats
+ [Documentation] Show flow stats and validate result
+ [Tags] get
+ ${resp} Get session ${REST_CONTEXT}/${CONTAINER}/flow
+ Should Be Equal As Strings ${resp.status_code} 200
+ ${topo_nodes} Get Nodes From Tree Topo (${TOPO_TREE_DEPTH},${TOPO_TREE_FANOUT})
+ :FOR ${ITEM} IN @{topo_nodes}
+ \ ${IND} Get From Dictionary ${ITEM} id
+ \ Should Contain ${resp.content} "${IND}"
+
+get table stats
+ [Documentation] Show flow stats and validate result
+ [Tags] get
+ ${resp} Get session ${REST_CONTEXT}/${CONTAINER}/table
+ Should Be Equal As Strings ${resp.status_code} 200
+ ${topo_nodes} Get Nodes From Tree Topo (${TOPO_TREE_DEPTH},${TOPO_TREE_FANOUT})
+ :FOR ${ITEM} IN @{topo_nodes}
+ \ ${IND} Get From Dictionary ${ITEM} id
+ \ Should Contain ${resp.content} "${IND}"
+
+
--- /dev/null
+*** Settings ***
+Documentation Test suite for Topology Manager
+Suite Setup Create Session session http://${CONTROLLER}:8080 auth=${AUTH} headers=${HEADERS}
+Suite Teardown Delete All Sessions
+Library Collections
+Library ../../../libraries/RequestsLibrary.py
+Library ../../../libraries/Common.py
+Library ../../../libraries/Topologynew.py
+Variables ../../../variables/Variables.py
+
+*** Variables ***
+${nodeprefix} openflow:
+${REST_CONTEXT} /controller/nb/v2/topology
+
+*** Test Cases ***
+Get Topology
+ [Documentation] Get Topology and validate the result.
+ [Tags] get
+ ${resp} Get session ${REST_CONTEXT}/${CONTAINER}
+ Should Be Equal As Strings ${resp.status_code} 200
+ Log ${resp.content}
+ ${TOPO_TREE_DEPTH} Convert To Integer ${TOPO_TREE_DEPTH}
+ ${TOPO_TREE_FANOUT} Convert To Integer ${TOPO_TREE_FANOUT}
+ Should Contain X Times ${resp.content} "00:00:00:00:00:00:00:01" ${TOPO_TREE_FANOUT*2}
+ ${leaflist} Get Ids Of Leaf Nodes ${TOPO_TREE_FANOUT} ${TOPO_TREE_DEPTH}
+ ${topo_nodes} Get Nodes From Tree Topo (${TOPO_TREE_DEPTH},${TOPO_TREE_FANOUT}) 1
+ :FOR ${ITEM} IN @{topo_nodes}
+ \ ${IND} Get From Dictionary ${ITEM} id
+ \ ${linkcnt} Num Of Links For Node ${IND} ${leaflist} ${TOPO_TREE_FANOUT}
+ \ Should Contain X Times ${resp.content} "${IND}" ${linkcnt*2}
+
+
--- /dev/null
+*** Settings ***
+Documentation Test suite for do pingall test
+Library SSHLibrary
+Library Collections
+Library ../../../libraries/RequestsLibrary.py
+Library ../../../libraries/Common.py
+Variables ../../../variables/Variables.py
+
+*** Variables ***
+
+*** Test Cases ***
+Ping all
+ [Documentation] Do ping all test, verify no packet loss
+ [Tags] pingall
+ ${TOPO_TREE_DEPTH} Convert To Integer ${TOPO_TREE_DEPTH}
+ ${TOPO_TREE_FANOUT} Convert To Integer ${TOPO_TREE_FANOUT}
+ ${numnodes} Num Of Nodes ${TOPO_TREE_DEPTH} ${TOPO_TREE_FANOUT}
+ Write pingall
+ Sleep ${numnodes*3}
+ ${result} Read
+ Should Not Contain ${result} X
+
--- /dev/null
+*** Settings ***
+Documentation Test suite for MD-SAL NSF
+Suite Setup Start Suite
+Suite Teardown Stop Suite
+Library SSHLibrary
+Library ../../../libraries/Common.py
+Variables ../../../variables/Variables.py
+
+*** Variables ***
+
+${start}= sudo mn --controller=remote,ip=${CONTROLLER} --topo tree,${TOPO_TREE_DEPTH},${TOPO_TREE_FANOUT}
+
+** Keywords ***
+Start Suite
+ Log Start mininet
+ ${TOPO_TREE_DEPTH} Convert To Integer ${TOPO_TREE_DEPTH}
+ ${TOPO_TREE_FANOUT} Convert To Integer ${TOPO_TREE_FANOUT}
+ ${numnodes} Num Of Nodes ${TOPO_TREE_DEPTH} ${TOPO_TREE_FANOUT}
+ Open Connection ${MININET} prompt=>
+ Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/id_rsa any
+ Write sudo ovs-vsctl set-manager ptcp:6644
+ Write sudo mn -c
+ Sleep 2
+ Write ${start}
+ Sleep ${numnodes*3+15}
+ Read
+Stop Suite
+ Log Stop mininet
+ Read
+ Write exit
+ Sleep 4
+ Read
+ Close Connection
ACCEPT_XML={'Accept': 'application/xml'}
ODL_CONTROLLER_SESSION=None
TOPO_TREE_LEVEL=2
-
+TOPO_TREE_DEPTH=3
+TOPO_TREE_FANOUT=2
# VTN Coordinator Variables
VTNC = '127.0.0.1'
VTNCPORT = '8083'