2 Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances
6 Resource TemplatedRequests.robot
7 Resource KarafKeywords.robot
8 Resource ../variables/Variables.robot
9 Resource ../variables/netvirt/Variables.robot
12 Library OperatingSystem
22 ... portname1=BR1-eth1
23 ... ipaddress1=2.2.2.2
25 ... portname2= BR2-eth1
26 ... ipaddress2=3.3.3.3
27 &{L3VPN_CREATE_DEFAULT}
28 ... vpnid=4ae8cd92-48ca-49b5-94e1-b2921a261111
31 ... exportrt=["2200:1","8800:1"]
32 ... importrt=["2200:1","8800:1"]
33 ... tenantid=6c53df3a-3456-11e5-a151-feff819cdc9f
34 ${VAR_BASE} ${CURDIR}/../variables/vpnservice/
35 ${ODL_FLOWTABLE_L3VPN} 21
38 ${STATE_UNKNOWN} UNKNOWN
39 ${STATE_ENABLE} ENABLED
40 ${STATE_DISABLE} DISABLE
46 OpenStackOperations.OpenStack Suite Setup
47 TemplatedRequests.Create Default Session timeout=${SESSION_TIMEOUT}
49 Basic Vpnservice Suite Cleanup
50 [Arguments] ${vpn_instance_ids}=@{EMPTY} ${vms}=@{EMPTY} ${networks}=@{EMPTY} ${subnets}=@{EMPTY} ${ports}=@{EMPTY} ${sgs}=@{EMPTY}
51 FOR ${vpn_instance_id} IN @{vpn_instance_ids}
52 BuiltIn.Run Keyword And Ignore Error VPN Delete L3VPN vpnid=${vpn_instance_id}
54 OpenStackOperations.Neutron Cleanup ${vms} ${networks} ${subnets} ${ports} ${sgs}
57 [Documentation] Create an L3VPN using the Json using the list of optional arguments received.
59 IF "routerid" in ${Kwargs}
60 Collections.Set_To_Dictionary ${Kwargs} router=, "router-id":"${Kwargs['routerid']}"
62 Collections.Set_To_Dictionary ${Kwargs} router=${empty}
64 &{L3vpn_create_actual_val} = Collections.Copy_Dictionary ${L3VPN_CREATE_DEFAULT}
65 Collections.Set_To_Dictionary ${L3vpn_create_actual_val} &{Kwargs}
66 TemplatedRequests.Post_As_Json_Templated
67 ... folder=${VAR_BASE}/l3vpn_create
68 ... mapping=${L3vpn_create_actual_val}
70 ... http_timeout=${SESSION_TIMEOUT}
73 [Documentation] Will return detailed list of the L3VPN_ID received
75 ${resp} = TemplatedRequests.Post_As_Json_Templated
76 ... folder=${VAR_BASE}/get_l3vpn
79 ... http_timeout=${SESSION_TIMEOUT}
84 [Documentation] Check that sub interface ip has been learnt after ARP request
86 ${resp} = RequestsLibrary.Get Request session ${VPN_REST}
87 BuiltIn.Log ${resp.text}
88 @{list_any_matches} = String.Get_Regexp_Matches
90 ... \"vpn-instance-name\":\"${VPN_INSTANCE_ID}\",.*"vrf-id":"${vrf_id}",\"vpn-id\":(\\d+)
92 ${result} = Evaluate ${list_any_matches[0]} * 2
93 ${vpn_id_hex} = BuiltIn.Convert To Hex ${result}
94 RETURN ${vpn_id_hex.lower()}
97 [Documentation] To verify L3VPN on ODL for given vpn ids
100 ${resp} = VpnOperations.VPN Get L3VPN vpnid=${vpn}
101 BuiltIn.Should Contain ${resp} ${vpn}
104 Associate L3VPN To Network
105 [Documentation] Associate the created L3VPN to a network-id received as dictionary argument
106 [Arguments] &{Kwargs}
107 TemplatedRequests.Post_As_Json_Templated
108 ... folder=${VAR_BASE}/assoc_l3vpn
109 ... mapping=${Kwargs}
111 ... http_timeout=${SESSION_TIMEOUT}
113 Associate L3VPNs To Networks
114 [Documentation] Associates multiple networks to L3VPN and verify the same
115 [Arguments] ${vpnid_list} ${network_list}
116 FOR ${network} ${vpnid} IN ZIP ${network_list} ${vpnid_list}
117 ${network_id} = OpenStackOperations.Get Net Id ${network}
118 VpnOperations.Associate L3VPN To Network networkid=${network_id} vpnid=${vpnid}
119 ${resp} = VpnOperations.VPN Get L3VPN vpnid=${vpnid}
120 BuiltIn.Should Contain ${resp} ${network_id}
123 Dissociate L3VPN From Networks
124 [Documentation] Disssociate the already associated networks from L3VPN
125 [Arguments] &{Kwargs}
126 TemplatedRequests.Post_As_Json_Templated
127 ... folder=${VAR_BASE}/dissoc_l3vpn
128 ... mapping=${Kwargs}
130 ... http_timeout=${SESSION_TIMEOUT}
132 Associate VPN to Router
133 [Documentation] Associate the created L3VPN to a router-id received as argument
134 [Arguments] &{Kwargs}
135 TemplatedRequests.Post_As_Json_Templated
136 ... folder=${VAR_BASE}/assoc_two_router_l3vpn
137 ... mapping=${Kwargs}
139 ... http_timeout=${SESSION_TIMEOUT}
141 Dissociate VPN to Router
142 [Documentation] Dissociate the already associated routers from L3VPN
143 [Arguments] &{Kwargs}
144 TemplatedRequests.Post_As_Json_Templated
145 ... folder=${VAR_BASE}/dissoc_two_router_l3vpn
146 ... mapping=${Kwargs}
148 ... http_timeout=${SESSION_TIMEOUT}
151 [Documentation] Delete the created L3VPN
152 [Arguments] &{Kwargs}
153 TemplatedRequests.Post_As_Json_Templated
154 ... folder=${VAR_BASE}/l3vpn_delete
155 ... mapping=${Kwargs}
157 ... http_timeout=${SESSION_TIMEOUT}
160 [Documentation] Creates Tunnel between the two DPNs received in the dictionary argument
161 [Arguments] &{Kwargs}
162 &{Itm_actual_val} = Collections.Copy_Dictionary ${ITM_CREATE_DEFAULT}
163 Collections.Set_To_Dictionary ${Itm_actual_val} &{Kwargs}
164 TemplatedRequests.Post_As_Json_Templated
165 ... folder=${VAR_BASE}/itm_create
166 ... mapping=${Itm_actual_val}
168 ... http_timeout=${SESSION_TIMEOUT}
171 [Documentation] Get all Tunnels and return the contents
172 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/itm:transport-zones/
174 Should Be Equal As Strings ${resp.status_code} 200
178 [Documentation] Delete Tunnels created under the transport-zone
179 [Arguments] ${zone-name}
180 ${resp} = RequestsLibrary.Delete Request
182 ... ${CONFIG_API}/itm:transport-zones/transport-zone/${zone-name}/
184 Should Be Equal As Strings ${resp.status_code} 200
187 Verify Flows Are Present For L3VPN
188 [Documentation] Verify Flows Are Present For L3VPN
189 [Arguments] ${ip} ${vm_ips}
190 ${flow_output} = Run Command On Remote System And Log
192 ... sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
193 Should Contain ${flow_output} table=${ODL_FLOWTABLE_L3VPN}
194 ${l3vpn_table} = Get Lines Containing String ${flow_output} table=${ODL_FLOWTABLE_L3VPN},
196 FOR ${i} IN @{vm_ips}
197 ${resp} = Should Contain ${l3vpn_table} ${i}
200 Verify Flows Are Present For L3VPN On All Compute Nodes
201 [Documentation] Verify Flows Are Present For L3VPN On All Compute Nodes
202 [Arguments] ${vm_ips}
203 FOR ${ip} IN @{OS_CMP_IPS}
204 BuiltIn.Wait Until Keyword Succeeds
207 ... VpnOperations.Verify Flows Are Present For L3VPN
212 Verify GWMAC Entry On ODL
213 [Documentation] get ODL GWMAC table entry
214 [Arguments] ${GWMAC_ADDRS}
215 ${resp} = RequestsLibrary.Get Request session ${VPN_PORT_DATA_URL}
217 Should Be Equal As Strings ${resp.status_code} 200
218 FOR ${macAdd} IN @{GWMAC_ADDRS}
219 Should Contain ${resp.text} ${macAdd}
222 Verify GWMAC Flow Entry Removed From Flow Table
223 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
225 ${flow_output} = Run Command On Remote System And Log
227 ... sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
228 Should Contain ${flow_output} table=${GWMAC_TABLE}
229 ${gwmac_table} = Get Lines Containing String ${flow_output} table=${GWMAC_TABLE}
231 #Verify GWMAC address present in table 19
232 FOR ${macAdd} IN @{GWMAC_ADDRS}
233 Should Not Contain ${gwmac_table} dl_dst=${macAdd} actions=goto_table:${L3_TABLE}
236 Verify GWMAC Flow Entry Removed From Flow Table On All Compute Nodes
237 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
238 FOR ${ip} IN @{OS_CMP_IPS}
239 BuiltIn.Wait Until Keyword Succeeds 30s 10s Verify GWMAC Flow Entry Removed From Flow Table ${ip}
242 Verify ARP REQUEST in groupTable
243 [Documentation] get flow dump for group ID
244 [Arguments] ${group_output} ${Group-ID}
245 Should Contain ${group_output} group_id=${Group-ID}
246 ${arp_group} = Get Lines Containing String ${group_output} group_id=${Group-ID}
248 BuiltIn.Should Match Regexp
250 ... ${ARP_REQUEST_GROUP_REGEX_FLUORINE}
252 Verify Tunnel Status as UP
253 [Documentation] Verify that the tunnels are UP
254 IF ${OS_NODE_CNT} == ${1} RETURN ${True}
255 ${output} = Issue Command On Karaf Console ${TEP_SHOW_STATE}
257 Should Contain ${output} ${STATE_UP}
258 Should Not Contain ${output} ${STATE_DOWN}
259 Should Not Contain ${output} ${STATE_UNKNOWN}
261 Verify Tunnel Status as DOWN
262 [Documentation] Verify that the tunnels are DOWN
263 ${output} = Issue Command On Karaf Console ${TEP_SHOW_STATE}
265 Should Contain ${output} ${STATE_DOWN}
266 Should Not Contain ${output} ${STATE_UP}
267 Should Not Contain ${output} ${STATE_UNKNOWN}
269 Verify Tunnel Status as UNKNOWN
270 [Documentation] Verify that the tunnels are in Unknown state
271 ${output} = Issue Command On Karaf Console ${TEP_SHOW_STATE}
273 Should Not Contain ${output} ${STATE_UP}
274 Should Not Contain ${output} ${STATE_DOWN}
275 Should Contain ${output} ${STATE_UNKNOWN}
277 Verify VXLAN interface
278 [Documentation] Verify that the VXLAN interfaces are Enabled
279 ${output} = Issue Command On Karaf Console ${VXLAN_SHOW}
281 Should Contain ${output} ${STATE_UP}
282 Should Contain ${output} ${STATE_ENABLE}
283 Should Not Contain ${output} ${STATE_DISABLE}
286 [Documentation] Get Fib table entries from ODL session
287 [Arguments] ${session}
288 ${resp} = RequestsLibrary.Get Request ${session} ${FIB_ENTRIES_URL}
292 Get Gateway MAC And IP Address
293 [Documentation] Get Gateway mac and IP Address
294 [Arguments] ${router_Name} ${ip_regex}=${IP_REGEX}
295 ${output} = OpenStack CLI openstack port list --router ${router_Name}
296 @{MacAddr-list} = Get Regexp Matches ${output} ${MAC_REGEX}
297 @{IpAddr-list} = Get Regexp Matches ${output} ${ip_regex}
298 RETURN ${MacAddr-list} ${IpAddr-list}
300 Test Teardown With Tcpdump Stop
301 [Arguments] ${conn_ids}=@{EMPTY}
302 OpenStackOperations.Stop Packet Capture On Nodes ${conn_ids}
303 Get Test Teardown Debugs
305 Verify IPv4 GWMAC Flow Entry On Flow Table
306 [Arguments] ${group_output} ${group_id} ${flow_output}
307 Verify ARP REQUEST in groupTable ${group_output} ${groupID[1]}
308 #Verify ARP_RESPONSE_TABLE - 81
309 Should Contain ${flow_output} table=${ARP_RESPONSE_TABLE}
310 ${arpResponder_table} = Get Lines Containing String ${flow_output} table=${ARP_RESPONSE_TABLE}
311 Should Contain ${arpResponder_table} priority=0 actions=drop
312 FOR ${macAdd} ${ipAdd} IN ZIP ${GWMAC_ADDRS} ${GWIP_ADDRS}
313 ${ARP_RESPONSE_IP_MAC_REGEX} = Set Variable
314 ... arp_tpa=${ipAdd},arp_op=1 actions=.*,set_field:${macAdd}->eth_src
315 Should Match Regexp ${arpResponder_table} ${ARP_RESPONSE_IP_MAC_REGEX}
318 Verify IPv6 GWMAC Flow Entry On Flow Table
319 [Arguments] ${flow_output}
320 Should Contain ${flow_output} table=${IPV6_TABLE}
321 ${icmp_ipv6_flows} = Get Lines Containing String ${flow_output} icmp_type=135
322 FOR ${ip_addr} IN @{GWIP_ADDRS}
323 ${rule} = Set Variable icmp_type=135,icmp_code=0,nd_target=${ip_addr} actions=CONTROLLER:65535
324 Should Match Regexp ${icmp_ipv6_flows} ${rule}
327 Verify GWMAC Flow Entry On Flow Table
328 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
329 [Arguments] ${cnIp} ${ipv}=ipv4
330 ${flow_output} = Run Command On Remote System
332 ... sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
333 ${group_output} = Run Command On Remote System
335 ... sudo ovs-ofctl -O OpenFlow13 dump-groups ${INTEGRATION_BRIDGE}
336 Should Contain ${flow_output} table=${DISPATCHER_TABLE}
337 ${dispatcher_table} = Get Lines Containing String ${flow_output} table=${DISPATCHER_TABLE}
338 Should Contain ${dispatcher_table} goto_table:${GWMAC_TABLE}
339 Should Not Contain ${dispatcher_table} goto_table:${ARP_RESPONSE_TABLE}
340 Should Contain ${flow_output} table=${GWMAC_TABLE}
341 ${gwmac_table} = Get Lines Containing String ${flow_output} table=${GWMAC_TABLE}
342 #Verify GWMAC address present in table 19
343 FOR ${macAdd} IN @{GWMAC_ADDRS}
344 Should Contain ${gwmac_table} dl_dst=${macAdd} actions=goto_table:${L3_TABLE}
347 Should Contain ${gwmac_table} actions=resubmit(,17)
348 #Verify ARP_CHECK_TABLE - 43
349 #arp request and response
350 ${arpchk_table} = Get Lines Containing String ${flow_output} table=${ARP_CHECK_TABLE}
351 BuiltIn.Should Match Regexp
353 ... ${ARP_RESPONSE_REGEX_FLUORINE}
354 ${arppunt_table} = String.Get Lines Containing String ${flow_output} table=${ARP_PUNT_TABLE}
355 BuiltIn.Should Match Regexp
357 ... ${ARP_PUNT_RESPONSE_REGEX}
358 ${match} = Should Match Regexp ${arpchk_table} ${ARP_REQUEST_REGEX}
359 ${groupID} = Split String ${match} separator=:
360 IF '${ipv}' == 'ipv4'
361 Verify IPv4 GWMAC Flow Entry On Flow Table ${group_output} ${group_id} ${flow_output}
363 Verify IPv6 GWMAC Flow Entry On Flow Table ${flow_output}
366 Verify GWMAC Flow Entry On Flow Table On All Compute Nodes
367 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
368 [Arguments] ${ipv}=ipv4
369 FOR ${ip} IN @{OS_CMP_IPS}
370 BuiltIn.Wait Until Keyword Succeeds
373 ... VpnOperations.Verify GWMAC Flow Entry On Flow Table
378 Delete Multiple L3VPNs
379 [Documentation] Delete three L3VPNs created using Multiple L3VPN Test
381 FOR ${vpn} IN @{vpns}
382 VPN Delete L3VPN vpnid=${vpn}
386 IF "${OPENSTACK_TOPO}" == "1cmb-0ctl-0cmp" RETURN
387 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
390 IF "${OPENSTACK_TOPO}" == "1cmb-0ctl-0cmp" RETURN
391 OpenStackOperations.Get Test Teardown Debugs