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"}]}}
33 [Documentation] Start VTN Manager Rest Config Api Test Suite
34 Create Session session http://${CONTROLLER}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
35 BuiltIn.Wait_Until_Keyword_Succeeds 30 3 Fetch vtn list
39 [Documentation] Start VTN Manager Test Suite
40 Create Session session http://${CONTROLLER}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
43 [Documentation] Stop VTN Manager Test Suite
48 [Documentation] Stop VTN Manager Test Suite
52 [Documentation] Check if VTN Manager is up.
53 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn:vtns
54 Should Be Equal As Strings ${resp.status_code} 200
56 Fetch vtn switch inventory
57 [Arguments] ${sw_name}
58 [Documentation] Check if Switch is detected.
59 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-inventory:vtn-nodes/vtn-node/${sw_name}
60 Should Be Equal As Strings ${resp.status_code} 200
63 [Arguments] ${vtn_name}
64 [Documentation] Create a vtn with specified parameters.
65 ${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}}
66 Should Be Equal As Strings ${resp.status_code} 200
69 [Arguments] ${vtn_name} ${vbr_name}
70 [Documentation] Create a vBridge in a VTN
71 ${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"}}
72 Should Be Equal As Strings ${resp.status_code} 200
75 [Arguments] ${vtn_name} ${vbr_name} ${interface_name}
76 [Documentation] Create a interface into a vBridge of a VTN
77 ${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}}}
78 Should Be Equal As Strings ${resp.status_code} 200
81 [Arguments] ${vtn_name} ${vbr_name} ${interface_name} ${node_id} ${port_id}
82 [Documentation] Create a portmap for a interface of a vbridge
83 ${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}"}}
84 Should Be Equal As Strings ${resp.status_code} 200
87 [Arguments] ${vtn_name}
88 [Documentation] Delete a vtn with specified parameters.
89 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn:remove-vtn data={"input": {"tenant-name":${vtn_name}}}
90 Should Be Equal As Strings ${resp.status_code} 200
93 [Arguments] ${vtn_name} ${vbr_name} ${vlan_id}
94 [Documentation] Create a vlanmap
95 ${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}}}
96 Should Be Equal As Strings ${resp.status_code} 200
99 [Arguments] ${vtn_name} ${vBridge_name}
100 [Documentation] Verify the reason and physical data flows for the specified vtn and vbridge
101 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-impl:vtn-flows/vtn-flow-table/${vtn_name}
102 Run Keyword If '${vBridge_name}' == 'vBridge1' DataFlowsForBridge ${resp} @{BRIDGE1_DATAFLOW}
103 ... ELSE IF '${vBridge_name}' == 'vBridge2' DataFlowsForBridge ${resp} @{BRIDGE2_DATAFLOW}
104 ... ELSE IF '${vBridge_name}' == 'vBridge1_vlan' DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE1_DATAFLOW}
105 ... ELSE DataFlowsForBridge ${resp} @{VLANMAP_BRIDGE2_DATAFLOW}
108 [Arguments] ${resp} @{BRIDGE_DATAFLOW}
109 [Documentation] Verify whether the required attributes exists.
110 : FOR ${dataflowElement} IN @{BRIDGE_DATAFLOW}
111 \ should Contain ${resp.content} ${dataflowElement}
114 [Arguments] ${pathmap_data}
115 [Documentation] Create a pathmap for a vtn
116 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-map:set-path-map data=${pathmap_data}
117 Should Be Equal As Strings ${resp.status_code} 200
120 [Documentation] Get a pathmap for a vtn.
121 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-map:global-path-maps
122 : FOR ${pathElement} IN @{PATHMAP_ATTR}
123 \ should Contain ${resp.content} ${pathElement}
126 [Arguments] ${pathpolicy_data}
127 [Documentation] Create a pathpolicy for a vtn
128 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:set-path-policy data=${pathpolicy_data}
129 Should Be Equal As Strings ${resp.status_code} 200
132 [Arguments] ${pathpolicy_id}
133 [Documentation] Get a pathpolicy for a vtn.
134 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-path-policy:vtn-path-policies/vtn-path-policy/${pathpolicy_id}
135 : FOR ${pathpolicyElement} IN @{PATHPOLICY_ATTR}
136 \ should Contain ${resp.content} ${pathpolicyElement}
139 [Arguments] ${path_id}
140 [Documentation] Delete a pathpolicy for a vtn
141 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-path-policy:remove-path-policy data={"input": {"id": "${path_id}"}}
142 Should Be Equal As Strings ${resp.status_code} 200
144 Verify flowEntryPathPolicy
145 [Arguments] ${of_version} ${port} ${output}
146 [Documentation] Checking Flows on switch S1 and switch S3 after applying path policy
147 ${DUMPFLOWS}= Set Variable If "${of_version}"=="OF10" ${DUMPFLOWS_OF10} ${DUMPFLOWS_OF13}
149 ${result} Read Until mininet>
150 Should Contain ${result} in_port=${port} actions=${output}
153 [Arguments] ${vtn_name} ${vBridge_name} ${macmap_data}
154 [Documentation] Create a macmap for a vbridge
155 ${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}}} }
156 Should Be Equal As Strings ${resp.status_code} 200
158 Get DynamicMacAddress
160 [Documentation] Get Dynamic mac address of Host
161 write ${h} ifconfig -a | grep HWaddr
162 ${source} Read Until mininet>
163 ${HWaddress}= Split String ${source} ${SPACE}
164 ${sourceHWaddr}= Get from List ${HWaddress} ${index}
165 ${sourceHWaddress}= Convert To Lowercase ${sourceHWaddr}
166 Return From Keyword ${sourceHWaddress} # Also [Return] would work here.
168 Mininet Ping Should Succeed
169 [Arguments] ${host1} ${host2}
170 [Documentation] Ping hosts to check connectivity
171 Write ${host1} ping -c 1 ${host2}
172 ${result} Read Until mininet>
173 Should Contain ${result} 64 bytes
175 Mininet Ping Should Not Succeed
176 [Arguments] ${host1} ${host2}
177 [Documentation] Ping hosts when there is no connectivity and check hosts is unreachable
178 Write ${host1} ping -c 3 ${host2}
179 ${result} Read Until mininet>
180 Should Not Contain ${result} 64 bytes
184 [Documentation] Create custom topology for vlan functionality
186 ${mininet_conn_id1}= Open Connection ${MININET} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
187 Set Suite Variable ${mininet_conn_id1}
188 Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
189 Execute Command sudo ovs-vsctl set-manager ptcp:6644
190 Put File ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
191 Run Keyword If '${OF}' == 'OF13' Write ${vlan_topo_13}
192 ... ELSE IF '${OF}' == 'OF10' Write ${vlan_topo_10}
193 ${result} Read Until mininet>
196 [Arguments] ${vtn_name}
197 [Documentation] Get data flow.
198 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-impl:vtn-flows/vtn-flow-table/${vtn_name}
199 Should Be Equal As Strings ${resp.status_code} 200
202 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name}
203 [Documentation] Remove a portmap for a interface of a vbridge
204 ${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}}}
205 Should Be Equal As Strings ${resp.status_code} 200
207 Verify FlowMacAddress
208 [Arguments] ${host1} ${host2} ${OF_VERSION}
209 [Documentation] Verify the source and destination mac address.
210 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
211 ... ELSE VerifyFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
213 Verify Flows On OpenFlow
214 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
215 [Documentation] Verify the mac addresses on the specified open flow.
216 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
217 Should Be Equal As Strings ${booleanValue} True
219 Verify RemovedFlowMacAddress
220 [Arguments] ${host1} ${host2} ${OF_VERSION}
221 [Documentation] Verify the removed source and destination mac address.
222 Run Keyword If '${OF_VERSION}' == 'OF10' Verify Removed Flows On OpenFlow ${host1} ${host2} ${DUMPFLOWS_OF10}
223 ... ELSE VerifyRemovedFlowsOnOpenFlow ${host1} ${host2} ${DUMPFLOWS_OF13}
225 Verify Removed Flows On OpenFlow
226 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
227 [Documentation] Verify the removed mac addresses on the specified open flow.
228 ${booleanValue}= Run Keyword And Return Status Verify macaddress ${host1} ${host2} ${DUMPFLOWS}
229 Should Not Be Equal As Strings ${booleanValue} True
232 [Arguments] ${host1} ${host2} ${DUMPFLOWS}
233 [Documentation] Verify the source and destination mac address after ping in the dumpflows
234 write ${host1} ifconfig -a | grep HWaddr
235 ${sourcemacaddr} Read Until mininet>
236 ${macaddress}= Split String ${sourcemacaddr} ${SPACE}
237 ${sourcemacaddr}= Get from List ${macaddress} ${index}
238 ${sourcemacaddress}= Convert To Lowercase ${sourcemacaddr}
239 write ${host2} ifconfig -a | grep HWaddr
240 ${destmacaddr} Read Until mininet>
241 ${macaddress}= Split String ${destmacaddr} ${SPACE}
242 ${destmacaddr}= Get from List ${macaddress} ${index}
243 ${destmacaddress}= Convert To Lowercase ${destmacaddr}
245 ${result} Read Until mininet>
246 Should Contain ${result} ${sourcemacaddress}
247 Should Contain ${result} ${destmacaddress}
250 [Arguments] ${vtn_name} ${vtnflowfilter_data}
251 [Documentation] Create a flowfilter for a vtn
252 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data=${vtnflowfilter_data}
253 Should Be Equal As Strings ${resp.status_code} 200
256 [Arguments] ${vtn_name} ${vBridge_name} ${vbrflowfilter_data}
257 [Documentation] Create a flowfilter for a vbr
258 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data=${vbrflowfilter_data}
259 Should Be Equal As Strings ${resp.status_code} 200
261 Add a vbrif flowfilter
262 [Arguments] ${vtn_name} ${vBridge_name} ${interface_name} ${vbrif_flowfilter_data}
263 [Documentation] Create a flowfilter for a vbrif
264 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-filter:set-flow-filter data=${vbrif_flowfilter_data}
265 Should Be Equal As Strings ${resp.status_code} 200
267 Verify Flow Entry for Inet Flowfilter
268 [Documentation] Verify switch flow entry using flowfilter for a vtn
269 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
270 Should Not Be Equal As Strings ${booleanValue} True
272 Verify Removed Flow Entry for Inet Drop Flowfilter
273 [Documentation] Verify removed switch flow entry using flowfilter drop for a vtn
274 ${booleanValue}= Run Keyword And Return Status Verify Actions on Flow Entry
275 Should Be Equal As Strings ${booleanValue} True
277 Verify Actions on Flow Entry
278 [Documentation] check flow action elements by giving dumpflows in mininet
279 write ${DUMPFLOWS_OF13}
280 ${result} Read Until mininet>
281 : FOR ${flowElement} IN @{FLOWELMENTS}
282 \ should Contain ${result} ${flowElement}
285 [Arguments] ${flowcond_name}
286 [Documentation] Create a flowcondition using Restconfig Api
287 ${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"}]}}
288 Should Be Equal As Strings ${resp.status_code} 200
291 [Documentation] Retrieve the list of flowconditions created
292 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions
293 Should Be Equal As Strings ${resp.status_code} 200
296 [Arguments] ${flowcond_name} ${retrieve}
297 [Documentation] Retrieve the flowcondition by name and to check the removed flowcondition added "retrieve" argument to differentiate the status code, since
298 ... after removing flowcondition name the status will be different compare to status code when the flowcondition name is present.
299 ${resp}= RequestsLibrary.Get Request session restconf/operational/vtn-flow-condition:vtn-flow-conditions/vtn-flow-condition/${flowcond_name}
300 Run Keyword If '${retrieve}' == 'retrieve' Should Be Equal As Strings ${resp.status_code} 200
301 ... ELSE Should Not Be Equal As Strings ${resp.status_code} 200
304 [Arguments] ${flowcond_name}
305 [Documentation] Remove the flowcondition by name
306 ${resp}= RequestsLibrary.Post Request session restconf/operations/vtn-flow-condition:remove-flow-condition {"input": {"name": "${flowcond_name}"}}
307 Should Be Equal As Strings ${resp.status_code} 200