2 Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances
5 Resource TemplatedRequests.robot
6 Resource KarafKeywords.robot
7 Resource ../variables/Variables.robot
10 Library OperatingSystem
13 &{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
14 ... dpnid2=2 portname2= BR2-eth1 ipaddress2=3.3.3.3
15 &{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
16 ${VAR_BASE} ${CURDIR}/../variables/vpnservice/
17 ${ODL_FLOWTABLE_L3VPN} 21
20 ${STATE_UNKNOWN} UNKNOWN
21 ${STATE_ENABLE} ENABLED
22 ${STATE_DISABLE} DISABLE
27 OpenStackOperations.OpenStack Suite Setup
28 TemplatedRequests.Create Default Session timeout=${SESSION_TIMEOUT}
30 Basic Vpnservice Suite Cleanup
31 [Arguments] ${vpn_instance_ids}=@{EMPTY} ${vms}=@{EMPTY} ${networks}=@{EMPTY} ${subnets}=@{EMPTY} ${ports}=@{EMPTY} ${sgs}=@{EMPTY}
32 : FOR ${vpn_instance_id} IN @{vpn_instance_ids}
33 \ BuiltIn.Run Keyword And Ignore Error VPN Delete L3VPN vpnid=${vpn_instance_id}
34 OpenStackOperations.Neutron Cleanup ${vms} ${networks} ${subnets} ${ports} ${sgs}
38 [Documentation] Create an L3VPN using the Json using the list of optional arguments received.
39 Run keyword if "routerid" in ${Kwargs} Collections.Set_To_Dictionary ${Kwargs} router=, "router-id":"${Kwargs['routerid']}"
40 ... ELSE Collections.Set_To_Dictionary ${Kwargs} router=${empty}
41 &{L3vpn_create_actual_val} = Collections.Copy_Dictionary ${L3VPN_CREATE_DEFAULT}
42 Collections.Set_To_Dictionary ${L3vpn_create_actual_val} &{Kwargs}
43 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/l3vpn_create mapping=${L3vpn_create_actual_val} session=default http_timeout=${SESSION_TIMEOUT}
47 [Documentation] Will return detailed list of the L3VPN_ID received
48 ${resp} = TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/get_l3vpn mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
54 [Documentation] Check that sub interface ip has been learnt after ARP request
55 ${resp} = RequestsLibrary.Get Request session ${VPN_REST}
56 BuiltIn.Log ${resp.content}
57 @{list_any_matches} = String.Get_Regexp_Matches ${resp.content} \"vpn-instance-name\":\"${VPN_INSTANCE_ID}\",.*"vrf-id":"${vrf_id}",\"vpn-id\":(\\d+) 1
58 ${result} = Evaluate ${list_any_matches[0]} * 2
59 ${vpn_id_hex} = BuiltIn.Convert To Hex ${result}
60 [Return] ${vpn_id_hex.lower()}
62 Associate L3VPN To Network
64 [Documentation] Associate the created L3VPN to a network-id received as dictionary argument
65 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/assoc_l3vpn mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
67 Dissociate L3VPN From Networks
69 [Documentation] Disssociate the already associated networks from L3VPN
70 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/dissoc_l3vpn mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
72 Associate VPN to Router
74 [Documentation] Associate the created L3VPN to a router-id received as argument
75 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/assoc_router_l3vpn mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
77 Dissociate VPN to Router
79 [Documentation] Dissociate the already associated routers from L3VPN
80 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/dissoc_router_l3vpn mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
84 [Documentation] Delete the created L3VPN
85 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/l3vpn_delete mapping=${Kwargs} session=default http_timeout=${SESSION_TIMEOUT}
89 [Documentation] Creates Tunnel between the two DPNs received in the dictionary argument
90 &{Itm_actual_val} = Collections.Copy_Dictionary ${ITM_CREATE_DEFAULT}
91 Collections.Set_To_Dictionary ${Itm_actual_val} &{Kwargs}
92 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/itm_create mapping=${Itm_actual_val} session=default http_timeout=${SESSION_TIMEOUT}
95 [Documentation] Get all Tunnels and return the contents
96 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/itm:transport-zones/
98 Should Be Equal As Strings ${resp.status_code} 200
99 [Return] ${resp.content}
102 [Arguments] ${zone-name}
103 [Documentation] Delete Tunnels created under the transport-zone
104 ${resp} = RequestsLibrary.Delete Request session ${CONFIG_API}/itm:transport-zones/transport-zone/${zone-name}/
106 Should Be Equal As Strings ${resp.status_code} 200
107 [Return] ${resp.content}
109 Verify Flows Are Present For L3VPN
110 [Arguments] ${ip} ${vm_ips}
111 [Documentation] Verify Flows Are Present For L3VPN
112 ${flow_output}= Run Command On Remote System And Log ${ip} sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
113 Should Contain ${flow_output} table=${ODL_FLOWTABLE_L3VPN}
114 ${l3vpn_table} = Get Lines Containing String ${flow_output} table=${ODL_FLOWTABLE_L3VPN},
116 : FOR ${i} IN @{vm_ips}
117 \ ${resp}= Should Contain ${l3vpn_table} ${i}
119 Verify GWMAC Entry On ODL
120 [Arguments] ${GWMAC_ADDRS}
121 [Documentation] get ODL GWMAC table entry
122 ${resp} = RequestsLibrary.Get Request session ${VPN_PORT_DATA_URL}
124 Should Be Equal As Strings ${resp.status_code} 200
125 : FOR ${macAdd} IN @{GWMAC_ADDRS}
126 \ Should Contain ${resp.content} ${macAdd}
128 Verify GWMAC Flow Entry Removed From Flow Table
130 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
131 ${flow_output}= Run Command On Remote System And Log ${cnIp} sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
132 Should Contain ${flow_output} table=${GWMAC_TABLE}
133 ${gwmac_table} = Get Lines Containing String ${flow_output} table=${GWMAC_TABLE}
135 #Verify GWMAC address present in table 19
136 : FOR ${macAdd} IN @{GWMAC_ADDRS}
137 \ Should Not Contain ${gwmac_table} dl_dst=${macAdd} actions=goto_table:${L3_TABLE}
139 Verify ARP REQUEST in groupTable
140 [Arguments] ${group_output} ${Group-ID}
141 [Documentation] get flow dump for group ID
142 Should Contain ${group_output} group_id=${Group-ID}
143 ${arp_group} = Get Lines Containing String ${group_output} group_id=${Group-ID}
145 Should Match Regexp ${arp_group} ${ARP_REQUEST_GROUP_REGEX}
147 Verify Tunnel Status as UP
148 [Documentation] Verify that the tunnels are UP
149 ${output}= Issue Command On Karaf Console ${TEP_SHOW_STATE}
151 Should Contain ${output} ${STATE_UP}
152 Should Not Contain ${output} ${STATE_DOWN}
153 Should Not Contain ${output} ${STATE_UNKNOWN}
155 Verify Tunnel Status as DOWN
156 [Documentation] Verify that the tunnels are DOWN
157 ${output}= Issue Command On Karaf Console ${TEP_SHOW_STATE}
159 Should Contain ${output} ${STATE_DOWN}
160 Should Not Contain ${output} ${STATE_UP}
161 Should Not Contain ${output} ${STATE_UNKNOWN}
163 Verify Tunnel Status as UNKNOWN
164 [Documentation] Verify that the tunnels are in Unknown state
165 ${output}= Issue Command On Karaf Console ${TEP_SHOW_STATE}
167 Should Not Contain ${output} ${STATE_UP}
168 Should Not Contain ${output} ${STATE_DOWN}
169 Should Contain ${output} ${STATE_UNKNOWN}
171 Verify VXLAN interface
172 [Documentation] Verify that the VXLAN interfaces are Enabled
173 ${output}= Issue Command On Karaf Console ${VXLAN_SHOW}
175 Should Contain ${output} ${STATE_UP}
176 Should Contain ${output} ${STATE_ENABLE}
177 Should Not Contain ${output} ${STATE_DISABLE}
180 [Arguments] ${session}
181 [Documentation] Get Fib table entries from ODL session
182 ${resp} RequestsLibrary.Get Request ${session} ${FIB_ENTRIES_URL}
184 [Return] ${resp.content}
186 Get Gateway MAC And IP Address
187 [Arguments] ${router_Name} ${ip_regex}=${IP_REGEX}
188 [Documentation] Get Gateway mac and IP Address
189 ${output} = Write Commands Until Prompt neutron router-port-list ${router_Name} 30s
190 @{MacAddr-list} = Get Regexp Matches ${output} ${MAC_REGEX}
191 @{IpAddr-list} = Get Regexp Matches ${output} ${ip_regex}
192 [Return] ${MacAddr-list} ${IpAddr-list}
194 Test Teardown With Tcpdump Stop
195 [Arguments] ${conn_ids}=@{EMPTY}
196 OpenStackOperations.Stop Packet Capture On Nodes ${conn_ids}
197 Get Test Teardown Debugs
199 Verify IPv4 GWMAC Flow Entry On Flow Table
200 [Arguments] ${group_output} ${group_id} ${flow_output}
201 Verify ARP REQUEST in groupTable ${group_output} ${groupID[1]}
202 #Verify ARP_RESPONSE_TABLE - 81
203 Should Contain ${flow_output} table=${ARP_RESPONSE_TABLE}
204 ${arpResponder_table} = Get Lines Containing String ${flow_output} table=${ARP_RESPONSE_TABLE}
205 Should Contain ${arpResponder_table} priority=0 actions=drop
206 : FOR ${macAdd} ${ipAdd} IN ZIP ${GWMAC_ADDRS} ${GWIP_ADDRS}
207 \ ${ARP_RESPONSE_IP_MAC_REGEX} = Set Variable arp_tpa=${ipAdd},arp_op=1 actions=.*,set_field:${macAdd}->eth_src
208 \ Should Match Regexp ${arpResponder_table} ${ARP_RESPONSE_IP_MAC_REGEX}
210 Verify IPv6 GWMAC Flow Entry On Flow Table
211 [Arguments] ${flow_output}
212 Should Contain ${flow_output} table=${IPV6_TABLE}
213 ${icmp_ipv6_flows} = Get Lines Containing String ${flow_output} icmp_type=135
214 : FOR ${ip_addr} IN @{GWIP_ADDRS}
215 \ ${rule} = Set Variable icmp_type=135,icmp_code=0,nd_target=${ip_addr} actions=CONTROLLER:65535
216 \ Should Match Regexp ${icmp_ipv6_flows} ${rule}
218 Verify GWMAC Flow Entry On Flow Table
219 [Arguments] ${cnIp} ${ipv}=ipv4
220 [Documentation] Verify the GWMAC Table, ARP Response table and Dispatcher table.
221 ${flow_output}= Run Command On Remote System ${cnIp} sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
222 ${group_output}= Run Command On Remote System ${cnIp} sudo ovs-ofctl -O OpenFlow13 dump-groups br-int
223 Should Contain ${flow_output} table=${DISPATCHER_TABLE}
224 ${dispatcher_table} = Get Lines Containing String ${flow_output} table=${DISPATCHER_TABLE}
225 Should Contain ${dispatcher_table} goto_table:${GWMAC_TABLE}
226 Should Not Contain ${dispatcher_table} goto_table:${ARP_RESPONSE_TABLE}
227 Should Contain ${flow_output} table=${GWMAC_TABLE}
228 ${gwmac_table} = Get Lines Containing String ${flow_output} table=${GWMAC_TABLE}
229 #Verify GWMAC address present in table 19
230 : FOR ${macAdd} IN @{GWMAC_ADDRS}
231 \ Should Contain ${gwmac_table} dl_dst=${macAdd} actions=goto_table:${L3_TABLE}
233 Should Contain ${gwmac_table} actions=resubmit(,17)
234 #Verify ARP_CHECK_TABLE - 43
235 #arp request and response
236 ${arpchk_table} = Get Lines Containing String ${flow_output} table=${ARP_CHECK_TABLE}
237 Should Match Regexp ${arpchk_table} ${ARP_RESPONSE_REGEX}
238 ${match} = Should Match Regexp ${arpchk_table} ${ARP_REQUEST_REGEX}
239 ${groupID} = Split String ${match} separator=:
240 BuiltIn.Run Keyword If '${ipv}' == 'ipv4' Verify IPv4 GWMAC Flow Entry On Flow Table ${group_output} ${group_id} ${flow_output}
241 ... ELSE Verify IPv6 GWMAC Flow Entry On Flow Table ${flow_output}
243 Delete Multiple L3VPNs
245 [Documentation] Delete three L3VPNs created using Multiple L3VPN Test
246 : FOR ${vpn} IN ${vpns}
247 \ VPN Delete L3VPN vpnid=${vpn}