2 Documentation This library contains keywords related to the BGP functionality.
4 Library BgpRpcClient.py ${TOOLS_SYSTEM_IP}
5 Resource ../variables/Variables.robot
7 Resource KillPythonTool.robot
8 Resource TemplatedRequests.robot
11 ${BGP_BMP_DIR} ${CURDIR}/../variables/bgpfunctional/bmp_basic/filled_structure
12 ${BGP_BMP_FEAT_DIR} ${CURDIR}/../variables/bgpfunctional/bmp_basic/empty_structure
13 ${BGP_RIB_URI} ${OPERATIONAL_API}/bgp-rib:bgp-rib/rib/example-bgp-rib
14 ${BGP_TOPOLOGY_URI} ${OPERATIONAL_TOPO_API}/topology/example-ipv4-topology
15 ${VAR_BASE_BGP} ${CURDIR}/../variables/bgpfunctional
16 ${RIB_NAME} example-bgp-rib
17 &{ADJ_RIB_IN} PATH=peer/bgp:%2F%2F${TOOLS_SYSTEM_IP}/adj-rib-in BGP_RIB=${RIB_NAME}
18 &{APP_PEER} IP=${ODL_SYSTEM_IP} BGP_RIB=${RIB_NAME}
19 &{EFFECTIVE_RIB_IN} PATH=peer/bgp:%2F%2F${TOOLS_SYSTEM_IP}/effective-rib-in BGP_RIB=${RIB_NAME}
20 &{LOC_RIB} PATH=loc-rib BGP_RIB=${RIB_NAME}
23 Start Quagga Processes On ODL
25 [Documentation] To start the zrpcd processes on ODL VM
26 ${conn_id}= Open_Connection_To_ODL_System ip_address=${odl_ip}
27 Switch Connection ${conn_id}
28 Write Commands Until Expected Prompt cd /opt/quagga/etc/ ${DEFAULT_LINUX_PROMPT_STRICT}
29 Write Commands Until Expected Prompt sudo cp zebra.conf.sample zebra.conf ${DEFAULT_LINUX_PROMPT_STRICT}
30 Write Commands Until Expected Prompt sudo /opt/quagga/etc/init.d/zrpcd start ${DEFAULT_LINUX_PROMPT_STRICT}
31 Write Commands Until Expected Prompt ps -ef | grep zrpcd ${DEFAULT_LINUX_PROMPT_STRICT}
32 Write Commands Until Expected Prompt netstat -nap | grep 7644 ${DEFAULT_LINUX_PROMPT_STRICT}
35 Restart BGP Processes On ODL
37 [Documentation] To restart the bgpd , qthriftd processes on ODL VM
38 ${conn_id} = Open_Connection_To_ODL_System ip_address=${odl_ip}
39 Switch Connection ${conn_id}
40 Write Commands Until Expected Prompt sudo pkill -f bgpd ${DEFAULT_LINUX_PROMPT_STRICT}
41 Start Quagga Processes On ODL ${odl_ip}
43 Start Quagga Processes On DCGW
44 [Arguments] ${dcgw_ip}
45 [Documentation] To start the zrpcd, bgpd,and zebra processes on DCGW
46 ${dcgw_conn_id} = Open_Connection_To_Tools_System ip_address=${dcgw_ip}
47 Switch Connection ${dcgw_conn_id}
48 Write Commands Until Expected Prompt cd /opt/quagga/etc/ ${DEFAULT_LINUX_PROMPT_STRICT}
49 Write Commands Until Expected Prompt sudo cp zebra.conf.sample zebra.conf ${DEFAULT_LINUX_PROMPT_STRICT}
50 Write Commands Until Expected Prompt sudo /opt/quagga/etc/init.d/zrpcd start ${DEFAULT_LINUX_PROMPT_STRICT}
51 Write Commands Until Expected Prompt ps -ef | grep zrpcd ${DEFAULT_LINUX_PROMPT_STRICT}
52 Write Commands Until Expected Prompt cd /opt/quagga/sbin/ ${DEFAULT_LINUX_PROMPT_STRICT}
53 ${output} = Write sudo ./bgpd &
54 ${output} = Read Until pid
56 ${output} = Write sudo ./zebra &
59 Write Commands Until Expected Prompt ps -ef | grep bgpd ${DEFAULT_LINUX_PROMPT_STRICT}
60 Write Commands Until Expected Prompt ps -ef | grep zebra ${DEFAULT_LINUX_PROMPT_STRICT}
61 Write Commands Until Expected Prompt netstat -nap | grep 7644 ${DEFAULT_LINUX_PROMPT_STRICT}
63 Restart BGP Processes On DCGW
64 [Arguments] ${dcgw_ip}
65 [Documentation] To Restart the zrpcd, bgpd,and zebra processes on DCGW
66 ${dcgw_conn_id} = Open_Connection_To_Tools_System ip_address=${dcgw_ip}
67 Switch Connection ${dcgw_conn_id}
68 Write Commands Until Expected Prompt sudo pkill -f bgpd ${DEFAULT_LINUX_PROMPT_STRICT}
69 Start Quagga Processes On DCGW ${dcgw_ip}
71 Show Quagga Configuration On ODL
72 [Arguments] ${odl_ip} ${rd}
73 [Documentation] Show quagga config from ODL
74 Create Quagga Telnet Session ${odl_ip} bgpd sdncbgpc
75 Execute Command On Quagga Telnet Session show running-config
76 Execute Command On Quagga Telnet Session show bgp neighbors
77 Execute Command On Quagga Telnet Session show ip bgp vrf ${rd}
78 Execute Command On Quagga Telnet Session exit
81 Create Quagga Telnet Session
82 [Arguments] ${ip} ${user} ${password}
83 [Documentation] Create telnet session for Quagga
84 ${conn_id}= Open_Connection_To_Tools_System ip_address=${ip}
85 Switch Connection ${conn_id}
86 ${output} = Write telnet localhost ${user}
87 ${output} = Read Until Password:
88 ${output} = Write ${password}
90 ${output} = Write terminal length 512
93 Execute Command On Quagga Telnet Session
94 [Arguments] ${command}
95 [Documentation] Execute command on Quagga telnet session(session should exist) and returns the output.
96 SSHLibrary.Write ${command}
97 ${output} = SSHLibrary.Read
101 Configure BGP And Add Neighbor On DCGW
102 [Arguments] ${dcgw_ip} ${as_id} ${router_id} ${neighbor_ip} ${vrf_name} ${rd}
104 [Documentation] Configure BGP and add neighbor on the dcgw
105 Create Quagga Telnet Session ${dcgw_ip} bgpd sdncbgpc
106 Execute Command On Quagga Telnet Session configure terminal
107 Execute Command On Quagga Telnet Session router bgp ${as_id}
108 Execute Command On Quagga Telnet Session bgp router-id ${router_id}
109 Execute Command On Quagga Telnet Session redistribute static
110 Execute Command On Quagga Telnet Session redistribute connected
111 Execute Command On Quagga Telnet Session neighbor ${neighbor_ip} send-remote-as ${as_id}
112 Execute Command On Quagga Telnet Session vrf ${vrf_name}
113 Execute Command On Quagga Telnet Session rd ${rd}
114 Execute Command On Quagga Telnet Session rt import ${rd}
115 Execute Command On Quagga Telnet Session rt export ${rd}
116 Execute Command On Quagga Telnet Session exit
117 Execute Command On Quagga Telnet Session address-family vpnv4 unicast
118 Execute Command On Quagga Telnet Session network ${loopback_ip}/32 rd ${rd} tag ${as_id}
119 Execute Command On Quagga Telnet Session neighbor ${neighbor_ip} activate
120 Execute Command On Quagga Telnet Session end
121 Execute Command On Quagga Telnet Session show running-config
122 Execute Command On Quagga Telnet Session exit
124 Add Loopback Interface On DCGW
125 [Arguments] ${dcgw_ip} ${loopback_name} ${loopback_ip} ${user}=zebra ${password}=zebra
126 [Documentation] Add loopback interface on DCGW
127 Create Quagga Telnet Session ${dcgw_ip} ${user} ${password}
128 Execute Command On Quagga Telnet Session enable
129 Execute Command On Quagga Telnet Session ${password}
130 Execute Command On Quagga Telnet Session configure terminal
131 Execute Command On Quagga Telnet Session interface ${loopback_name}
132 Execute Command On Quagga Telnet Session ip address ${loopback_ip}/32
133 Execute Command On Quagga Telnet Session exit
134 Execute Command On Quagga Telnet Session end
135 Execute Command On Quagga Telnet Session show running-config
136 Execute Command On Quagga Telnet Session exit
138 Execute Show Command On Quagga
139 [Arguments] ${dcgw_ip} ${cmd} ${user}=bgpd ${password}=sdncbgpc
140 [Documentation] Execute command on quagga and returns the ouput.
141 Create Quagga Telnet Session ${dcgw_ip} ${user} ${password}
142 ${output} = Execute Command On Quagga Telnet Session ${cmd}
144 Execute Command On quagga Telnet Session exit
147 Verify BGP Neighbor Status On Quagga
148 [Arguments] ${dcgw_ip} ${neighbor_ip}
149 [Documentation] Verify bgp neighbor status on quagga
150 ${output} = Execute Show Command On quagga ${dcgw_ip} show bgp neighbors ${neighbor_ip}
152 Should Contain ${output} BGP state = Established
154 Verify Routes On Quagga
155 [Arguments] ${dcgw_ip} ${rd} ${ip_list}
156 [Documentation] Verify routes on quagga
157 ${output} = Execute Show Command On quagga ${dcgw_ip} show ip bgp vrf ${rd}
159 : FOR ${ip} IN @{ip_list}
160 \ Should Contain ${output} ${ip}
162 Delete BGP Config On Quagga
163 [Arguments] ${dcgw_ip} ${bgp_id} ${user}=bgpd ${password}=sdncbgpc
164 [Documentation] Delete BGP Config on Quagga
165 Create Quagga Telnet Session ${dcgw_ip} ${user} ${password}
166 Execute Command On Quagga Telnet Session configure terminal
167 Execute Command On Quagga Telnet Session no router bgp ${bgp_id}
168 Execute Command On Quagga Telnet Session end
169 ${output} = Execute Command On Quagga Telnet Session show running-config
170 Execute Command On Quagga Telnet Session exit
174 [Arguments] ${dcgw_ip} ${as_id} ${vpn_name} ${rd}
175 [Documentation] Creating L3VPN on DCGW
176 BgpOperations.Create Quagga Telnet Session ${dcgw_ip} bgpd sdncbgpc
177 BgpOperations.Execute Command On Quagga Telnet Session configure terminal
178 BgpOperations.Execute Command On Quagga Telnet Session router bgp ${as_id}
179 BgpOperations.Execute Command On Quagga Telnet Session vrf ${vpn_name}
180 BgpOperations.Execute Command On Quagga Telnet Session rd ${rd}
181 BgpOperations.Execute Command On Quagga Telnet Session rt export ${rd}
182 BgpOperations.Execute Command On Quagga Telnet Session rt import ${rd}
183 BgpOperations.Execute Command On Quagga Telnet Session end
186 [Arguments] ${dcgw_ip} ${as_id} @{vpns}
187 [Documentation] Deleting L3VPN on DCGW
188 BgpOperations.Create Quagga Telnet Session ${dcgw_ip} bgpd sdncbgpc
189 BgpOperations.Execute Command On Quagga Telnet Session configure terminal
190 BgpOperations.Execute Command On Quagga Telnet Session router bgp ${as_id}
191 : FOR ${vpn} IN @{vpns}
192 \ BgpOperations.Execute Command On Quagga Telnet Session no vrf ${vpn}
193 BgpOperations.Execute Command On Quagga Telnet Session end
196 [Arguments] ${dcgw_ip} ${vpn_name} ${rd}
197 [Documentation] Verify L3VPN vrf name and rd value on DCGW
198 ${output} = BgpOperations.Execute Show Command On Quagga ${dcgw_ip} show running-config
199 BuiltIn.Should Contain ${output} vrf ${vpn_name}
200 BuiltIn.Should Contain ${output} rd ${rd}
203 [Arguments] ${dcgw_ip} ${rd} ${network_ip} ${label}
204 [Documentation] Add routes on DCGW
205 BgpOperations.Create Quagga Telnet Session ${dcgw_ip} bgpd sdncbgpc
206 BgpOperations.Execute Command On Quagga Telnet Session configure terminal
207 BgpOperations.Execute Command On Quagga Telnet Session router bgp ${AS_ID}
208 BgpOperations.Execute Command On Quagga Telnet Session address-family vpnv4 unicast
209 BgpOperations.Execute Command On Quagga Telnet Session network ${network_ip}/32 rd ${rd} tag ${label}
210 BgpOperations.Execute Command On Quagga Telnet Session end
212 Create BGP Configuration On ODL
213 [Arguments] &{Kwargs}
214 [Documentation] Associate the created L3VPN to a network-id received as dictionary argument
215 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE_BGP}/create_bgp mapping=${Kwargs} session=session
217 AddNeighbor To BGP Configuration On ODL
218 [Arguments] &{Kwargs}
219 [Documentation] Associate the created L3VPN to a network-id received as dictionary argument
220 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE_BGP}/addNeighbor_bgp mapping=${Kwargs} session=session
222 Get BGP Configuration On ODL
223 [Arguments] ${odl_session}
224 [Documentation] Get bgp configuration
225 ${resp} = RequestsLibrary.Get Request ${odl_session} ${CONFIG_API}/ebgp:bgp/
227 [Return] ${resp.content}
229 Delete BGP Configuration On ODL
230 [Arguments] ${odl_session}
231 [Documentation] Delete BGP
232 ${resp} = RequestsLibrary.Delete Request ${odl_session} ${CONFIG_API}/ebgp:bgp/
234 Should Be Equal As Strings ${resp.status_code} 200
235 [Return] ${resp.content}
237 Create External Tunnel Endpoint Configuration
238 [Arguments] &{Kwargs}
239 [Documentation] Create Tunnel End point
240 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE_BGP}/create_etep mapping=${Kwargs} session=session
242 Delete External Tunnel Endpoint Configuration
243 [Arguments] &{Kwargs}
244 [Documentation] Delete Tunnel End point
245 TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE_BGP}/delete_etep mapping=${Kwargs} session=session
247 Get External Tunnel Endpoint Configuration
249 [Documentation] Get bgp configuration
250 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/itm:dc-gateway-ip-list/dc-gateway-ip/${ip}/
252 [Return] ${resp.content}
255 [Documentation] Create and Log the diff between expected and actual responses, make sure Python tool was killed.
256 ... Tear down imported Resources.
257 KillPythonTool.Search_And_Kill_Remote_Python 'play\.py'
258 RequestsLibrary.Delete_All_Sessions
259 SSHLibrary.Close_All_Connections
261 Check_Example_Bgp_Rib_Content
262 [Arguments] ${session} ${substr} ${error_message}=${JSONKEYSTR} not found, but expected.
263 [Documentation] Check the example-bgp-rib content for string
264 ${response}= RequestsLibrary.Get Request ${session} ${BGP_RIB_URI}
265 BuiltIn.Log ${response.status_code}
266 BuiltIn.Log ${response.text}
267 BuiltIn.Should_Contain ${response.text} ${substr} ${error_message} values=False
269 Check_Example_Bgp_Rib_Does_Not_Contain
270 [Arguments] ${session} ${substr} ${error_message}=${JSONKEYSTR} found, but not expected.
271 [Documentation] Check the example-bgp-rib does not contain the string
272 ${response}= RequestsLibrary.Get Request ${session} ${BGP_RIB_URI}
273 BuiltIn.Log ${response.status_code}
274 BuiltIn.Log ${response.text}
275 BuiltIn.Should_Not_Contain ${response.text} ${substr} ${error_message} values=False
277 Check_Example_IPv4_Topology_Content
278 [Arguments] ${session} ${string_to_check}=${EMPTY}
279 [Documentation] Check the example-ipv4-topology content for string
280 ${response}= RequestsLibrary.Get Request ${session} ${BGP_TOPOLOGY_URI}
281 BuiltIn.Log ${response.status_code}
282 BuiltIn.Log ${response.text}
283 BuiltIn.Should_Contain ${response.text} ${string_to_check}
285 Check_Example_IPv4_Topology_Does_Not_Contain
286 [Arguments] ${session} ${string_to_check}
287 [Documentation] Check the example-ipv4-topology does not contain the string
288 ${response}= RequestsLibrary.Get Request ${session} ${BGP_TOPOLOGY_URI}
289 BuiltIn.Log ${response.status_code}
290 BuiltIn.Log ${response.text}
291 BuiltIn.Should_Not_Contain ${response.text} ${string_to_check}
293 Bmp_Monitor_Precondition
294 [Arguments] ${session}
295 [Documentation] Verify example-bmp-monitor presence in bmp-monitors
296 &{mapping} BuiltIn.Create_Dictionary TOOL_IP=${TOOLS_SYSTEM_IP}
297 BuiltIn.Wait_Until_Keyword_Succeeds 6x 10s TemplatedRequests.Get_As_Json_Templated folder=${BGP_BMP_FEAT_DIR} mapping=${mapping} verify=True
298 ... session=${session}
300 Bmp_Monitor_Postcondition
301 [Arguments] ${session}
302 [Documentation] Verifies if example-bmp-monitor data contains one peer.
303 &{mapping} BuiltIn.Create_Dictionary TOOL_IP=${TOOLS_SYSTEM_IP}
304 ${output} BuiltIn.Wait_Until_Keyword_Succeeds 10x 5s TemplatedRequests.Get_As_Json_Templated folder=${BGP_BMP_DIR} mapping=${mapping}
305 ... session=${session} verify=True
306 BuiltIn.Log ${output}
309 [Arguments] ${totest} ${dir}
310 ${announce_hex} = OperatingSystem.Get_File ${dir}/${totest}/announce_${totest}.hex
311 ${announce_hex} = String.Remove_String ${announce_hex} \n
312 ${withdraw_hex} = OperatingSystem.Get_File ${dir}/${totest}/withdraw_${totest}.hex
313 ${withdraw_hex} = String.Remove_String ${withdraw_hex} \n
314 BgpRpcClient.play_clean
315 TemplatedRequests.Post_As_Xml_Templated ${dir}/${totest}/app mapping=${APP_PEER} session=${CONFIG_SESSION}
316 ${update} BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Get_Update_Message
317 BuiltIn.Should_Be_Equal_As_Strings ${update} ${announce_hex}
318 BgpRpcClient.play_clean
319 Remove_Configured_Routes ${totest} ${dir}
320 ${update} BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Get_Update_Message
321 BuiltIn.Should_Be_Equal_As_Strings ${update} ${withdraw_hex}
322 [Teardown] Remove_Configured_Routes ${totest} ${dir}
325 [Arguments] ${totest} ${dir} ${ipv}=ipv4
326 ${announce_hex} = OperatingSystem.Get_File ${dir}/${totest}/announce_${totest}.hex
327 ${withdraw_hex} = OperatingSystem.Get_File ${dir}/${totest}/withdraw_${totest}.hex
328 BgpRpcClient.play_clean
329 BgpRpcClient.play_send ${announce_hex}
330 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s TemplatedRequests.Get_As_Json_Templated ${dir}/${totest}/rib mapping=${ADJ_RIB_IN} session=${CONFIG_SESSION}
332 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s TemplatedRequests.Get_As_Json_Templated ${dir}/${totest}/rib mapping=${EFFECTIVE_RIB_IN} session=${CONFIG_SESSION}
334 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s TemplatedRequests.Get_As_Json_Templated ${dir}/${totest}/rib mapping=${LOC_RIB} session=${CONFIG_SESSION}
336 BgpRpcClient.play_send ${withdraw_hex}
337 BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s TemplatedRequests.Get_As_Json_Templated ${dir}/empty_routes/${ipv} mapping=${LOC_RIB} session=${CONFIG_SESSION}
339 [Teardown] BgpRpcClient.play_send ${withdraw_hex}
342 [Documentation] Returns hex update message.
343 ${update} = BgpRpcClient.play_get
344 BuiltIn.Should_Not_Be_Equal ${update} ${Empty}
347 Remove_Configured_Routes
348 [Arguments] ${totest} ${dir}
349 [Documentation] Removes the route if present.
350 BuiltIn.Run_Keyword_And_Ignore_Error TemplatedRequests.Delete_Templated ${dir}/${totest}/app mapping=${APP_PEER} session=${CONFIG_SESSION}