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