--- /dev/null
+"""Custom topology example
+
+Three directly connected switches plus a host for each switch:
+
+ host --- switch --- switch --- switch --- host
+
+Adding the 'topos' dict with a key/value pair to generate our newly defined
+topology enables one to pass in '--topo=mytopo' from the command line.
+"""
+
+from mininet.topo import Topo
+
+
+class PathpolicyTopo(Topo):
+ """Simple topology example."""
+
+ def __init__(self):
+
+ # Initialize topology
+ Topo.__init__(self)
+
+ # Add hosts and switches
+ leftHost = self.addHost('h1')
+ rightHost = self.addHost('h2')
+ leftSwitch = self.addSwitch('s1')
+ middleSwitch = self.addSwitch('s2')
+ middleSwitch2 = self.addSwitch('s4')
+ rightSwitch = self.addSwitch('s3')
+
+ # Add links
+ self.addLink(leftHost, leftSwitch)
+ self.addLink(leftSwitch, middleSwitch)
+ self.addLink(leftSwitch, middleSwitch2)
+ self.addLink(middleSwitch, rightSwitch)
+ self.addLink(middleSwitch2, rightSwitch)
+ self.addLink(rightSwitch, rightHost)
+
+
+topos = {'pathpolicytopo': (lambda: PathpolicyTopo())}
@{FLOWELMENTS} nw_src=10.0.0.1 nw_dst=10.0.0.3 actions=drop
${vlanmap_bridge1} {"vlan": "200"}
${vlanmap_bridge2} {"vlan": "300"}
+${pathpolicy_topo} sudo mn --controller=remote,ip=${CONTROLLER} --custom topo-3sw-2host_multipath.py --topo pathpolicytopo --switch ovsk,protocols=OpenFlow13
+@{PATHMAP_ATTR} "index":"1" "condition":"flowcond_path" "policy":"1"
+${policy_id} 1
+@{PATHPOLICY_ATTR} "id":"1" "type":"OF" "name":"s4-eth2"
+${custom} ${CURDIR}/${CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH}
*** Keywords ***
Start SuiteVtnMa
${resp}= RequestsLibrary.Put session ${REST_CONTEXT_VTNS}/${vtn_name}/vbridges/${vBridge_name}/interfaces/${interface_name}/portmap data=${json_data} headers=${HEADERS}
Should Be Equal As Strings ${resp.status_code} 200
+Add a pathmap
+ [Arguments] ${pathmap_data}
+ [Documentation] Create a pathmap for a vtn
+ ${json_data}= json.dumps ${pathmap_data}
+ ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/pathmaps/${policy_id} data=${pathmap_data} headers=${HEADERS}
+ Should Be Equal As Strings ${resp.status_code} 201
+
+Get a pathmap
+ [Documentation] Get a pathmap for a vtn.
+ ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathmaps
+ : FOR ${pathElement} IN @{PATHMAP_ATTR}
+ \ should Contain ${resp.content} ${pathElement}
+
+Add a pathpolicy
+ [Arguments] ${pathpolicy_data}
+ [Documentation] Create a pathpolicy for a vtn
+ ${json_data}= json.dumps ${pathpolicy_data}
+ ${resp}= RequestsLibrary.Put session ${REST_CONTEXT}/pathpolicies/${policy_id} data=${pathpolicy_data} headers=${HEADERS}
+ Should Be Equal As Strings ${resp.status_code} 201
+
+Get a pathpolicy
+ [Documentation] Get a pathpolicy for a vtn.
+ ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathpolicies/${policy_id}
+ : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
+ \ should Contain ${resp.content} ${pathpolicyElement}
+
+Verify flowEntryBeforePathPolicy
+ [Documentation] Checking Flows on switch S1 and switch S3 before applying path policy
+ write ${DUMPFLOWS}
+ ${result} Read Until mininet>
+ @{list_to_verify} Create List in_port=1 actions=output:2 actions=output:3
+ : FOR ${flowverifyElement} IN @{list_to_verify}
+ \ should Contain ${result} ${flowverifyElement}
+
+Verify flowEntryAfterPathPolicy
+ [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
+ write ${DUMPFLOWS}
+ ${result} Read Until mininet>
+ @{list_to_verify} Create List in_port=1 actions=output:3 in_port=2
+ : FOR ${flowverifyElement} IN @{list_to_verify}
+ \ should Contain ${result} ${flowverifyElement}
+
+Start PathSuiteVtnMaTest
+ [Documentation] Start VTN Manager Test Suite and Mininet
+ Start SuiteVtnMaTest
+ Start Mininet ${MININET} ${pathpolicy_topo} ${custom}
+
+Stop PathSuiteVtnMaTest
+ [Documentation] Cleanup/Shutdown work at the completion of all tests.
+ Delete All Sessions
+ Stop Mininet ${mininet_conn_id}
+
+Delete a pathmap
+ [Documentation] Delete a pathmap for a vtn
+ ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/pathmaps/1
+ Should Be Equal As Strings ${resp.status_code} 200
+
+Get a pathmap after delete
+ [Documentation] Get a pathmap for a vtn.
+ ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathmaps
+ : FOR ${pathElement} IN @{PATHMAP_ATTR}
+ \ should Not Contain ${resp.content} ${pathElement}
+
+Delete a pathpolicy
+ [Documentation] Delete a pathpolicy for a vtn
+ ${resp}= RequestsLibrary.Delete session ${REST_CONTEXT}/pathpolicies/1
+ Should Be Equal As Strings ${resp.status_code} 200
+
+Get a pathpolicy after delete
+ [Documentation] Get a pathpolicy for a vtn after delete.
+ ${resp}= RequestsLibrary.Get session ${REST_CONTEXT}/pathpolicies/${policy_id}
+ : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
+ \ should Not Contain ${resp.content} ${pathpolicyElement}
+
Add a macmap
[Arguments] ${vtn_name} ${vBridge_name} ${macmap_data}
[Documentation] Create a macmap for a vbridge
--- /dev/null
+*** Settings ***
+Documentation Test suite for VTN Manager using OF13
+Suite Setup Start PathSuiteVtnMaTest
+Suite Teardown Stop PathSuiteVtnMaTest
+Resource ../../../libraries/VtnMaKeywords.robot
+
+*** Variables ***
+${pathmapdata} {"index": 1,"condition":"flowcond_path","policy":1,"idleTimeout": 300,"hardTimeout": 0}
+${pathpolicydata} {"id": 1,"default": 100000,"cost": [{"location": {"node": {"type": "OF","id": "00:00:00:00:00:00:00:01"},"port": {"type": "OF","id": "3","name": "s1-eth3"}},"cost": 1000},{"location": {"node": {"type": "OF","id": "00:00:00:00:00:00:00:04"},"port": {"type": "OF","id": "2","name": "s4-eth2"}},"cost": 1000},{"location": {"node": {"type": "OF", "id": "00:00:00:00:00:00:00:03"},"port": {"type": "OF","id": "3","name": "s3-eth3"}},"cost": 100000}]}
+
+*** Test Cases ***
+Check if switch1 detected
+ [Documentation] Check if openflow:1 is detected
+ BuiltIn.Wait_Until_Keyword_Succeeds 12 3 Fetch vtn switch inventory openflow:1
+
+Check if switch2 detected
+ [Documentation] Check if openflow:2 is detected
+ BuiltIn.Wait_Until_Keyword_Succeeds 3 1 Fetch vtn switch inventory openflow:2
+
+Check if switch3 detected
+ [Documentation] Check if openflow:3 is detected
+ BuiltIn.Wait_Until_Keyword_Succeeds 3 1 Fetch vtn switch inventory openflow:3
+
+Check if switch4 detected
+ [Documentation] Check if openflow:4 is detected
+ BuiltIn.Wait_Until_Keyword_Succeeds 3 1 Fetch vtn switch inventory openflow:4
+
+Add a vtn Tenant_path
+ [Documentation] Add a vtn Tenant_path
+ Add a vtn Tenant_path {"idleTimeout": "200","hardTimeout": "600","description": "Virtual Tenant_path for Hackfest network"}
+
+Add a vBridge vBridge1
+ [Documentation] Add a vBridge vBridge1 in vtn Tenant_path
+ Add a vBridge Tenant_path vBridge1 {"ageInterval": "300","description": "vBridge1 for Tenant_path"}
+
+Add a interface If1_path
+ [Documentation] Add a interface if1_path into vBrdige vBridge1
+ Add a interface Tenant_path vBridge1 if1_path {}
+
+Add a portmap for interface if1_path
+ [Documentation] Create a portmap on Interface if1 of vBridge1
+ ${node} Create Dictionary type=OF id=00:00:00:00:00:00:00:01
+ ${port} Create Dictionary name=s1-eth1 type=OF id=1
+ ${portmap_data} Create Dictionary node=${node} port=${port}
+ Add a portmap Tenant_path vBridge1 if1_path ${portmap_data}
+
+Add a interface If2_path
+ [Documentation] Add a interface if2_path into vBrdige vBridge1
+ Add a interface Tenant_path vBridge1 if2_path {}
+
+Add a portmap for interface if2_path
+ [Documentation] Create a portmap on Interface if2_path of vBridge1
+ ${node} Create Dictionary type=OF id=00:00:00:00:00:00:00:03
+ ${port} Create Dictionary name=s3-eth3 type=OF id=3
+ ${portmap_data} Create Dictionary node=${node} port=${port}
+ Add a portmap Tenant_path vBridge1 if2_path ${portmap_data}
+
+Ping h1 to h2 before path policy
+ [Documentation] Ping h1 to h2, verify no packet loss
+ Mininet Ping Should Succeed h1 h2
+
+Verify flowEntryBeforePathPolicy
+ [Documentation] Checking Flows on switch s1 and s3
+ [Tags] Switch
+ Verify flowEntryBeforePathPolicy
+
+Add a flowcondition flowcond_path
+ [Documentation] Create a flowcondition flowcond_path
+ ${inet4}= Create Dictionary src=10.0.0.1 dst=10.0.0.2 protocol=1
+ ${inetMatch}= Create Dictionary inet4=${inet4}
+ ${ethernet}= Create Dictionary src=ca:9e:58:0c:1e:f0 dst=ba:bd:0f:e3:a8:c8 type=2048
+ ${matchElement}= Create Dictionary index=1 ethernet=${ethernet} inetMatch=${inetMatch}
+ @{matchlist} Create List ${matchElement}
+ ${flowcond_data}= Create Dictionary name=flowcond_path match=${matchlist}
+ Add a flowcondition flowcond_path ${flowcond_data}
+
+Add a pathmap
+ [Documentation] Create a pathmap in the vtn
+ Add a pathmap ${pathmapdata}
+
+Get a pathmap
+ [Documentation] Retrieve a pathmap in the vtn
+ Get a pathmap
+
+Add a pathpolicy
+ [Documentation] Create a pathpolicy in the vtn
+ Add a pathpolicy ${pathpolicydata}
+
+Get a pathpolicy
+ [Documentation] Retrieve a pathpolicy in the vtn
+ Get a pathpolicy
+
+Ping h1 to h2 after path policy
+ [Documentation] Ping h1 to h2, verify no packet loss
+ Mininet Ping Should Succeed h1 h2
+
+Verify flowEntryAfterPathPolicy
+ [Documentation] Checking Flows on switch s1 and s3
+ [Tags] Switch
+ Verify flowEntryAfterPathPolicy
+
+Delete a pathmap
+ [Documentation] Delete a pathmap
+ Delete a pathmap
+
+Get a pathmap after delete
+ [Documentation] Retrieve a pathmap in the vtn after delete to check whether it is deleted properly
+ Get a pathmap after delete
+
+Delete a pathpolicy
+ [Documentation] Delete a pathpolicy
+ Delete a pathpolicy
+
+Get a pathpolicy after delete
+ [Documentation] Retrieve a pathpolicy in the vtn after delete to check whether it is deleted properly
+ Get a pathpolicy after delete
+
+Delete a flowcondition
+ [Documentation] Delete a flowcondition
+ Delete a flowcondition flowcond_path
+
+Delete a vtn Tenant_path
+ [Documentation] Delete a vtn Tenant_path
+ Delete a vtn Tenant_path
+
+
+
+
CREATE_FULLYMESH_TOPOLOGY_FILE_PATH = "libraries/MininetTopo/" +\
CREATE_FULLYMESH_TOPOLOGY_FILE
+# Mininet Custom Topology Path and File for Path Policy
+CREATE_PATHPOLICY_TOPOLOGY_FILE = "topo-3sw-2host_multipath.py"
+CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH = "MininetTopo/" +\
+ CREATE_PATHPOLICY_TOPOLOGY_FILE
+
GBP_REGEP_API = "/restconf/operations/endpoint:register-endpoint"
GBP_UNREGEP_API = "/restconf/operations/endpoint:unregister-endpoint"
GBP_TENANTS_API = "/restconf/config/policy:tenants"