2 Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances
4 Resource CompareStream.robot
6 Resource TemplatedRequests.robot
7 Resource KarafKeywords.robot
8 Resource ../variables/Variables.robot
9 Resource ../variables/netvirt/Variables.robot
12 Library OperatingSystem
15 &{ITM_CREATE_DEFAULT} tunneltype=vxlan vlanid=0 prefix=1.1.1.1/24 gateway=0.0.0.0 dpnid1=1 portname1=BR1-eth1 ipaddress1=2.2.2.2
16 ... dpnid2=2 portname2= BR2-eth1 ipaddress2=3.3.3.3
17 &{L3VPN_CREATE_DEFAULT} vpnid=4ae8cd92-48ca-49b5-94e1-b2921a261111 name=vpn1 rd=["2200:1"] exportrt=["2200:1","8800:1"] importrt=["2200:1","8800:1"] tenantid=6c53df3a-3456-11e5-a151-feff819cdc9f
18 ${VAR_BASE} ${CURDIR}/../variables/vpnservice/
19 ${ODL_FLOWTABLE_L3VPN} 21
22 ${STATE_UNKNOWN} UNKNOWN
23 ${STATE_ENABLE} ENABLED
24 ${STATE_DISABLE} DISABLE
29 OpenStackOperations.OpenStack Suite Setup
30 TemplatedRequests.Create Default Session timeout=${SESSION_TIMEOUT}
32 Basic Vpnservice Suite Cleanup
33 [Arguments] ${vpn_instance_ids}=@{EMPTY} ${vms}=@{EMPTY} ${networks}=@{EMPTY} ${subnets}=@{EMPTY} ${ports}=@{EMPTY} ${sgs}=@{EMPTY}
34 FOR ${vpn_instance_id} IN @{vpn_instance_ids}
35 BuiltIn.Run Keyword And Ignore Error VPN Delete L3VPN vpnid=${vpn_instance_id}
37 OpenStackOperations.Neutron Cleanup ${vms} ${networks} ${subnets} ${ports} ${sgs}
41 [Documentation] Create an L3VPN using the Json using the list of optional arguments received.
42 Run keyword if "routerid" in ${Kwargs} Collections.Set_To_Dictionary ${Kwargs} router=, "router-id":"${Kwargs['routerid']}"
43 ... ELSE Collections.Set_To_Dictionary ${Kwargs} router=${empty}
44 &{L3vpn_create_actual_val} = Collections.Copy_Dictionary ${L3VPN_CREATE_DEFAULT}
45 Collections.Set_To_Dictionary ${L3vpn_create_actual_val} &{Kwargs}
46 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/l3vpn_create mapping=${L3vpn_create_actual_val} session=default http_timeout=${SESSION_TIMEOUT}
50 [Documentation] Will return detailed list of the L3VPN_ID received
51 ${resp} = TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/get_l3vpn mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
57 [Documentation] Check that sub interface ip has been learnt after ARP request
58 ${resp} = RequestsLibrary.Get Request session ${VPN_REST}
59 BuiltIn.Log ${resp.content}
60 @{list_any_matches} = String.Get_Regexp_Matches ${resp.content} \"vpn-instance-name\":\"${VPN_INSTANCE_ID}\",.*"vrf-id":"${vrf_id}",\"vpn-id\":(\\d+) 1
61 ${result} = Evaluate ${list_any_matches[0]} * 2
62 ${vpn_id_hex} = BuiltIn.Convert To Hex ${result}
63 [Return] ${vpn_id_hex.lower()}
67 [Documentation] To verify L3VPN on ODL for given vpn ids
69 ${resp} = VpnOperations.VPN Get L3VPN vpnid=${vpn}
70 BuiltIn.Should Contain ${resp} ${vpn}
73 Associate L3VPN To Network
75 [Documentation] Associate the created L3VPN to a network-id received as dictionary argument
76 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/assoc_l3vpn mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
78 Associate L3VPNs To Networks
79 [Arguments] ${vpnid_list} ${network_list}
80 [Documentation] Associates multiple networks to L3VPN and verify the same
81 FOR ${network} ${vpnid} IN ZIP ${network_list} ${vpnid_list}
82 ${network_id} = OpenStackOperations.Get Net Id ${network}
83 VpnOperations.Associate L3VPN To Network networkid=${network_id} vpnid=${vpnid}
84 ${resp} = VpnOperations.VPN Get L3VPN vpnid=${vpnid}
85 BuiltIn.Should Contain ${resp} ${network_id}
88 Dissociate L3VPN From Networks
90 [Documentation] Disssociate the already associated networks from L3VPN
91 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/dissoc_l3vpn mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
93 Associate VPN to Router
95 [Documentation] Associate the created L3VPN to a router-id received as argument
96 CompareStream.Run_Keyword_If_At_Least_Fluorine TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/assoc_two_router_l3vpn mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
97 CompareStream.Run_Keyword_If_At_Most_Oxygen TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/assoc_router_l3vpn mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
99 Dissociate VPN to Router
100 [Arguments] &{Kwargs}
101 [Documentation] Dissociate the already associated routers from L3VPN
102 CompareStream.Run_Keyword_If_At_Least_Fluorine TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/dissoc_two_router_l3vpn mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
103 CompareStream.Run_Keyword_If_At_Most_Oxygen TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/dissoc_router_l3vpn mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
106 [Arguments] &{Kwargs}
107 [Documentation] Delete the created L3VPN
108 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/l3vpn_delete mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
111 [Arguments] &{Kwargs}
112 [Documentation] Creates Tunnel between the two DPNs received in the dictionary argument
113 &{Itm_actual_val} = Collections.Copy_Dictionary ${ITM_CREATE_DEFAULT}
114 Collections.Set_To_Dictionary ${Itm_actual_val} &{Kwargs}
115 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/itm_create mapping=${Itm_actual_val} session=default http_timeout=${SESSION_TIMEOUT}
118 [Documentation] Get all Tunnels and return the contents
119 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/itm:transport-zones/
121 Should Be Equal As Strings ${resp.status_code} 200
122 [Return] ${resp.content}
125 [Arguments] ${zone-name}
126 [Documentation] Delete Tunnels created under the transport-zone
127 ${resp} = RequestsLibrary.Delete Request session ${CONFIG_API}/itm:transport-zones/transport-zone/${zone-name}/
129 Should Be Equal As Strings ${resp.status_code} 200
130 [Return] ${resp.content}
132 Verify Flows Are Present For L3VPN
133 [Arguments] ${ip} ${vm_ips}
134 [Documentation] Verify Flows Are Present For L3VPN
135 ${flow_output}= Run Command On Remote System And Log ${ip} sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
136 Should Contain ${flow_output} table=${ODL_FLOWTABLE_L3VPN}
137 ${l3vpn_table} = Get Lines Containing String ${flow_output} table=${ODL_FLOWTABLE_L3VPN},
139 FOR ${i} IN @{vm_ips}
140 ${resp}= Should Contain ${l3vpn_table} ${i}
143 Verify Flows Are Present For L3VPN On All Compute Nodes
144 [Arguments] ${vm_ips}
145 [Documentation] Verify Flows Are Present For L3VPN On All Compute Nodes
146 FOR ${ip} IN @{OS_CMP_IPS}
147 BuiltIn.Wait Until Keyword Succeeds 30s 10s VpnOperations.Verify Flows Are Present For L3VPN ${ip} ${vm_ips}
150 Verify GWMAC Entry On ODL
151 [Arguments] ${GWMAC_ADDRS}
152 [Documentation] get ODL GWMAC table entry
153 ${resp} = RequestsLibrary.Get Request session ${VPN_PORT_DATA_URL}
155 Should Be Equal As Strings ${resp.status_code} 200
156 FOR ${macAdd} IN @{GWMAC_ADDRS}
157 Should Contain ${resp.content} ${macAdd}
160 Verify GWMAC Flow Entry Removed From Flow Table
162 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
163 ${flow_output}= Run Command On Remote System And Log ${cnIp} sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
164 Should Contain ${flow_output} table=${GWMAC_TABLE}
165 ${gwmac_table} = Get Lines Containing String ${flow_output} table=${GWMAC_TABLE}
167 #Verify GWMAC address present in table 19
168 FOR ${macAdd} IN @{GWMAC_ADDRS}
169 Should Not Contain ${gwmac_table} dl_dst=${macAdd} actions=goto_table:${L3_TABLE}
172 Verify GWMAC Flow Entry Removed From Flow Table On All Compute Nodes
173 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
174 FOR ${ip} IN @{OS_CMP_IPS}
175 BuiltIn.Wait Until Keyword Succeeds 30s 10s Verify GWMAC Flow Entry Removed From Flow Table ${ip}
178 Verify ARP REQUEST in groupTable
179 [Arguments] ${group_output} ${Group-ID}
180 [Documentation] get flow dump for group ID
181 Should Contain ${group_output} group_id=${Group-ID}
182 ${arp_group} = Get Lines Containing String ${group_output} group_id=${Group-ID}
184 CompareStream.Run_Keyword_If_At_Most_Oxygen BuiltIn.Should Match Regexp ${arp_group} ${ARP_REQUEST_GROUP_REGEX}
185 CompareStream.Run_Keyword_If_At_Least_Fluorine BuiltIn.Should Match Regexp ${arp_group} ${ARP_REQUEST_GROUP_REGEX_FLUORINE}
187 Verify Tunnel Status as UP
188 [Documentation] Verify that the tunnels are UP
189 BuiltIn.Return From Keyword If ${OS_NODE_CNT} == ${1} ${True}
190 ${output}= Issue Command On Karaf Console ${TEP_SHOW_STATE}
192 Should Contain ${output} ${STATE_UP}
193 Should Not Contain ${output} ${STATE_DOWN}
194 Should Not Contain ${output} ${STATE_UNKNOWN}
196 Verify Tunnel Status as DOWN
197 [Documentation] Verify that the tunnels are DOWN
198 ${output}= Issue Command On Karaf Console ${TEP_SHOW_STATE}
200 Should Contain ${output} ${STATE_DOWN}
201 Should Not Contain ${output} ${STATE_UP}
202 Should Not Contain ${output} ${STATE_UNKNOWN}
204 Verify Tunnel Status as UNKNOWN
205 [Documentation] Verify that the tunnels are in Unknown state
206 ${output}= Issue Command On Karaf Console ${TEP_SHOW_STATE}
208 Should Not Contain ${output} ${STATE_UP}
209 Should Not Contain ${output} ${STATE_DOWN}
210 Should Contain ${output} ${STATE_UNKNOWN}
212 Verify VXLAN interface
213 [Documentation] Verify that the VXLAN interfaces are Enabled
214 ${output}= Issue Command On Karaf Console ${VXLAN_SHOW}
216 Should Contain ${output} ${STATE_UP}
217 Should Contain ${output} ${STATE_ENABLE}
218 Should Not Contain ${output} ${STATE_DISABLE}
221 [Arguments] ${session}
222 [Documentation] Get Fib table entries from ODL session
223 ${resp} RequestsLibrary.Get Request ${session} ${FIB_ENTRIES_URL}
225 [Return] ${resp.content}
227 Get Gateway MAC And IP Address
228 [Arguments] ${router_Name} ${ip_regex}=${IP_REGEX}
229 [Documentation] Get Gateway mac and IP Address
230 ${output} = OpenStack CLI openstack port list --router ${router_Name}
231 @{MacAddr-list} = Get Regexp Matches ${output} ${MAC_REGEX}
232 @{IpAddr-list} = Get Regexp Matches ${output} ${ip_regex}
233 [Return] ${MacAddr-list} ${IpAddr-list}
235 Test Teardown With Tcpdump Stop
236 [Arguments] ${conn_ids}=@{EMPTY}
237 OpenStackOperations.Stop Packet Capture On Nodes ${conn_ids}
238 Get Test Teardown Debugs
240 Verify IPv4 GWMAC Flow Entry On Flow Table
241 [Arguments] ${group_output} ${group_id} ${flow_output}
242 Verify ARP REQUEST in groupTable ${group_output} ${groupID[1]}
243 #Verify ARP_RESPONSE_TABLE - 81
244 Should Contain ${flow_output} table=${ARP_RESPONSE_TABLE}
245 ${arpResponder_table} = Get Lines Containing String ${flow_output} table=${ARP_RESPONSE_TABLE}
246 Should Contain ${arpResponder_table} priority=0 actions=drop
247 FOR ${macAdd} ${ipAdd} IN ZIP ${GWMAC_ADDRS} ${GWIP_ADDRS}
248 ${ARP_RESPONSE_IP_MAC_REGEX} = Set Variable arp_tpa=${ipAdd},arp_op=1 actions=.*,set_field:${macAdd}->eth_src
249 Should Match Regexp ${arpResponder_table} ${ARP_RESPONSE_IP_MAC_REGEX}
252 Verify IPv6 GWMAC Flow Entry On Flow Table
253 [Arguments] ${flow_output}
254 Should Contain ${flow_output} table=${IPV6_TABLE}
255 ${icmp_ipv6_flows} = Get Lines Containing String ${flow_output} icmp_type=135
256 FOR ${ip_addr} IN @{GWIP_ADDRS}
257 ${rule} = Set Variable icmp_type=135,icmp_code=0,nd_target=${ip_addr} actions=CONTROLLER:65535
258 Should Match Regexp ${icmp_ipv6_flows} ${rule}
261 Verify GWMAC Flow Entry On Flow Table
262 [Arguments] ${cnIp} ${ipv}=ipv4
263 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
264 ${flow_output}= Run Command On Remote System ${cnIp} sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
265 ${group_output}= Run Command On Remote System ${cnIp} sudo ovs-ofctl -O OpenFlow13 dump-groups ${INTEGRATION_BRIDGE}
266 Should Contain ${flow_output} table=${DISPATCHER_TABLE}
267 ${dispatcher_table} = Get Lines Containing String ${flow_output} table=${DISPATCHER_TABLE}
268 Should Contain ${dispatcher_table} goto_table:${GWMAC_TABLE}
269 Should Not Contain ${dispatcher_table} goto_table:${ARP_RESPONSE_TABLE}
270 Should Contain ${flow_output} table=${GWMAC_TABLE}
271 ${gwmac_table} = Get Lines Containing String ${flow_output} table=${GWMAC_TABLE}
272 #Verify GWMAC address present in table 19
273 FOR ${macAdd} IN @{GWMAC_ADDRS}
274 Should Contain ${gwmac_table} dl_dst=${macAdd} actions=goto_table:${L3_TABLE}
277 Should Contain ${gwmac_table} actions=resubmit(,17)
278 #Verify ARP_CHECK_TABLE - 43
279 #arp request and response
280 ${arpchk_table} = Get Lines Containing String ${flow_output} table=${ARP_CHECK_TABLE}
281 CompareStream.Run_Keyword_If_At_Most_Oxygen BuiltIn.Should Match Regexp ${arpchk_table} ${ARP_RESPONSE_REGEX}
282 CompareStream.Run_Keyword_If_At_Least_Fluorine BuiltIn.Should Match Regexp ${arpchk_table} ${ARP_RESPONSE_REGEX_FLUORINE}
283 ${arppunt_table} = String.Get Lines Containing String ${flow_output} table=${ARP_PUNT_TABLE}
284 CompareStream.Run_Keyword_If_At_Least_Fluorine BuiltIn.Should Match Regexp ${arppunt_table} ${ARP_PUNT_RESPONSE_REGEX}
285 ${match} = Should Match Regexp ${arpchk_table} ${ARP_REQUEST_REGEX}
286 ${groupID} = Split String ${match} separator=:
287 BuiltIn.Run Keyword If '${ipv}' == 'ipv4' Verify IPv4 GWMAC Flow Entry On Flow Table ${group_output} ${group_id} ${flow_output}
288 ... ELSE Verify IPv6 GWMAC Flow Entry On Flow Table ${flow_output}
290 Verify GWMAC Flow Entry On Flow Table On All Compute Nodes
291 [Arguments] ${ipv}=ipv4
292 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
293 FOR ${ip} IN @{OS_CMP_IPS}
294 BuiltIn.Wait Until Keyword Succeeds 30s 10s VpnOperations.Verify GWMAC Flow Entry On Flow Table ${ip} ${ipv}
297 Delete Multiple L3VPNs
299 [Documentation] Delete three L3VPNs created using Multiple L3VPN Test
300 FOR ${vpn} IN @{vpns}
301 VPN Delete L3VPN vpnid=${vpn}
305 BuiltIn.Return From Keyword If "${OPENSTACK_TOPO}" == "1cmb-0ctl-0cmp"
306 SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
309 BuiltIn.Return From Keyword If "${OPENSTACK_TOPO}" == "1cmb-0ctl-0cmp"
310 OpenStackOperations.Get Test Teardown Debugs