2 Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances
5 Resource CompareStream.robot
7 Resource TemplatedRequests.robot
8 Resource KarafKeywords.robot
9 Resource ../variables/Variables.robot
10 Resource ../variables/netvirt/Variables.robot
13 Library OperatingSystem
23 ... portname1=BR1-eth1
24 ... ipaddress1=2.2.2.2
26 ... portname2= BR2-eth1
27 ... ipaddress2=3.3.3.3
28 &{L3VPN_CREATE_DEFAULT}
29 ... vpnid=4ae8cd92-48ca-49b5-94e1-b2921a261111
32 ... exportrt=["2200:1","8800:1"]
33 ... importrt=["2200:1","8800:1"]
34 ... tenantid=6c53df3a-3456-11e5-a151-feff819cdc9f
35 ${VAR_BASE} ${CURDIR}/../variables/vpnservice/
36 ${ODL_FLOWTABLE_L3VPN} 21
39 ${STATE_UNKNOWN} UNKNOWN
40 ${STATE_ENABLE} ENABLED
41 ${STATE_DISABLE} DISABLE
47 OpenStackOperations.OpenStack Suite Setup
48 TemplatedRequests.Create Default Session timeout=${SESSION_TIMEOUT}
50 Basic Vpnservice Suite Cleanup
51 [Arguments] ${vpn_instance_ids}=@{EMPTY} ${vms}=@{EMPTY} ${networks}=@{EMPTY} ${subnets}=@{EMPTY} ${ports}=@{EMPTY} ${sgs}=@{EMPTY}
52 FOR ${vpn_instance_id} IN @{vpn_instance_ids}
53 BuiltIn.Run Keyword And Ignore Error VPN Delete L3VPN vpnid=${vpn_instance_id}
55 OpenStackOperations.Neutron Cleanup ${vms} ${networks} ${subnets} ${ports} ${sgs}
58 [Documentation] Create an L3VPN using the Json using the list of optional arguments received.
60 IF "routerid" in ${Kwargs}
61 Collections.Set_To_Dictionary ${Kwargs} router=, "router-id":"${Kwargs['routerid']}"
63 Collections.Set_To_Dictionary ${Kwargs} router=${empty}
65 &{L3vpn_create_actual_val} = Collections.Copy_Dictionary ${L3VPN_CREATE_DEFAULT}
66 Collections.Set_To_Dictionary ${L3vpn_create_actual_val} &{Kwargs}
67 TemplatedRequests.Post_As_Json_Templated
68 ... folder=${VAR_BASE}/l3vpn_create
69 ... mapping=${L3vpn_create_actual_val}
71 ... http_timeout=${SESSION_TIMEOUT}
74 [Documentation] Will return detailed list of the L3VPN_ID received
76 ${resp} = TemplatedRequests.Post_As_Json_Templated
77 ... folder=${VAR_BASE}/get_l3vpn
80 ... http_timeout=${SESSION_TIMEOUT}
85 [Documentation] Check that sub interface ip has been learnt after ARP request
87 ${resp} = RequestsLibrary.Get Request session ${VPN_REST}
88 BuiltIn.Log ${resp.text}
89 @{list_any_matches} = String.Get_Regexp_Matches
91 ... \"vpn-instance-name\":\"${VPN_INSTANCE_ID}\",.*"vrf-id":"${vrf_id}",\"vpn-id\":(\\d+)
93 ${result} = Evaluate ${list_any_matches[0]} * 2
94 ${vpn_id_hex} = BuiltIn.Convert To Hex ${result}
95 RETURN ${vpn_id_hex.lower()}
98 [Documentation] To verify L3VPN on ODL for given vpn ids
100 FOR ${vpn} IN @{vpns}
101 ${resp} = VpnOperations.VPN Get L3VPN vpnid=${vpn}
102 BuiltIn.Should Contain ${resp} ${vpn}
105 Associate L3VPN To Network
106 [Documentation] Associate the created L3VPN to a network-id received as dictionary argument
107 [Arguments] &{Kwargs}
108 TemplatedRequests.Post_As_Json_Templated
109 ... folder=${VAR_BASE}/assoc_l3vpn
110 ... mapping=${Kwargs}
112 ... http_timeout=${SESSION_TIMEOUT}
114 Associate L3VPNs To Networks
115 [Documentation] Associates multiple networks to L3VPN and verify the same
116 [Arguments] ${vpnid_list} ${network_list}
117 FOR ${network} ${vpnid} IN ZIP ${network_list} ${vpnid_list}
118 ${network_id} = OpenStackOperations.Get Net Id ${network}
119 VpnOperations.Associate L3VPN To Network networkid=${network_id} vpnid=${vpnid}
120 ${resp} = VpnOperations.VPN Get L3VPN vpnid=${vpnid}
121 BuiltIn.Should Contain ${resp} ${network_id}
124 Dissociate L3VPN From Networks
125 [Documentation] Disssociate the already associated networks from L3VPN
126 [Arguments] &{Kwargs}
127 TemplatedRequests.Post_As_Json_Templated
128 ... folder=${VAR_BASE}/dissoc_l3vpn
129 ... mapping=${Kwargs}
131 ... http_timeout=${SESSION_TIMEOUT}
133 Associate VPN to Router
134 [Documentation] Associate the created L3VPN to a router-id received as argument
135 [Arguments] &{Kwargs}
136 CompareStream.Run_Keyword_If_At_Least_Fluorine
137 ... TemplatedRequests.Post_As_Json_Templated
138 ... folder=${VAR_BASE}/assoc_two_router_l3vpn
139 ... mapping=${Kwargs}
141 ... http_timeout=${SESSION_TIMEOUT}
142 CompareStream.Run_Keyword_If_At_Most_Oxygen
143 ... TemplatedRequests.Post_As_Json_Templated
144 ... folder=${VAR_BASE}/assoc_router_l3vpn
145 ... mapping=${Kwargs}
147 ... http_timeout=${SESSION_TIMEOUT}
149 Dissociate VPN to Router
150 [Documentation] Dissociate the already associated routers from L3VPN
151 [Arguments] &{Kwargs}
152 CompareStream.Run_Keyword_If_At_Least_Fluorine
153 ... TemplatedRequests.Post_As_Json_Templated
154 ... folder=${VAR_BASE}/dissoc_two_router_l3vpn
155 ... mapping=${Kwargs}
157 ... http_timeout=${SESSION_TIMEOUT}
158 CompareStream.Run_Keyword_If_At_Most_Oxygen
159 ... TemplatedRequests.Post_As_Json_Templated
160 ... folder=${VAR_BASE}/dissoc_router_l3vpn
161 ... mapping=${Kwargs}
163 ... http_timeout=${SESSION_TIMEOUT}
166 [Documentation] Delete the created L3VPN
167 [Arguments] &{Kwargs}
168 TemplatedRequests.Post_As_Json_Templated
169 ... folder=${VAR_BASE}/l3vpn_delete
170 ... mapping=${Kwargs}
172 ... http_timeout=${SESSION_TIMEOUT}
175 [Documentation] Creates Tunnel between the two DPNs received in the dictionary argument
176 [Arguments] &{Kwargs}
177 &{Itm_actual_val} = Collections.Copy_Dictionary ${ITM_CREATE_DEFAULT}
178 Collections.Set_To_Dictionary ${Itm_actual_val} &{Kwargs}
179 TemplatedRequests.Post_As_Json_Templated
180 ... folder=${VAR_BASE}/itm_create
181 ... mapping=${Itm_actual_val}
183 ... http_timeout=${SESSION_TIMEOUT}
186 [Documentation] Get all Tunnels and return the contents
187 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/itm:transport-zones/
189 Should Be Equal As Strings ${resp.status_code} 200
193 [Documentation] Delete Tunnels created under the transport-zone
194 [Arguments] ${zone-name}
195 ${resp} = RequestsLibrary.Delete Request
197 ... ${CONFIG_API}/itm:transport-zones/transport-zone/${zone-name}/
199 Should Be Equal As Strings ${resp.status_code} 200
202 Verify Flows Are Present For L3VPN
203 [Documentation] Verify Flows Are Present For L3VPN
204 [Arguments] ${ip} ${vm_ips}
205 ${flow_output} = Run Command On Remote System And Log
207 ... sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
208 Should Contain ${flow_output} table=${ODL_FLOWTABLE_L3VPN}
209 ${l3vpn_table} = Get Lines Containing String ${flow_output} table=${ODL_FLOWTABLE_L3VPN},
211 FOR ${i} IN @{vm_ips}
212 ${resp} = Should Contain ${l3vpn_table} ${i}
215 Verify Flows Are Present For L3VPN On All Compute Nodes
216 [Documentation] Verify Flows Are Present For L3VPN On All Compute Nodes
217 [Arguments] ${vm_ips}
218 FOR ${ip} IN @{OS_CMP_IPS}
219 BuiltIn.Wait Until Keyword Succeeds
222 ... VpnOperations.Verify Flows Are Present For L3VPN
227 Verify GWMAC Entry On ODL
228 [Documentation] get ODL GWMAC table entry
229 [Arguments] ${GWMAC_ADDRS}
230 ${resp} = RequestsLibrary.Get Request session ${VPN_PORT_DATA_URL}
232 Should Be Equal As Strings ${resp.status_code} 200
233 FOR ${macAdd} IN @{GWMAC_ADDRS}
234 Should Contain ${resp.text} ${macAdd}
237 Verify GWMAC Flow Entry Removed From Flow Table
238 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
240 ${flow_output} = Run Command On Remote System And Log
242 ... sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
243 Should Contain ${flow_output} table=${GWMAC_TABLE}
244 ${gwmac_table} = Get Lines Containing String ${flow_output} table=${GWMAC_TABLE}
246 #Verify GWMAC address present in table 19
247 FOR ${macAdd} IN @{GWMAC_ADDRS}
248 Should Not Contain ${gwmac_table} dl_dst=${macAdd} actions=goto_table:${L3_TABLE}
251 Verify GWMAC Flow Entry Removed From Flow Table On All Compute Nodes
252 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
253 FOR ${ip} IN @{OS_CMP_IPS}
254 BuiltIn.Wait Until Keyword Succeeds 30s 10s Verify GWMAC Flow Entry Removed From Flow Table ${ip}
257 Verify ARP REQUEST in groupTable
258 [Documentation] get flow dump for group ID
259 [Arguments] ${group_output} ${Group-ID}
260 Should Contain ${group_output} group_id=${Group-ID}
261 ${arp_group} = Get Lines Containing String ${group_output} group_id=${Group-ID}
263 CompareStream.Run_Keyword_If_At_Most_Oxygen
264 ... BuiltIn.Should Match Regexp
266 ... ${ARP_REQUEST_GROUP_REGEX}
267 CompareStream.Run_Keyword_If_At_Least_Fluorine
268 ... BuiltIn.Should Match Regexp
270 ... ${ARP_REQUEST_GROUP_REGEX_FLUORINE}
272 Verify Tunnel Status as UP
273 [Documentation] Verify that the tunnels are UP
274 IF ${OS_NODE_CNT} == ${1} RETURN ${True}
275 ${output} = Issue Command On Karaf Console ${TEP_SHOW_STATE}
277 Should Contain ${output} ${STATE_UP}
278 Should Not Contain ${output} ${STATE_DOWN}
279 Should Not Contain ${output} ${STATE_UNKNOWN}
281 Verify Tunnel Status as DOWN
282 [Documentation] Verify that the tunnels are DOWN
283 ${output} = Issue Command On Karaf Console ${TEP_SHOW_STATE}
285 Should Contain ${output} ${STATE_DOWN}
286 Should Not Contain ${output} ${STATE_UP}
287 Should Not Contain ${output} ${STATE_UNKNOWN}
289 Verify Tunnel Status as UNKNOWN
290 [Documentation] Verify that the tunnels are in Unknown state
291 ${output} = Issue Command On Karaf Console ${TEP_SHOW_STATE}
293 Should Not Contain ${output} ${STATE_UP}
294 Should Not Contain ${output} ${STATE_DOWN}
295 Should Contain ${output} ${STATE_UNKNOWN}
297 Verify VXLAN interface
298 [Documentation] Verify that the VXLAN interfaces are Enabled
299 ${output} = Issue Command On Karaf Console ${VXLAN_SHOW}
301 Should Contain ${output} ${STATE_UP}
302 Should Contain ${output} ${STATE_ENABLE}
303 Should Not Contain ${output} ${STATE_DISABLE}
306 [Documentation] Get Fib table entries from ODL session
307 [Arguments] ${session}
308 ${resp} = RequestsLibrary.Get Request ${session} ${FIB_ENTRIES_URL}
312 Get Gateway MAC And IP Address
313 [Documentation] Get Gateway mac and IP Address
314 [Arguments] ${router_Name} ${ip_regex}=${IP_REGEX}
315 ${output} = OpenStack CLI openstack port list --router ${router_Name}
316 @{MacAddr-list} = Get Regexp Matches ${output} ${MAC_REGEX}
317 @{IpAddr-list} = Get Regexp Matches ${output} ${ip_regex}
318 RETURN ${MacAddr-list} ${IpAddr-list}
320 Test Teardown With Tcpdump Stop
321 [Arguments] ${conn_ids}=@{EMPTY}
322 OpenStackOperations.Stop Packet Capture On Nodes ${conn_ids}
323 Get Test Teardown Debugs
325 Verify IPv4 GWMAC Flow Entry On Flow Table
326 [Arguments] ${group_output} ${group_id} ${flow_output}
327 Verify ARP REQUEST in groupTable ${group_output} ${groupID[1]}
328 #Verify ARP_RESPONSE_TABLE - 81
329 Should Contain ${flow_output} table=${ARP_RESPONSE_TABLE}
330 ${arpResponder_table} = Get Lines Containing String ${flow_output} table=${ARP_RESPONSE_TABLE}
331 Should Contain ${arpResponder_table} priority=0 actions=drop
332 FOR ${macAdd} ${ipAdd} IN ZIP ${GWMAC_ADDRS} ${GWIP_ADDRS}
333 ${ARP_RESPONSE_IP_MAC_REGEX} = Set Variable
334 ... arp_tpa=${ipAdd},arp_op=1 actions=.*,set_field:${macAdd}->eth_src
335 Should Match Regexp ${arpResponder_table} ${ARP_RESPONSE_IP_MAC_REGEX}
338 Verify IPv6 GWMAC Flow Entry On Flow Table
339 [Arguments] ${flow_output}
340 Should Contain ${flow_output} table=${IPV6_TABLE}
341 ${icmp_ipv6_flows} = Get Lines Containing String ${flow_output} icmp_type=135
342 FOR ${ip_addr} IN @{GWIP_ADDRS}
343 ${rule} = Set Variable icmp_type=135,icmp_code=0,nd_target=${ip_addr} actions=CONTROLLER:65535
344 Should Match Regexp ${icmp_ipv6_flows} ${rule}
347 Verify GWMAC Flow Entry On Flow Table
348 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
349 [Arguments] ${cnIp} ${ipv}=ipv4
350 ${flow_output} = Run Command On Remote System
352 ... sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
353 ${group_output} = Run Command On Remote System
355 ... sudo ovs-ofctl -O OpenFlow13 dump-groups ${INTEGRATION_BRIDGE}
356 Should Contain ${flow_output} table=${DISPATCHER_TABLE}
357 ${dispatcher_table} = Get Lines Containing String ${flow_output} table=${DISPATCHER_TABLE}
358 Should Contain ${dispatcher_table} goto_table:${GWMAC_TABLE}
359 Should Not Contain ${dispatcher_table} goto_table:${ARP_RESPONSE_TABLE}
360 Should Contain ${flow_output} table=${GWMAC_TABLE}
361 ${gwmac_table} = Get Lines Containing String ${flow_output} table=${GWMAC_TABLE}
362 #Verify GWMAC address present in table 19
363 FOR ${macAdd} IN @{GWMAC_ADDRS}
364 Should Contain ${gwmac_table} dl_dst=${macAdd} actions=goto_table:${L3_TABLE}
367 Should Contain ${gwmac_table} actions=resubmit(,17)
368 #Verify ARP_CHECK_TABLE - 43
369 #arp request and response
370 ${arpchk_table} = Get Lines Containing String ${flow_output} table=${ARP_CHECK_TABLE}
371 CompareStream.Run_Keyword_If_At_Most_Oxygen
372 ... BuiltIn.Should Match Regexp
374 ... ${ARP_RESPONSE_REGEX}
375 CompareStream.Run_Keyword_If_At_Least_Fluorine
376 ... BuiltIn.Should Match Regexp
378 ... ${ARP_RESPONSE_REGEX_FLUORINE}
379 ${arppunt_table} = String.Get Lines Containing String ${flow_output} table=${ARP_PUNT_TABLE}
380 CompareStream.Run_Keyword_If_At_Least_Fluorine
381 ... BuiltIn.Should Match Regexp
383 ... ${ARP_PUNT_RESPONSE_REGEX}
384 ${match} = Should Match Regexp ${arpchk_table} ${ARP_REQUEST_REGEX}
385 ${groupID} = Split String ${match} separator=:
386 IF '${ipv}' == 'ipv4'
387 Verify IPv4 GWMAC Flow Entry On Flow Table ${group_output} ${group_id} ${flow_output}
389 Verify IPv6 GWMAC Flow Entry On Flow Table ${flow_output}
392 Verify GWMAC Flow Entry On Flow Table On All Compute Nodes
393 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
394 [Arguments] ${ipv}=ipv4
395 FOR ${ip} IN @{OS_CMP_IPS}
396 BuiltIn.Wait Until Keyword Succeeds
399 ... VpnOperations.Verify GWMAC Flow Entry On Flow Table
404 Delete Multiple L3VPNs
405 [Documentation] Delete three L3VPNs created using Multiple L3VPN Test
407 FOR ${vpn} IN @{vpns}
408 VPN Delete L3VPN vpnid=${vpn}
412 IF "${OPENSTACK_TOPO}" == "1cmb-0ctl-0cmp" RETURN
413 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
416 IF "${OPENSTACK_TOPO}" == "1cmb-0ctl-0cmp" RETURN
417 OpenStackOperations.Get Test Teardown Debugs