7 Library RequestsLibrary
8 Variables ../variables/Variables.py
12 ${vlan_topo_10} sudo mn --controller=remote,ip=${CONTROLLER} --custom vlan_vtn_test.py --topo vlantopo
13 ${vlan_topo_13} sudo mn --controller=remote,ip=${CONTROLLER} --custom vlan_vtn_test.py --topo vlantopo --switch ovsk,protocols=OpenFlow13
14 ${VERSION_VTN} controller/nb/v2/vtn/version
15 ${VTN_INVENTORY} restconf/operational/vtn-inventory:vtn-nodes
16 ${DUMPFLOWS_OF10} dpctl dump-flows -O OpenFlow10
17 ${DUMPFLOWS_OF13} dpctl dump-flows -O OpenFlow13
19 @{FLOWELMENTS} nw_src=10.0.0.1 nw_dst=10.0.0.3 actions=drop
20 @{BRIDGE1_DATAFLOW} "reason":"PORTMAPPED" "virtual-node-path":{"bridge-name":"vBridge1","tenant-name":"Tenant1","interface-name":"if2"}
21 @{BRIDGE2_DATAFLOW} "reason":"PORTMAPPED" "virtual-node-path":{"bridge-name":"vBridge2","tenant-name":"Tenant1","interface-name":"if3"}
22 ${vlanmap_bridge1} 200
23 ${vlanmap_bridge2} 300
24 @{VLANMAP_BRIDGE1_DATAFLOW} "reason":"VLANMAPPED" "virtual-node-path":{"bridge-name":"vBridge1_vlan","tenant-name":"Tenant1","vlan-map-id":"ANY.200"}
25 @{VLANMAP_BRIDGE2_DATAFLOW} "reason":"VLANMAPPED" "virtual-node-path":{"bridge-name":"vBridge2_vlan","tenant-name":"Tenant1","vlan-map-id":"ANY.300"}
27 ${out_before_pathpolicy} output:2
28 ${out_after_pathpolicy} output:3
29 ${flowcond_restconfigdata} {"input":{"operation":"SET","present":"false","name":"cond_1","vtn-flow-match":[{"vtn-ether-match":{"destination-address":"ba:bd:0f:e3:a8:c8","ether-type":"2048","source-address":"ca:9e:58:0c:1e:f0","vlan-id": "1"},"vtn-inet-match":{"source-network":"10.0.0.1/32","protocol":1,"destination-network":"10.0.0.2/32"},"index":"1"}]}}
34 [Documentation] Start VTN Manager Rest Config Api Test Suite
35 Create Session session http://${CONTROLLER}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
36 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
40 [Documentation] Start VTN Manager Test Suite
41 Create Session session http://${CONTROLLER}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
44 [Documentation] Stop VTN Manager Test Suite
49 [Documentation] Stop VTN Manager Test Suite
53 [Documentation] Check if VTN Manager is up.
54 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn:vtns
55 Should Be Equal As Strings ${resp.status_code} 200
57 Fetch vtn switch inventory
58 [Arguments] ${sw_name}
59 [Documentation] Check if Switch is detected.
60 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-inventory:vtn-nodes/vtn-node/${sw_name}
61 Should Be Equal As Strings ${resp.status_code} 200
64 [Arguments] ${vtn_name}
65 [Documentation] Create a vtn with specified parameters.
66 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn:update-vtn data={"input": {"tenant-name":${vtn_name}, "update-mode": "CREATE","operation": "SET", "description": "creating vtn", "idle-timeout":300, "hard-timeout":0}}
67 Should Be Equal As Strings ${resp.status_code} 200
70 [Arguments] ${vtn_name} ${vbr_name}
71 [Documentation] Create a vBridge in a VTN
72 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-vbridge:update-vbridge data={"input": {"update-mode": "CREATE","operation":"SET", "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "description": "vbrdige created"}}
73 Should Be Equal As Strings ${resp.status_code} 200
76 [Arguments] ${vtn_name} ${vbr_name} ${interface_name}
77 [Documentation] Create a interface into a vBridge of a VTN
78 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-vinterface:update-vinterface data={"input": {"update-mode":"CREATE","operation":"SET", "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "description": "vbrdige interfacecreated", "enabled":"true", "interface-name": ${interface_name}}}
79 Should Be Equal As Strings ${resp.status_code} 200
82 [Arguments] ${vtn_name} ${vbr_name} ${interface_name} ${node_id} ${port_id}
83 [Documentation] Create a portmap for a interface of a vbridge
84 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-port-map:set-port-map data={"input": { "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "interface-name": ${interface_name}, "node":"${node_id}", "port-name":"${port_id}"}}
85 Should Be Equal As Strings ${resp.status_code} 200
88 [Arguments] ${vtn_name}
89 [Documentation] Delete a vtn with specified parameters.
90 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn:remove-vtn data={"input": {"tenant-name":${vtn_name}}}
91 Should Be Equal As Strings ${resp.status_code} 200
94 [Arguments] ${vtn_name} ${vbr_name} ${vlan_id}
95 [Documentation] Create a vlanmap
96 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-vlan-map:add-vlan-map data={"input": {"tenant-name":${vtn_name},"bridge-name":${vbr_name},"vlan-id":${vlan_id}}}
97 Should Be Equal As Strings ${resp.status_code} 200
100 [Arguments] ${vtn_name} ${vBridge_name}
101 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
102 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-impl:vtn-flows/vtn-flow-table/${vtn_name}
103 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
104 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
105 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
106 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
109 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
110 [Documentation] Verify whether the required attributes exists.
111 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
112 \ should Contain ${resp.content} ${dataflowElement}
115 [Arguments] ${pathmap_data}
116 [Documentation] Create a pathmap for a vtn
117 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:set-path-map data=${pathmap_data}
118 Should Be Equal As Strings ${resp.status_code} 200
121 [Documentation] Get a pathmap for a vtn.
122 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-map:global-path-maps
123 : FOR ${pathElement} IN @{PATHMAP_ATTR}
124 \ should Contain ${resp.content} ${pathElement}
127 [Arguments] ${pathpolicy_data}
128 [Documentation] Create a pathpolicy for a vtn
129 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:set-path-policy data=${pathpolicy_data}
130 Should Be Equal As Strings ${resp.status_code} 200
133 [Arguments] ${pathpolicy_id}
134 [Documentation] Get a pathpolicy for a vtn.
135 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-policy:vtn-path-policies/vtn-path-policy/${pathpolicy_id}
136 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
137 \ should Contain ${resp.content} ${pathpolicyElement}
140 [Arguments] ${path_id}
141 [Documentation] Delete a pathpolicy for a vtn
142 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:remove-path-policy data={"input": {"id": "${path_id}"}}
143 Should Be Equal As Strings ${resp.status_code} 200
145 Verify flowEntryPathPolicy
146 [Arguments] ${of_version} ${port} ${output}
147 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
148 ${DUMPFLOWS}= Set Variable If "${of_version}"=="OF10" ${DUMPFLOWS_OF10} ${DUMPFLOWS_OF13}
150 ${result} Read Until mininet>
151 Should Contain ${result} in_port=${port} actions=${output}
154 [Arguments] ${vtn_name} ${vBridge_name} ${macmap_data}
155 [Documentation] Create a macmap for a vbridge
156 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-mac-map:set-mac-map data={"input": { "allowed-hosts": ["${macmap_data}"], "tenant-name":${vtn_name}, "bridge-name": ${vBridge_name}}} }
157 Should Be Equal As Strings ${resp.status_code} 200
159 Get DynamicMacAddress
161 [Documentation] Get Dynamic mac address of Host
162 write ${h} ifconfig -a | grep HWaddr
163 ${source} Read Until mininet>
164 ${HWaddress}= Split String ${source} ${SPACE}
165 ${sourceHWaddr}= Get from List ${HWaddress} ${index}
166 ${sourceHWaddress}= Convert To Lowercase ${sourceHWaddr}
167 Return From Keyword ${sourceHWaddress} # Also [Return] would work here.
169 Mininet Ping Should Succeed
170 [Arguments] ${host1} ${host2}
171 [Documentation] Ping hosts to check connectivity
172 Write ${host1} ping -c 1 ${host2}
173 ${result} Read Until mininet>
174 Should Contain ${result} 64 bytes
176 Mininet Ping Should Not Succeed
177 [Arguments] ${host1} ${host2}
178 [Documentation] Ping hosts when there is no connectivity and check hosts is unreachable
179 Write ${host1} ping -c 3 ${host2}
180 ${result} Read Until mininet>
181 Should Not Contain ${result} 64 bytes
185 [Documentation] Create custom topology for vlan functionality
187 ${mininet_conn_id1}= Open Connection ${MININET} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
188 Set Suite Variable ${mininet_conn_id1}
189 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
190 Execute Command sudo ovs-vsctl set-manager ptcp:6644
191 Put File ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
192 Run Keyword If '${OF}' == 'OF13' Write ${vlan_topo_13}
193 ... ELSE IF '${OF}' == 'OF10' Write ${vlan_topo_10}
194 ${result} Read Until mininet>
197 [Arguments] ${vtn_name}
198 [Documentation] Get data flow.
199 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-impl:vtn-flows/vtn-flow-table/${vtn_name}
200 Should Be Equal As Strings ${resp.status_code} 200
203 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
204 [Documentation] Remove a portmap for a interface of a vbridge
205 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-port-map:remove-port-map data={"input": {"tenant-name":${vtn_name},"bridge-name":${vBridge_name},"interface-name":${interface_name}}}
206 Should Be Equal As Strings ${resp.status_code} 200
208 Verify FlowMacAddress
209 [Arguments] ${host1} ${host2} ${OF_VERSION}
210 [Documentation] Verify the source and destination mac address.
211 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
212 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
214 Verify Flows On OpenFlow
215 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
216 [Documentation] Verify the mac addresses on the specified open flow.
217 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
218 Should Be Equal As Strings ${booleanValue} True
220 Verify RemovedFlowMacAddress
221 [Arguments] ${host1} ${host2} ${OF_VERSION}
222 [Documentation] Verify the removed source and destination mac address.
223 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
224 ... ELSE VerifyRemovedFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
226 Verify Removed Flows On OpenFlow
227 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
228 [Documentation] Verify the removed mac addresses on the specified open flow.
229 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
230 Should Not Be Equal As Strings ${booleanValue} True
233 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
234 [Documentation] Verify the source and destination mac address after ping in the dumpflows
235 write ${host1} ifconfig -a | grep HWaddr
236 ${sourcemacaddr} Read Until mininet>
237 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
238 ${sourcemacaddr}= Get from List ${macaddress} ${index}
239 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
240 write ${host2} ifconfig -a | grep HWaddr
241 ${destmacaddr} Read Until mininet>
242 ${macaddress}= Split String ${destmacaddr} ${SPACE}
243 ${destmacaddr}= Get from List ${macaddress} ${index}
244 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
246 ${result} Read Until mininet>
247 Should Contain ${result} ${sourcemacaddress}
248 Should Contain ${result} ${destmacaddress}
251 [Arguments] ${vtn_name} ${vtnflowfilter_data}
252 [Documentation] Create a flowfilter for a vtn
253 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data=${vtnflowfilter_data}
254 Should Be Equal As Strings ${resp.status_code} 200
257 [Arguments] ${vtn_name} ${vBridge_name} ${vbrflowfilter_data}
258 [Documentation] Create a flowfilter for a vbr
259 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data=${vbrflowfilter_data}
260 Should Be Equal As Strings ${resp.status_code} 200
262 Add a vbrif flowfilter
263 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${vbrif_flowfilter_data}
264 [Documentation] Create a flowfilter for a vbrif
265 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data=${vbrif_flowfilter_data}
266 Should Be Equal As Strings ${resp.status_code} 200
268 Verify Flow Entry for Inet Flowfilter
269 [Documentation] Verify switch flow entry using flowfilter for a vtn
270 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
271 Should Not Be Equal As Strings ${booleanValue} True
273 Verify Removed Flow Entry for Inet Drop Flowfilter
274 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
275 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
276 Should Be Equal As Strings ${booleanValue} True
278 Verify Actions on Flow Entry
279 [Documentation] check flow action elements by giving dumpflows in mininet
280 write ${DUMPFLOWS_OF13}
281 ${result} Read Until mininet>
282 : FOR ${flowElement} IN @{FLOWELMENTS}
283 \ should Contain ${result} ${flowElement}
286 [Arguments] ${flowcond_name}
287 [Documentation] Create a flowcondition using Restconfig Api
288 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:set-flow-condition data={"input":{"operation":"SET","present":"false","name":"${flowcond_name}", "vtn-flow-match":[{"vtn-ether-match":{"destination-address":"ba:bd:0f:e3:a8:c8","ether-type":"2048","source-address":"ca:9e:58:0c:1e:f0","vlan-id": "1"},"vtn-inet-match":{"source-network":"10.0.0.1/32","protocol":1,"destination-network":"10.0.0.2/32"},"index":"1"}]}}
289 Should Be Equal As Strings ${resp.status_code} 200
292 [Documentation] Retrieve the list of flowconditions created
293 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions
294 Should Be Equal As Strings ${resp.status_code} 200
297 [Arguments] ${flowcond_name} ${retrieve}
298 [Documentation] Retrieve the flowcondition by name and to check the removed flowcondition added "retrieve" argument to differentiate the status code, since
299 ... after removing flowcondition name the status will be different compare to status code when the flowcondition name is present.
300 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions/vtn-flow-condition/${flowcond_name}
301 Run Keyword If '${retrieve}' == 'retrieve' Should Be Equal As Strings ${resp.status_code} 200
302 ... ELSE Should Not Be Equal As Strings ${resp.status_code} 200
305 [Arguments] ${flowcond_name}
306 [Documentation] Remove the flowcondition by name
307 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:remove-flow-condition {"input": {"name": "${flowcond_name}"}}
308 Should Be Equal As Strings ${resp.status_code} 200